* [PATCH v3 0/1] hw/adc: convert object props to class props
@ 2026-07-03 14:32 Mark Cave-Ayland
2026-07-03 14:32 ` [PATCH v3 1/1] hw/adc/npcm7xx_adc.c: convert NPCM7XX_ADC " Mark Cave-Ayland
0 siblings, 1 reply; 6+ messages in thread
From: Mark Cave-Ayland @ 2026-07-03 14:32 UTC (permalink / raw)
To: kfting, wuhaotsh, alistair, peter.maydell, berrange, qemu-arm,
qemu-devel
Since the use of object props is effectively deprecated, here is an attempt
to convert all use of object props in hw/adc to class props. The eventual
aim is to continue working through the codebase, removing all remaining uses
of object props.
The series is lightly tested: it passes "make check", GitLab CI and some
simple local tests. I'm mostly interested for feedback on the conversion
strategy, and to get a feel for the best way to merge this series since once
the basic conversion patterns are in place, the same patterns can be applied
elsewhere and it would be good to minimise the merge window for such changes.
Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Based-on: 20260703135512.3213964-1-mark.caveayland@nutanix.com ("hw/acpi: convert object props to class props")
v3:
- Rebase onto 20260703135512.3213964-1-mark.caveayland@nutanix.com ("hw/acpi: convert object props to class props")
to use new object_class_property_add_uint32_ptr() function
v2:
- Drop support for "foo[*]" notation, and generate the array property name
directly as suggested by Daniel
Mark Cave-Ayland (1):
hw/adc/npcm7xx_adc.c: convert NPCM7XX_ADC object props to class props
hw/adc/npcm7xx_adc.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/1] hw/adc/npcm7xx_adc.c: convert NPCM7XX_ADC object props to class props
2026-07-03 14:32 [PATCH v3 0/1] hw/adc: convert object props to class props Mark Cave-Ayland
@ 2026-07-03 14:32 ` Mark Cave-Ayland
2026-07-06 6:59 ` Philippe Mathieu-Daudé
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Mark Cave-Ayland @ 2026-07-03 14:32 UTC (permalink / raw)
To: kfting, wuhaotsh, alistair, peter.maydell, berrange, qemu-arm,
qemu-devel
Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
---
hw/adc/npcm7xx_adc.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/hw/adc/npcm7xx_adc.c b/hw/adc/npcm7xx_adc.c
index 3584c27c75..27d42f87b1 100644
--- a/hw/adc/npcm7xx_adc.c
+++ b/hw/adc/npcm7xx_adc.c
@@ -229,7 +229,6 @@ static void npcm7xx_adc_init(Object *obj)
{
NPCM7xxADCState *s = NPCM7XX_ADC(obj);
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
- int i;
sysbus_init_irq(sbd, &s->irq);
@@ -240,12 +239,6 @@ static void npcm7xx_adc_init(Object *obj)
sysbus_init_mmio(sbd, &s->iomem);
s->clock = qdev_init_clock_in(DEVICE(s), "clock", NULL, NULL, 0);
- for (i = 0; i < NPCM7XX_ADC_NUM_INPUTS; ++i) {
- object_property_add_uint32_ptr(obj, "adci[*]",
- &s->adci[i], OBJ_PROP_FLAG_READWRITE);
- }
- object_property_add_uint32_ptr(obj, "vref",
- &s->vref, OBJ_PROP_FLAG_WRITE);
npcm7xx_adc_calibrate(s);
}
@@ -275,6 +268,7 @@ static void npcm7xx_adc_class_init(ObjectClass *klass, const void *data)
{
ResettableClass *rc = RESETTABLE_CLASS(klass);
DeviceClass *dc = DEVICE_CLASS(klass);
+ int i;
dc->desc = "NPCM7xx ADC Module";
dc->vmsd = &vmstate_npcm7xx_adc;
@@ -282,6 +276,17 @@ static void npcm7xx_adc_class_init(ObjectClass *klass, const void *data)
rc->phases.hold = npcm7xx_adc_hold_reset;
device_class_set_props(dc, npcm7xx_timer_properties);
+
+ for (i = 0; i < NPCM7XX_ADC_NUM_INPUTS; ++i) {
+ g_autofree char *adciprop = g_strdup_printf("adci[%u]", i);
+
+ object_class_property_add_uint32_ptr(klass, adciprop,
+ offsetof(NPCM7xxADCState, adci[i]),
+ OBJ_PROP_FLAG_READWRITE);
+ }
+ object_class_property_add_uint32_ptr(klass, "vref",
+ offsetof(NPCM7xxADCState, vref),
+ OBJ_PROP_FLAG_WRITE);
}
static const TypeInfo npcm7xx_adc_info = {
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/1] hw/adc/npcm7xx_adc.c: convert NPCM7XX_ADC object props to class props
2026-07-03 14:32 ` [PATCH v3 1/1] hw/adc/npcm7xx_adc.c: convert NPCM7XX_ADC " Mark Cave-Ayland
@ 2026-07-06 6:59 ` Philippe Mathieu-Daudé
2026-07-07 11:50 ` Daniel P. Berrangé
2026-07-07 11:56 ` Daniel P. Berrangé
2 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-06 6:59 UTC (permalink / raw)
To: Mark Cave-Ayland, kfting, wuhaotsh, alistair, peter.maydell,
berrange, qemu-arm, qemu-devel
On 3/7/26 16:32, Mark Cave-Ayland wrote:
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> ---
> hw/adc/npcm7xx_adc.c | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/1] hw/adc/npcm7xx_adc.c: convert NPCM7XX_ADC object props to class props
2026-07-03 14:32 ` [PATCH v3 1/1] hw/adc/npcm7xx_adc.c: convert NPCM7XX_ADC " Mark Cave-Ayland
2026-07-06 6:59 ` Philippe Mathieu-Daudé
@ 2026-07-07 11:50 ` Daniel P. Berrangé
2026-07-07 11:53 ` Daniel P. Berrangé
2026-07-07 11:56 ` Daniel P. Berrangé
2 siblings, 1 reply; 6+ messages in thread
From: Daniel P. Berrangé @ 2026-07-07 11:50 UTC (permalink / raw)
To: Mark Cave-Ayland
Cc: kfting, wuhaotsh, alistair, peter.maydell, qemu-arm, qemu-devel
On Fri, Jul 03, 2026 at 03:32:17PM +0100, Mark Cave-Ayland wrote:
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> ---
> hw/adc/npcm7xx_adc.c | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/hw/adc/npcm7xx_adc.c b/hw/adc/npcm7xx_adc.c
> index 3584c27c75..27d42f87b1 100644
> --- a/hw/adc/npcm7xx_adc.c
> +++ b/hw/adc/npcm7xx_adc.c
> @@ -229,7 +229,6 @@ static void npcm7xx_adc_init(Object *obj)
> {
> NPCM7xxADCState *s = NPCM7XX_ADC(obj);
> SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
> - int i;
>
> sysbus_init_irq(sbd, &s->irq);
>
> @@ -240,12 +239,6 @@ static void npcm7xx_adc_init(Object *obj)
> sysbus_init_mmio(sbd, &s->iomem);
> s->clock = qdev_init_clock_in(DEVICE(s), "clock", NULL, NULL, 0);
>
> - for (i = 0; i < NPCM7XX_ADC_NUM_INPUTS; ++i) {
> - object_property_add_uint32_ptr(obj, "adci[*]",
> - &s->adci[i], OBJ_PROP_FLAG_READWRITE);
> - }
> - object_property_add_uint32_ptr(obj, "vref",
> - &s->vref, OBJ_PROP_FLAG_WRITE);
> npcm7xx_adc_calibrate(s);
> }
>
> @@ -275,6 +268,7 @@ static void npcm7xx_adc_class_init(ObjectClass *klass, const void *data)
> {
> ResettableClass *rc = RESETTABLE_CLASS(klass);
> DeviceClass *dc = DEVICE_CLASS(klass);
> + int i;
>
> dc->desc = "NPCM7xx ADC Module";
> dc->vmsd = &vmstate_npcm7xx_adc;
> @@ -282,6 +276,17 @@ static void npcm7xx_adc_class_init(ObjectClass *klass, const void *data)
> rc->phases.hold = npcm7xx_adc_hold_reset;
>
> device_class_set_props(dc, npcm7xx_timer_properties);
> +
> + for (i = 0; i < NPCM7XX_ADC_NUM_INPUTS; ++i) {
> + g_autofree char *adciprop = g_strdup_printf("adci[%u]", i);
> +
> + object_class_property_add_uint32_ptr(klass, adciprop,
> + offsetof(NPCM7xxADCState, adci[i]),
> + OBJ_PROP_FLAG_READWRITE);
> + }
> + object_class_property_add_uint32_ptr(klass, "vref",
> + offsetof(NPCM7xxADCState, vref),
> + OBJ_PROP_FLAG_WRITE);
Are you sure this actually works ?
With the old code:
object_property_add_uint32_ptr(obj, "adci[*]",
&s->adci[i], OBJ_PROP_FLAG_READWRITE);
we're passing the absolute address of a struct field.
With the new code:
object_class_property_add_uint32_ptr(klass, adciprop,
offsetof(NPCM7xxADCState, adci[i]),
OBJ_PROP_FLAG_READWRITE);
we're passing the relative offset from the start of the struct.
I agree this makes sense as the semantics we'd want/need, but it
doesn't seem to be what's actually implementefd
Both object_property_add_uint32_ptr and object_class_property_add_uint32_ptr
use the same property_get_uint32_ptr & property_set_uint32_ptr
callbacks.
IOW, afaict object_class_property_add_uint32_ptr is expecting to get
an absolute address, not a relative offset.
This seems to make object_class_property_add_uint32_ptr largely
useless unless trying to set global variables, instead of instance
level fields.
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/1] hw/adc/npcm7xx_adc.c: convert NPCM7XX_ADC object props to class props
2026-07-07 11:50 ` Daniel P. Berrangé
@ 2026-07-07 11:53 ` Daniel P. Berrangé
0 siblings, 0 replies; 6+ messages in thread
From: Daniel P. Berrangé @ 2026-07-07 11:53 UTC (permalink / raw)
To: Mark Cave-Ayland, kfting, wuhaotsh, alistair, peter.maydell,
qemu-arm, qemu-devel
On Tue, Jul 07, 2026 at 12:50:34PM +0100, Daniel P. Berrangé wrote:
> On Fri, Jul 03, 2026 at 03:32:17PM +0100, Mark Cave-Ayland wrote:
> > Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> > ---
> > hw/adc/npcm7xx_adc.c | 19 ++++++++++++-------
> > 1 file changed, 12 insertions(+), 7 deletions(-)
> >
> > diff --git a/hw/adc/npcm7xx_adc.c b/hw/adc/npcm7xx_adc.c
> > index 3584c27c75..27d42f87b1 100644
> > --- a/hw/adc/npcm7xx_adc.c
> > +++ b/hw/adc/npcm7xx_adc.c
> > @@ -229,7 +229,6 @@ static void npcm7xx_adc_init(Object *obj)
> > {
> > NPCM7xxADCState *s = NPCM7XX_ADC(obj);
> > SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
> > - int i;
> >
> > sysbus_init_irq(sbd, &s->irq);
> >
> > @@ -240,12 +239,6 @@ static void npcm7xx_adc_init(Object *obj)
> > sysbus_init_mmio(sbd, &s->iomem);
> > s->clock = qdev_init_clock_in(DEVICE(s), "clock", NULL, NULL, 0);
> >
> > - for (i = 0; i < NPCM7XX_ADC_NUM_INPUTS; ++i) {
> > - object_property_add_uint32_ptr(obj, "adci[*]",
> > - &s->adci[i], OBJ_PROP_FLAG_READWRITE);
> > - }
> > - object_property_add_uint32_ptr(obj, "vref",
> > - &s->vref, OBJ_PROP_FLAG_WRITE);
> > npcm7xx_adc_calibrate(s);
> > }
> >
> > @@ -275,6 +268,7 @@ static void npcm7xx_adc_class_init(ObjectClass *klass, const void *data)
> > {
> > ResettableClass *rc = RESETTABLE_CLASS(klass);
> > DeviceClass *dc = DEVICE_CLASS(klass);
> > + int i;
> >
> > dc->desc = "NPCM7xx ADC Module";
> > dc->vmsd = &vmstate_npcm7xx_adc;
> > @@ -282,6 +276,17 @@ static void npcm7xx_adc_class_init(ObjectClass *klass, const void *data)
> > rc->phases.hold = npcm7xx_adc_hold_reset;
> >
> > device_class_set_props(dc, npcm7xx_timer_properties);
> > +
> > + for (i = 0; i < NPCM7XX_ADC_NUM_INPUTS; ++i) {
> > + g_autofree char *adciprop = g_strdup_printf("adci[%u]", i);
> > +
> > + object_class_property_add_uint32_ptr(klass, adciprop,
> > + offsetof(NPCM7xxADCState, adci[i]),
> > + OBJ_PROP_FLAG_READWRITE);
> > + }
> > + object_class_property_add_uint32_ptr(klass, "vref",
> > + offsetof(NPCM7xxADCState, vref),
> > + OBJ_PROP_FLAG_WRITE);
>
> Are you sure this actually works ?
Never mind. I realize now that this depends on your previous
series that changes object_class_property_add_uint32_ptr
to actually have the useful/desirable "relative offset"
semantics.
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/1] hw/adc/npcm7xx_adc.c: convert NPCM7XX_ADC object props to class props
2026-07-03 14:32 ` [PATCH v3 1/1] hw/adc/npcm7xx_adc.c: convert NPCM7XX_ADC " Mark Cave-Ayland
2026-07-06 6:59 ` Philippe Mathieu-Daudé
2026-07-07 11:50 ` Daniel P. Berrangé
@ 2026-07-07 11:56 ` Daniel P. Berrangé
2 siblings, 0 replies; 6+ messages in thread
From: Daniel P. Berrangé @ 2026-07-07 11:56 UTC (permalink / raw)
To: Mark Cave-Ayland
Cc: kfting, wuhaotsh, alistair, peter.maydell, qemu-arm, qemu-devel
On Fri, Jul 03, 2026 at 03:32:17PM +0100, Mark Cave-Ayland wrote:
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> ---
> hw/adc/npcm7xx_adc.c | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-07-07 11:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-03 14:32 [PATCH v3 0/1] hw/adc: convert object props to class props Mark Cave-Ayland
2026-07-03 14:32 ` [PATCH v3 1/1] hw/adc/npcm7xx_adc.c: convert NPCM7XX_ADC " Mark Cave-Ayland
2026-07-06 6:59 ` Philippe Mathieu-Daudé
2026-07-07 11:50 ` Daniel P. Berrangé
2026-07-07 11:53 ` Daniel P. Berrangé
2026-07-07 11:56 ` Daniel P. Berrangé
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.