[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 03/25] tmp421: Register properties as class properties
From: |
Eduardo Habkost |
Subject: |
[PULL 03/25] tmp421: Register properties as class properties |
Date: |
Tue, 15 Dec 2020 10:19:20 -0500 |
Class properties make QOM introspection simpler and easier, as
they don't require an object to be instantiated.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20201111183823.283752-4-ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/misc/tmp421.c | 30 +++++++++++++-----------------
1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/hw/misc/tmp421.c b/hw/misc/tmp421.c
index ef3c682e32..a3db57dcb5 100644
--- a/hw/misc/tmp421.c
+++ b/hw/misc/tmp421.c
@@ -337,22 +337,6 @@ static void tmp421_realize(DeviceState *dev, Error **errp)
tmp421_reset(&s->i2c);
}
-static void tmp421_initfn(Object *obj)
-{
- object_property_add(obj, "temperature0", "int",
- tmp421_get_temperature,
- tmp421_set_temperature, NULL, NULL);
- object_property_add(obj, "temperature1", "int",
- tmp421_get_temperature,
- tmp421_set_temperature, NULL, NULL);
- object_property_add(obj, "temperature2", "int",
- tmp421_get_temperature,
- tmp421_set_temperature, NULL, NULL);
- object_property_add(obj, "temperature3", "int",
- tmp421_get_temperature,
- tmp421_set_temperature, NULL, NULL);
-}
-
static void tmp421_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -365,6 +349,19 @@ static void tmp421_class_init(ObjectClass *klass, void
*data)
k->send = tmp421_tx;
dc->vmsd = &vmstate_tmp421;
sc->dev = (DeviceInfo *) data;
+
+ object_class_property_add(klass, "temperature0", "int",
+ tmp421_get_temperature,
+ tmp421_set_temperature, NULL, NULL);
+ object_class_property_add(klass, "temperature1", "int",
+ tmp421_get_temperature,
+ tmp421_set_temperature, NULL, NULL);
+ object_class_property_add(klass, "temperature2", "int",
+ tmp421_get_temperature,
+ tmp421_set_temperature, NULL, NULL);
+ object_class_property_add(klass, "temperature3", "int",
+ tmp421_get_temperature,
+ tmp421_set_temperature, NULL, NULL);
}
static const TypeInfo tmp421_info = {
@@ -372,7 +369,6 @@ static const TypeInfo tmp421_info = {
.parent = TYPE_I2C_SLAVE,
.instance_size = sizeof(TMP421State),
.class_size = sizeof(TMP421Class),
- .instance_init = tmp421_initfn,
.abstract = true,
};
--
2.28.0
- [PULL 00/25] Machine queue, 2020-12-15, Eduardo Habkost, 2020/12/15
- [PULL 02/25] vexpress-a15: Register "virtualization" as class property, Eduardo Habkost, 2020/12/15
- [PULL 09/25] netfilter: Reorder functions, Eduardo Habkost, 2020/12/15
- [PULL 18/25] qdev: Make bit_prop_set() get Object* argument, Eduardo Habkost, 2020/12/15
- [PULL 03/25] tmp421: Register properties as class properties,
Eduardo Habkost <=
- [PULL 10/25] netfilter: Use class properties, Eduardo Habkost, 2020/12/15
- [PULL 05/25] arm/virt: Register most properties as class properties, Eduardo Habkost, 2020/12/15
- [PULL 22/25] qdev: Make error_set_from_qdev_prop_error() get Object* argument, Eduardo Habkost, 2020/12/15
- [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