qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 4/8] hw/misc/pca9552: Add a 'description' property for deb


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v4 4/8] hw/misc/pca9552: Add a 'description' property for debugging purpose
Date: Mon, 22 Jun 2020 10:31:24 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0

On 6/22/20 8:27 AM, Cédric Le Goater wrote:
> 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 <clg@kaod.org>
> 
> Could it be a QOM attribute ? 

What do you call a 'QOM attribute'?
Is it what qdev properties implement?
(in this case via DEFINE_PROP_STRING).

> 
> C.
> 
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@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 = {
>>
> 
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]