On 6/21/20 12:58 AM, Philippe Mathieu-Daudé wrote: > Add a description field to distinguish between multiple devices.
Reviewed-by: Cédric Le Goater <c...@kaod.org> Could it be a QOM attribute ? C. > Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> > --- > include/hw/misc/pca9552.h | 1 + > hw/misc/pca9552.c | 10 ++++++++++ > 2 files changed, 11 insertions(+) > > diff --git a/include/hw/misc/pca9552.h b/include/hw/misc/pca9552.h > index ef6da4988f..c5be7f1c5e 100644 > --- a/include/hw/misc/pca9552.h > +++ b/include/hw/misc/pca9552.h > @@ -27,6 +27,7 @@ typedef struct PCA9552State { > > uint8_t regs[PCA9552_NR_REGS]; > uint8_t max_reg; > + char *description; /* For debugging purpose only */ > uint8_t nr_leds; > } PCA9552State; > > diff --git a/hw/misc/pca9552.c b/hw/misc/pca9552.c > index b97fc2893c..54ccdcf6d4 100644 > --- a/hw/misc/pca9552.c > +++ b/hw/misc/pca9552.c > @@ -12,6 +12,7 @@ > #include "qemu/osdep.h" > #include "qemu/log.h" > #include "qemu/module.h" > +#include "hw/qdev-properties.h" > #include "hw/misc/pca9552.h" > #include "hw/misc/pca9552_regs.h" > #include "migration/vmstate.h" > @@ -312,8 +313,16 @@ static void pca9552_realize(DeviceState *dev, Error > **errp) > __func__, s->nr_leds, PCA9552_PIN_COUNT); > return; > } > + if (!s->description) { > + s->description = g_strdup("pca-unspecified"); > + } > } > > +static Property pca9552_properties[] = { > + DEFINE_PROP_STRING("description", PCA9552State, description), > + DEFINE_PROP_END_OF_LIST(), > +}; > + > static void pca9552_class_init(ObjectClass *klass, void *data) > { > DeviceClass *dc = DEVICE_CLASS(klass); > @@ -325,6 +334,7 @@ static void pca9552_class_init(ObjectClass *klass, void > *data) > dc->realize = pca9552_realize; > dc->reset = pca9552_reset; > dc->vmsd = &pca9552_vmstate; > + device_class_set_props(dc, pca9552_properties); > } > > static const TypeInfo pca9552_info = { >