[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/25] can_host: Use class properties
From: |
Eduardo Habkost |
Subject: |
[PULL 08/25] can_host: Use class properties |
Date: |
Tue, 15 Dec 2020 10:19:25 -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 | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/net/can/can_host.c b/net/can/can_host.c
index ba7f163d0a..a3c84028c6 100644
--- a/net/can/can_host.c
+++ b/net/can/can_host.c
@@ -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 },
--
2.28.0
- [PULL 14/25] qdev: Check dev->realized at set_size(), (continued)
- [PULL 14/25] qdev: Check dev->realized at set_size(), Eduardo Habkost, 2020/12/15
- [PULL 21/25] qdev: Make check_prop_still_unset() get Object* argument, Eduardo Habkost, 2020/12/15
- [PULL 15/25] sparc: Check dev->realized at sparc_set_nwindows(), Eduardo Habkost, 2020/12/15
- [PULL 01/25] vexpress: Register "secure" as class property, Eduardo Habkost, 2020/12/15
- [PULL 16/25] qdev: Don't use dev->id on set_size32() error message, Eduardo Habkost, 2020/12/15
- [PULL 11/25] cs4231: Get rid of empty property array, Eduardo Habkost, 2020/12/15
- [PULL 07/25] arm/cpu64: Register "aarch64" as class property, Eduardo Habkost, 2020/12/15
- [PULL 04/25] i386: Register feature bit properties as class properties, Eduardo Habkost, 2020/12/15
- [PULL 13/25] qdev: Move property code to qdev-properties.[ch], Eduardo Habkost, 2020/12/15
- [PULL 12/25] cpu: Move cpu_common_props to hw/core/cpu.c, Eduardo Habkost, 2020/12/15
- [PULL 08/25] can_host: Use class properties,
Eduardo Habkost <=
- [PULL 25/25] MAINTAINERS: Update my git repository URLs, Eduardo Habkost, 2020/12/15
- [PULL 17/25] qdev: Make PropertyInfo.print method get Object* argument, Eduardo Habkost, 2020/12/15
- [PULL 20/25] qdev: Make qdev_find_global_prop() get Object* argument, Eduardo Habkost, 2020/12/15
- [PULL 23/25] qdev: Make qdev_propinfo_get_uint16() static, Eduardo Habkost, 2020/12/15
- [PULL 19/25] qdev: Make qdev_get_prop_ptr() get Object* arg, Eduardo Habkost, 2020/12/15
- [PULL 24/25] qdev: Move UUID property to qdev-properties-system.c, Eduardo Habkost, 2020/12/15
- [PULL 06/25] virt: Register "its" as class property, Eduardo Habkost, 2020/12/15
- Re: [PULL 00/25] Machine queue, 2020-12-15, Peter Maydell, 2020/12/15