]> git.proxmox.com Git - mirror_qemu.git/commitdiff
can_host: Use class properties
authorEduardo Habkost <ehabkost@redhat.com>
Wed, 11 Nov 2020 18:38:19 +0000 (13:38 -0500)
committerEduardo Habkost <ehabkost@redhat.com>
Tue, 15 Dec 2020 15:02:07 +0000 (10:02 -0500)
Instance properties make introspection hard and are not shown by
"-object ...,help".  Convert them to class properties.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Tested-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Message-Id: <20201111183823.283752-9-ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
net/can/can_host.c

index ba7f163d0a00c881aa63d11335c8f2a008bdd76b..a3c84028c61fd40855ced5df4de3a9e2d4cead03 100644 (file)
@@ -77,21 +77,16 @@ static void can_host_complete(UserCreatable *uc, Error **errp)
     can_host_connect(CAN_HOST(uc), errp);
 }
 
-static void can_host_instance_init(Object *obj)
-{
-    CanHostState *ch = CAN_HOST(obj);
-
-    object_property_add_link(obj, "canbus", TYPE_CAN_BUS,
-                             (Object **)&ch->bus,
-                             object_property_allow_set_link,
-                             OBJ_PROP_LINK_STRONG);
-}
-
 static void can_host_class_init(ObjectClass *klass,
                                 void *class_data G_GNUC_UNUSED)
 {
     UserCreatableClass *uc_klass = USER_CREATABLE_CLASS(klass);
 
+    object_class_property_add_link(klass, "canbus", TYPE_CAN_BUS,
+                                   offsetof(CanHostState, bus),
+                                   object_property_allow_set_link,
+                                   OBJ_PROP_LINK_STRONG);
+
     klass->unparent = can_host_unparent;
     uc_klass->complete = can_host_complete;
 }
@@ -102,7 +97,6 @@ static const TypeInfo can_host_info = {
     .instance_size = sizeof(CanHostState),
     .class_size = sizeof(CanHostClass),
     .abstract = true,
-    .instance_init = can_host_instance_init,
     .class_init = can_host_class_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_USER_CREATABLE },