Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Miles Glenn <milesg@linux.ibm.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>, qemu-devel@nongnu.org
Cc: "Markus Armbruster" <armbru@redhat.com>,
	"Michael Roth" <michael.roth@amd.com>,
	"John Snow" <jsnow@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Mauro Carvalho Chehab" <mchehab+huawei@kernel.org>,
	"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Kostiantyn Kostiuk" <kkostiuk@redhat.com>,
	"Eric Blake" <eblake@redhat.com>,
	"David Hildenbrand" <david@kernel.org>,
	"Igor Mammedov" <imammedo@redhat.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Jason Wang" <jasowangio@gmail.com>,
	"Marcelo Tosatti" <mtosatti@redhat.com>,
	kvm@vger.kernel.org, "Alberto Garcia" <berto@igalia.com>,
	"Kevin Wolf" <kwolf@redhat.com>,
	"Hanna Reitz" <hreitz@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
	"Zhao Liu" <zhao1.liu@intel.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Junjie Cao" <junjie.cao@intel.com>,
	"Anisa Su" <anisa.su@samsung.com>,
	"Elena Ufimtseva" <elena.ufimtseva@oracle.com>,
	"Jagannathan Raman" <jag.raman@oracle.com>,
	"John Levon" <john.levon@nutanix.com>,
	"Thanos Makatos" <thanos.makatos@nutanix.com>,
	"Cédric Le Goater" <clg@redhat.com>,
	"Cornelia Huck" <cohuck@redhat.com>,
	"Eric Farman" <farman@linux.ibm.com>,
	"Matthew Rosato" <mjrosato@linux.ibm.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Ilya Leoshkevich" <iii@linux.ibm.com>,
	qemu-block@nongnu.org, linux-cxl@vger.kernel.org,
	qemu-s390x@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
	"Sergio Lopez" <slp@redhat.com>,
	qemu-arm@nongnu.org, "Palmer Dabbelt" <palmer@dabbelt.com>,
	"Alistair Francis" <alistair.francis@wdc.com>,
	"Weiwei Li" <liwei1518@gmail.com>,
	"Daniel Henrique Barboza" <daniel.barboza@oss.qualcomm.com>,
	"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
	"Chao Liu" <chao.liu@processmission.com>,
	qemu-riscv@nongnu.org, "Song Gao" <17746591750@163.com>,
	"Bibo Mao" <maobibo@loongson.cn>,
	"Xianglai Li" <lixianglai@loongson.cn>,
	"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
	"Pedro Barbuda" <pbarbuda@microsoft.com>,
	"Mohamed Mediouni" <mohamed@unpredictable.fr>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
	"Amit Machhiwal" <amachhiw@linux.ibm.com>,
	qemu-ppc@nongnu.org, "Zhang Chen" <zhangckid@gmail.com>,
	"Li Zhijian" <lizhijian@fujitsu.com>,
	"Alistair Francis" <alistair@alistair23.me>,
	"Alexander Graf" <graf@amazon.com>,
	"Gonglei (Arei)" <arei.gonglei@huawei.com>,
	"zhenwei pi" <zhenwei.pi@linux.dev>,
	"Ani Sinha" <anisinha@redhat.com>, "Luc Michel" <luc@lmichel.fr>,
	"Cédric Le Goater" <clg@kaod.org>,
	"Jamin Lin" <jamin_lin@aspeedtech.com>,
	"Kane Chen" <kane_chen@aspeedtech.com>,
	"Samuel Tardieu" <sam@rfc1149.net>,
	"Denis V. Lunev" <den@openvz.org>,
	"FangSheng Huang" <FangSheng.Huang@amd.com>,
	"Tyrone Ting" <kfting@nuvoton.com>,
	"Hao Wu" <wuhaotsh@google.com>, "Keith Busch" <kbusch@kernel.org>,
	"Klaus Jensen" <its@irrelevant.dk>,
	"Jesper Devantier" <foss@defmacro.it>,
	"Aditya Gupta" <adityag@linux.ibm.com>,
	"Conor Dooley" <conor@kernel.org>,
	"Sebastian Huber" <sebastian.huber@embedded-brains.de>,
	"Halil Pasic" <pasic@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Jason Herne" <jjherne@linux.ibm.com>,
	"Titus Rwantare" <titusr@google.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Anthony PERARD" <anthony@xenproject.org>,
	"Peter Xu" <peterx@redhat.com>,
	"Chinmay Rath" <rathc@linux.ibm.com>,
	"Hendrik Brueckner" <brueckner@linux.ibm.com>,
	xen-devel@lists.xenproject.org,
	"Roman Bolshakov" <rbolshakov@ddn.com>,
	"Phil Dennis-Jordan" <phil@philjordan.eu>,
	"Fam Zheng" <fam@euphon.net>, "Farhan Ali" <alifm@linux.ibm.com>,
	"Alex Williamson" <alex@shazbot.org>,
	"Tao Tang" <tangtao1634@phytium.com.cn>,
	"Stefan Berger" <stefanb@linux.vnet.ibm.com>,
	"Fabiano Rosas" <farosas@suse.de>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Artyom Tarasenko" <atar4qemu@gmail.com>,
	"Yoshinori Sato" <yoshinori.sato@nifty.com>,
	"Jiri Pirko" <jiri@resnulli.us>,
	"Eric Auger" <eric.auger@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>
Subject: Re: [PATCH v7 50/65] hw/gpio/pca955x: convert pin/led property to QAPI-aware enum
Date: Tue, 20 Oct 2026 15:41:27 -0500	[thread overview]
Message-ID: <b71f57e2e611b24bed7c0db597cfa8acd4336460.camel@linux.ibm.com> (raw)
In-Reply-To: <20261020-qom-qapi-v7-50-431a86b02b58@redhat.com>

On Tue, 2026-10-20 at 14:46 +0400, Marc-André Lureau wrote:
> Replaces the runtime-parsed visitor-based QOM property accessors with
> compile-time per-pin/per-LED accessor functions using QEMU_REPEAT.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  hw/gpio/pca9552.c | 205 +++++++++++++++++++++---------------------------------
>  hw/gpio/pca9554.c | 136 ++++++++++++++----------------------
>  2 files changed, 131 insertions(+), 210 deletions(-)
> 
> diff --git a/hw/gpio/pca9552.c b/hw/gpio/pca9552.c
> index 16741c22dea3..0a007bbbe4ac 100644
> --- a/hw/gpio/pca9552.c
> +++ b/hw/gpio/pca9552.c
> @@ -25,6 +25,7 @@
>  #include "qapi/error.h"
>  #include "qapi/qapi-types-machine.h"
>  #include "qapi/qapi-visit-machine.h"

Do you still need to include qapi/qapi-visit-machine.h?

> +#include "qapi/qapi-type-infos-machine.h"
>  #include "trace.h"
>  #include "qom/object.h"
>  
> @@ -354,33 +355,6 @@ static int pca955x_event(I2CSlave *i2c, enum i2c_event event)
>      return 0;
>  }
>  
> -static void pca955x_get_led(Object *obj, Visitor *v, const char *name,
> -                            void *opaque, Error **errp)
> -{
> -    PCA955xClass *k = PCA955X_GET_CLASS(obj);
> -    PCA955xState *s = PCA955X(obj);
> -    int led, rc, reg;
> -    Pca9552LedState state;
> -
> -    rc = sscanf(name, "led%2d", &led);
> -    if (rc != 1) {
> -        error_setg(errp, "%s: error reading %s", __func__, name);
> -        return;
> -    }
> -    if (led < 0 || led >= k->pin_count) {
> -        error_setg(errp, "%s: invalid led %s", __func__, name);
> -        return;
> -    }
> -    /*
> -     * Get the LSx register as the qom interface should expose the device
> -     * state, not the modeled 'input line' behaviour which would come from
> -     * reading the INPUTx reg
> -     */
> -    reg = PCA9552_LS0 + led / 4;
> -    state = (pca955x_read(s, reg) >> ((led % 4) * 2)) & 0x3;
> -    visit_type_Pca9552LedState(v, name, &state, errp);
> -}
> -
>  /*
>   * Return an LED selector register value based on an existing one, with
>   * the appropriate 2-bit state value set for the given LED number (0-3).
> @@ -391,97 +365,8 @@ static inline uint8_t pca955x_ledsel(uint8_t oldval, int led_num, int state)
>                  ((state & 0x3) << (led_num << 1));
>  }
>  
> -static void pca955x_set_led(Object *obj, Visitor *v, const char *name,
> -                            void *opaque, Error **errp)
> -{
> -    PCA955xClass *k = PCA955X_GET_CLASS(obj);
> -    PCA955xState *s = PCA955X(obj);
> -    int led, rc, reg, val;
> -    Pca9552LedState state;
> -
> -    if (!visit_type_Pca9552LedState(v, name, &state, errp)) {
> -        return;
> -    }
> -    rc = sscanf(name, "led%2d", &led);
> -    if (rc != 1) {
> -        error_setg(errp, "%s: error reading %s", __func__, name);
> -        return;
> -    }
> -    if (led < 0 || led >= k->pin_count) {
> -        error_setg(errp, "%s: invalid led %s", __func__, name);
> -        return;
> -    }
> -
> -    reg = PCA9552_LS0 + led / 4;
> -    val = pca955x_read(s, reg);
> -    val = pca955x_ledsel(val, led % 4, state);
> -    pca955x_write(s, reg, val);
> -}
> -
>  static void pca955x_set_ext_state(PCA955xState *s, int pin, int level);
>  
> -static void pca955x_get_pin(Object *obj, Visitor *v, const char *name,
> -                            void *opaque, Error **errp)
> -{
> -    PCA955xClass *k = PCA955X_GET_CLASS(obj);
> -    PCA955xState *s = PCA955X(obj);
> -    int pin, rc;
> -    uint8_t input_reg;
> -    Pca9552PinState state;
> -
> -    rc = sscanf(name, "pin%2d", &pin);
> -    if (rc != 1) {
> -        error_setg(errp, "%s: error reading %s", __func__, name);
> -        return;
> -    }
> -    if (pin < 0 || pin >= k->pin_count) {
> -        error_setg(errp, "%s invalid pin %s", __func__, name);
> -        return;
> -    }
> -
> -    /*
> -     * Report the raw pin logic level; polarity inversion is a read-time
> -     * transform applied to the INPUT register, not to the pin state itself.
> -     */
> -    input_reg = PCA9535_INPUT0 + (pin / 8);
> -    state = (s->regs[input_reg] >> (pin % 8)) & 0x1;
> -    visit_type_Pca9552PinState(v, name, &state, errp);
> -}
> -
> -static void pca955x_set_pin(Object *obj, Visitor *v, const char *name,
> -                            void *opaque, Error **errp)
> -{
> -    PCA955xClass *k = PCA955X_GET_CLASS(obj);
> -    PCA955xState *s = PCA955X(obj);
> -    int pin, rc;
> -    Pca9552PinState state;
> -    uint8_t config_reg;
> -
> -    if (!visit_type_Pca9552PinState(v, name, &state, errp)) {
> -        return;
> -    }
> -    rc = sscanf(name, "pin%2d", &pin);
> -    if (rc != 1) {
> -        error_setg(errp, "%s: error reading %s", __func__, name);
> -        return;
> -    }
> -    if (pin < 0 || pin >= k->pin_count) {
> -        error_setg(errp, "%s invalid pin %s", __func__, name);
> -        return;
> -    }
> -
> -    /* Only input-configured pins can be driven by an external device. */
> -    config_reg = PCA9535_CONFIG0 + (pin / 8);
> -    if (!((s->regs[config_reg] >> (pin % 8)) & 0x1)) {
> -        qemu_log_mask(LOG_UNIMP,
> -                      "%s: pin %d is configured as output, ignoring set\n",
> -                      s->description, pin);
> -        return;
> -    }
> -
> -    pca955x_set_ext_state(s, pin, state != PCA9552_PIN_STATE_LOW);
> -}
> -
>  static const VMStateDescription pca9552_vmstate = {
>      .name = "PCA9552",
>      .version_id = 0,
> @@ -536,26 +421,92 @@ static void pca9535_reset_hold(Object *obj, ResetType type)
>      s->len = 0;
>  }
>  
> +/*
> + * Get the LSx register as the qom interface should expose the device
> + * state, not the modeled 'input line' behaviour which would come from
> + * reading the INPUTx reg
> + */
> +#define DEFINE_LED_ACCESSORS(n)                                              \
> +static int prop_get_led##n(Object *obj, Error **errp)                        \
> +{                                                                            \
> +    PCA955xState *s = PCA955X(obj);                                          \
> +    uint8_t reg = PCA9552_LS0 + (n) / 4;                                     \
> +    return (pca955x_read(s, reg) >> (((n) % 4) * 2)) & 0x3;                  \
> +}                                                                            \
> +static void prop_set_led##n(Object *obj, int val, Error **errp)              \
> +{                                                                            \
> +    PCA955xState *s = PCA955X(obj);                                          \
> +    uint8_t reg = PCA9552_LS0 + (n) / 4;                                     \
> +    uint8_t old = pca955x_read(s, reg);                                      \
> +    pca955x_write(s, reg, pca955x_ledsel(old, (n) % 4, val));                \
> +}
> +
> +QEMU_REPEAT(PCA955X_PIN_COUNT_MAX, DEFINE_LED_ACCESSORS)
> +
> +#define LED_ENUM_PROP(n) {                                              \
> +    .name = "led" #n,                                                   \
> +    .default_value = -1,                                                \
> +    .qapi_type = &Pca9552LedState_type_info,                            \
> +    .get = prop_get_led##n,                                             \
> +    .set = prop_set_led##n,                                             \
> +},
> +
> +static const QapiEnumProp led_enum_props[] = {
> +    QEMU_REPEAT(PCA955X_PIN_COUNT_MAX, LED_ENUM_PROP)
> +};
> +
> +/*
> + * Report the raw pin logic level; polarity inversion is a read-time
> + * transform applied to the INPUT register, not to the pin state
> + * itself.
> + */
> +#define DEFINE_PIN_ACCESSORS(n)                                              \
> +static int prop_get_pin##n(Object *obj, Error **errp)                        \
> +{                                                                            \
> +    PCA955xState *s = PCA955X(obj);                                          \
> +    uint8_t input_reg = PCA9535_INPUT0 + (n) / 8;                            \
> +    return (s->regs[input_reg] >> ((n) % 8)) & 0x1;                          \
> +}                                                                            \
> +static void prop_set_pin##n(Object *obj, int val, Error **errp)              \
> +{                                                                            \
> +    PCA955xState *s = PCA955X(obj);                                          \
> +    uint8_t config_reg = PCA9535_CONFIG0 + (n) / 8;                          \
> +    /* Only input-configured pins can be driven by an external device */     \
> +    if (!((s->regs[config_reg] >> ((n) % 8)) & 0x1)) {                       \
> +        qemu_log_mask(LOG_UNIMP,                                             \
> +                      "%s: pin %d configured as output, ignoring set\n",     \
> +                      s->description, (n));                                  \
> +        return;                                                              \
> +    }                                                                        \
> +    pca955x_set_ext_state(s, (n), val != PCA9552_PIN_STATE_LOW);             \
> +}
> +
> +QEMU_REPEAT(PCA955X_PIN_COUNT_MAX, DEFINE_PIN_ACCESSORS)
> +
> +#define PIN_ENUM_PROP(n) {                                              \
> +    .name = "pin" #n,                                                   \
> +    .default_value = -1,                                                \
> +    .qapi_type = &Pca9552PinState_type_info,                            \
> +    .get = prop_get_pin##n,                                             \
> +    .set = prop_set_pin##n,                                             \
> +},
> +
> +static const QapiEnumProp pin_enum_props[] = {
> +    QEMU_REPEAT(PCA955X_PIN_COUNT_MAX, PIN_ENUM_PROP)
> +};
> +
>  static void pca955x_initfn(Object *obj)
>  {
>      PCA955xClass *k = PCA955X_GET_CLASS(obj);
>  
>      assert(k->pin_count <= PCA955X_PIN_COUNT_MAX);
> +    /* TODO: use array/list instead of individual QAPI enum properties */
>      for (int ix = 0; ix < k->pin_count; ix++) {
> -        char *name;
> -
>          if (k->has_led_support) {
> -            /* LED variant: expose the LED selector state as led%d. */
> -            name = g_strdup_printf("led%d", ix);
> -            object_property_add(obj, name, "Pca9552LedState",
> -                                pca955x_get_led, pca955x_set_led, NULL, NULL);
> +            object_property_add_qapi_enum(obj, &led_enum_props[ix]);
>          } else {
> -            /* GPIO variant: expose the pin logic level as pin%d. */
> -            name = g_strdup_printf("pin%d", ix);
> -            object_property_add(obj, name, "Pca9552PinState",
> -                                pca955x_get_pin, pca955x_set_pin, NULL, NULL);
> +            object_property_add_qapi_enum(obj, &pin_enum_props[ix]);
>          }
> -        g_free(name);
>      }
>  }
>  
> diff --git a/hw/gpio/pca9554.c b/hw/gpio/pca9554.c
> index e4eddc829ef7..f2a5b94a36d8 100644
> --- a/hw/gpio/pca9554.c
> +++ b/hw/gpio/pca9554.c
> @@ -18,7 +18,7 @@
>  #include "qapi/error.h"
>  #include "qapi/qapi-types-machine.h"
>  #include "qapi/qapi-visit-machine.h"

Do you still need qapi/qapi-visit-machine.h?


> -#include "qapi/visitor.h"
> +#include "qapi/qapi-type-infos-machine.h"
>  #include "trace.h"
>  #include "qom/object.h"
>  
> @@ -151,83 +151,60 @@ static void pca9554_set_ext_state(PCA9554State *s, int pin, int level)
>      }
>  }
>  
> -static void pca9554_get_pin(Object *obj, Visitor *v, const char *name,
> -                            void *opaque, Error **errp)
> -{
> -    PCA9554State *s = PCA9554(obj);
> -    int pin, rc;
> -    Pca9554PinState state;
> -
> -    rc = sscanf(name, "pin%2d", &pin);
> -    if (rc != 1) {
> -        error_setg(errp, "%s: error reading %s", __func__, name);
> -        return;
> -    }
> -    if (pin < 0 || pin >= PCA9554_GET_CLASS(s)->pin_count) {
> -        error_setg(errp, "%s invalid pin %s", __func__, name);
> -        return;
> -    }
> -
> -    /*
> -     * Report the physical pin level. The input register is kept in sync by
> -     * pca9554_update_pin_input(): output pins mirror the OUTPUT register and
> -     * input pins reflect the externally driven (or pulled-up) level, so it
> -     * holds the wire level regardless of the configured direction.
> -     */
> -    state = (s->regs[PCA9554_INPUT] >> pin) & 0x1;
> -    visit_type_Pca9554PinState(v, name, &state, errp);
> +/*
> + * Report the physical pin level. The input register is kept in sync
> + * by pca9554_update_pin_input(): output pins mirror the OUTPUT
> + * register and input pins reflect the externally driven (or
> + * pulled-up) level, so it holds the wire level regardless of the
> + * configured direction.
> + */
> +#define DEFINE_PIN_ACCESSORS(n)                                              \
> +static int prop_get_pin##n(Object *obj, Error **errp)                        \
> +{                                                                            \
> +    PCA9554State *s = PCA9554(obj);                                          \
> +    return (s->regs[PCA9554_INPUT] >> (n)) & 0x1;                            \
> +}                                                                            \
> +static void prop_set_pin##n(Object *obj, int val, Error **errp)              \
> +{                                                                            \
> +    PCA9554State *s = PCA9554(obj);                                          \
> +    if (s->hw_dir) {                                                         \
> +        if (!((s->regs[PCA9554_CONFIG] >> (n)) & 0x1)) {                     \
> +            qemu_log_mask(LOG_UNIMP,                                         \
> +                          "%s: pin %d configured as output,"                 \
> +                          " ignoring set\n",                                 \
> +                          s->description, (n));                              \
> +            return;                                                          \
> +        }                                                                    \
> +        pca9554_set_ext_state(s, (n), val != PCA9554_PIN_STATE_LOW);         \
> +    } else {                                                                 \
> +        /* Legacy behavior: force output mode and drive */                   \
> +        uint8_t mask = 0x1 << (n);                                           \
> +        int v = pca9554_read(s, PCA9554_OUTPUT);                             \
> +        if (val == PCA9554_PIN_STATE_LOW) {                                  \
> +            v &= ~mask;                                                      \
> +        } else {                                                             \
> +            v |= mask;                                                       \
> +        }                                                                    \
> +        pca9554_write(s, PCA9554_OUTPUT, v);                                 \
> +        v = pca9554_read(s, PCA9554_CONFIG);                                 \
> +        v &= ~mask;                                                          \
> +        pca9554_write(s, PCA9554_CONFIG, v);                                 \
> +    }                                                                        \
>  }
>  
> -static void pca9554_set_pin(Object *obj, Visitor *v, const char *name,
> -                            void *opaque, Error **errp)
> -{
> -    PCA9554State *s = PCA9554(obj);
> -    int pin, rc, val;
> -    uint8_t mask;
> -    Pca9554PinState state;
> +QEMU_REPEAT(PCA9554_PIN_COUNT, DEFINE_PIN_ACCESSORS)
>  
> -    if (!visit_type_Pca9554PinState(v, name, &state, errp)) {
> -        return;
> -    }
> -    rc = sscanf(name, "pin%2d", &pin);
> -    if (rc != 1) {
> -        error_setg(errp, "%s: error reading %s", __func__, name);
> -        return;
> -    }
> -    if (pin < 0 || pin >= PCA9554_GET_CLASS(s)->pin_count) {
> -        error_setg(errp, "%s invalid pin %s", __func__, name);
> -        return;
> -    }
> +#define PIN_ENUM_PROP(n) {                                              \
> +    .name = "pin" #n,                                                   \
> +    .default_value = -1,                                                \
> +    .qapi_type = &Pca9554PinState_type_info,                            \
> +    .get = prop_get_pin##n,                                             \
> +    .set = prop_set_pin##n,                                             \
> +},
>  
> -    if (s->hw_dir) {
> -        /* Warn and ignore if the guest has configured this pin as output */
> -        if (!((s->regs[PCA9554_CONFIG] >> pin) & 0x1)) {
> -            qemu_log_mask(LOG_UNIMP,
> -                          "%s: pin %d is configured as output, "
> -                          "ignoring external set\n",
> -                          s->description, pin);
> -            return;
> -        }
> -        /* Drive the external input level */
> -        pca9554_set_ext_state(s, pin, state != PCA9554_PIN_STATE_LOW);
> -    } else {
> -        /* Legacy behavior: force output mode and drive */
> -        /* First, modify the output register bit */
> -        val = pca9554_read(s, PCA9554_OUTPUT);
> -        mask = 0x1 << pin;
> -        if (state == PCA9554_PIN_STATE_LOW) {
> -            val &= ~(mask);
> -        } else {
> -            val |= mask;
> -        }
> -        pca9554_write(s, PCA9554_OUTPUT, val);
> -
> -        /* Then, clear the config register bit for output mode */
> -        val = pca9554_read(s, PCA9554_CONFIG);
> -        val &= ~mask;
> -        pca9554_write(s, PCA9554_CONFIG, val);
> -    }
> -}
> +static const QapiEnumProp pin_enum_props[] = {
> +    QEMU_REPEAT(PCA9554_PIN_COUNT, PIN_ENUM_PROP)
> +};
>  
>  static const VMStateDescription pca9554_vmstate = {
>      .name = "PCA9554",
> @@ -264,16 +241,9 @@ static void pca9554_reset(DeviceState *dev)
>  static void pca9554_initfn(Object *obj)
>  {
>      PCA9554Class *pc = PCA9554_GET_CLASS(obj);
> -    int pin;
>  
> -    for (pin = 0; pin < pc->pin_count; pin++) {
> -        char *name;
> -
> -        name = g_strdup_printf("pin%d", pin);
> -        object_property_add(obj, name, "Pca9554PinState",
> -                            pca9554_get_pin, pca9554_set_pin,
> -                            NULL, NULL);
> -        g_free(name);

Should we have the same TODO comment here as with the 9552 code?

Thanks,

Glenn

> +    for (int pin = 0; pin < pc->pin_count; pin++) {
> +        object_property_add_qapi_enum(obj, &pin_enum_props[pin]);
>      }
>  }
>  
> 


  reply	other threads:[~2026-10-20 20:42 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 10:45 [PATCH v7 00/65] Hi marcandre.lureau
2026-10-20 10:45 ` [PATCH v7 01/65] qapi/schema: Rename .lookup_entity() and tighten return type marcandre.lureau
2026-10-20 10:45 ` [PATCH v7 02/65] qapi: Ease access to introspection names marcandre.lureau
2026-10-20 10:45 ` [PATCH v7 03/65] qapi/introspect: Simplify masked name comment emission slighly marcandre.lureau
2026-10-20 10:45 ` [PATCH v7 04/65] qapi/introspect: Don't elide types marcandre.lureau
2026-10-20 10:45 ` [PATCH v7 05/65] qapi: QAPISchemaVisitor.visit_needed() is now unused, drop marcandre.lureau
2026-10-20 10:45 ` [PATCH v7 06/65] qapi/introspect: Tweak integer type masking marcandre.lureau
2026-10-20 10:45 ` [PATCH v7 07/65] qapi: add QAPITypeInfo struct definition Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 08/65] qapi/gen: fix _module_basename for multi-dash 'what' parameters Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 09/65] qapi: add type-infos generator Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 10/65] meson: add qapi-type-infos-*.c/h to build Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 11/65] qom: add qapi_type field to ObjectProperty Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 12/65] qapi/qom: add qapi-type field to ObjectPropertyInfo Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 13/65] qom/qmp: populate qapi-type in QMP handlers Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 14/65] qom/qmp: populate description & default-value in qom_property_info() Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 15/65] qom: add object_property_set_default_enum() Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 16/65] qom: add object_{class_}property_add_qapi Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 17/65] qom: add object_{class_}property_add_qapi_enum Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 18/65] tests: update check-qom-proplist for QAPI-aware property registration Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 19/65] qom: convert QAPI enum properties to QAPI-aware registration Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 20/65] qom: convert struct " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 21/65] x86: convert OnOffAuto " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 22/65] microvm: " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 23/65] pc: convert OnOffAuto vmport property " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 24/65] arm/virt: convert OnOffAuto acpi " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 25/65] riscv/virt: convert OnOffAuto properties " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 26/65] loongarch/virt: " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 27/65] hostmem-file: convert OnOffAuto rom property " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 28/65] sev: convert OnOffAuto legacy-vm-type " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 29/65] whpx: convert OnOffAuto hyperv " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 30/65] whpx: convert OnOffAuto arch properties " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 31/65] accel/kvm: convert OnOffSplit property " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 32/65] whpx: " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 33/65] hw/ppc/spapr_caps: fix property type name Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 34/65] ppc/spapr-caps: convert to QAPI-aware property registration Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 35/65] net/colo-compare: fix compare_timeout setter visitor type Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 36/65] net/colo-compare: fix max_queue_size " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 37/65] hw/misc/xlnx-versal-trng: add missing getter for fips-fault-events Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 38/65] qom: convert scalar properties to QAPI-aware registration Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 39/65] i386/cpu: convert strList property " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 40/65] accel/hvf: convert OnOffSplit " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 41/65] i386/x86: convert SgxEPCList " Marc-André Lureau
2026-10-20 10:45 ` [PATCH v7 42/65] virtio-balloon: convert guest-stats property to QAPI type Marc-André Lureau
2026-10-20 12:59   ` Markus Armbruster
2026-10-20 10:46 ` [PATCH v7 43/65] qom: replace object_property_add_tm with StructTm " Marc-André Lureau
2026-10-20 13:25   ` Markus Armbruster
2026-10-20 10:46 ` [PATCH v7 44/65] hw/nvdimm: convert UUID property to QAPI-aware registration Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 45/65] hw/s390-virtio-ccw: convert loadparm " Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 46/65] hw/ppc/spapr_drc: convert fdt " Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 47/65] hw/s390x: convert BootCertificatesList " Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 48/65] hw/gpio/pca955x: use QAPI enums for led and pin properties Marc-André Lureau
2026-10-20 20:28   ` Miles Glenn
2026-10-20 10:46 ` [PATCH v7 49/65] include: add QEMU_REPEAT helper macro Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 50/65] hw/gpio/pca955x: convert pin/led property to QAPI-aware enum Marc-André Lureau
2026-10-20 20:41   ` Miles Glenn [this message]
2026-10-20 10:46 ` [PATCH v7 51/65] hw/pci: change the busnr type to uint8 Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 52/65] qdev: add qapi_type field to PropertyInfo with fallback registration Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 53/65] qdev: convert core PropertyInfo definitions to use qapi_type Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 54/65] qdev: adjust PciDevfn declared type Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 55/65] qdev: convert system PropertyInfo definitions to use qapi_type Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 56/65] hw: convert device-local " Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 57/65] target/riscv: convert " Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 58/65] qdev: " Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 59/65] qdev: introduce typed array PropertyInfos Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 60/65] qdev: simplify DEFINE_PROP_ARRAY and remove generic array PropertyInfo Marc-André Lureau
2026-10-21 14:45   ` Markus Armbruster
2026-10-20 10:46 ` [PATCH v7 61/65] qdev: remove deprecated PropertyInfo.type and .enum_table fields Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 62/65] hw/i386: convert PCSouthBridgeOption to QAPI enum Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 63/65] qom: remove old enum property registration API Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 64/65] qom: use QAPITypeInfo in object_property_get_enum Marc-André Lureau
2026-10-20 10:46 ` [PATCH v7 65/65] tests/qmp-cmd-test: assert qapi-type resolves in query-qmp-schema Marc-André Lureau
2026-10-21 16:29 ` Property types changed in this series (was: [PATCH v7 00/65] Hi) Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b71f57e2e611b24bed7c0db597cfa8acd4336460.camel@linux.ibm.com \
    --to=milesg@linux.ibm.com \
    --cc=17746591750@163.com \
    --cc=FangSheng.Huang@amd.com \
    --cc=adityag@linux.ibm.com \
    --cc=alex@shazbot.org \
    --cc=alifm@linux.ibm.com \
    --cc=alistair.francis@wdc.com \
    --cc=alistair@alistair23.me \
    --cc=amachhiw@linux.ibm.com \
    --cc=anisa.su@samsung.com \
    --cc=anisinha@redhat.com \
    --cc=anthony@xenproject.org \
    --cc=arei.gonglei@huawei.com \
    --cc=armbru@redhat.com \
    --cc=atar4qemu@gmail.com \
    --cc=berrange@redhat.com \
    --cc=berto@igalia.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=brueckner@linux.ibm.com \
    --cc=chao.liu@processmission.com \
    --cc=clg@kaod.org \
    --cc=clg@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=conor@kernel.org \
    --cc=daniel.barboza@oss.qualcomm.com \
    --cc=david@kernel.org \
    --cc=den@openvz.org \
    --cc=eblake@redhat.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=elena.ufimtseva@oracle.com \
    --cc=eric.auger@redhat.com \
    --cc=fam@euphon.net \
    --cc=farman@linux.ibm.com \
    --cc=farosas@suse.de \
    --cc=foss@defmacro.it \
    --cc=graf@amazon.com \
    --cc=harshpb@linux.ibm.com \
    --cc=hreitz@redhat.com \
    --cc=iii@linux.ibm.com \
    --cc=imammedo@redhat.com \
    --cc=its@irrelevant.dk \
    --cc=jag.raman@oracle.com \
    --cc=jamin_lin@aspeedtech.com \
    --cc=jasowangio@gmail.com \
    --cc=jiaxun.yang@flygoat.com \
    --cc=jic23@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=jjherne@linux.ibm.com \
    --cc=john.levon@nutanix.com \
    --cc=jsnow@redhat.com \
    --cc=junjie.cao@intel.com \
    --cc=kane_chen@aspeedtech.com \
    --cc=kbusch@kernel.org \
    --cc=kfting@nuvoton.com \
    --cc=kkostiuk@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kwolf@redhat.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=liwei1518@gmail.com \
    --cc=lixianglai@loongson.cn \
    --cc=lizhijian@fujitsu.com \
    --cc=luc@lmichel.fr \
    --cc=lvivier@redhat.com \
    --cc=maobibo@loongson.cn \
    --cc=marcandre.lureau@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=mchehab+huawei@kernel.org \
    --cc=michael.roth@amd.com \
    --cc=mjrosato@linux.ibm.com \
    --cc=mohamed@unpredictable.fr \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=npiggin@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=pasic@linux.ibm.com \
    --cc=pbarbuda@microsoft.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=peterx@redhat.com \
    --cc=phil@philjordan.eu \
    --cc=philmd@oss.qualcomm.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=rathc@linux.ibm.com \
    --cc=rbolshakov@ddn.com \
    --cc=richard.henderson@linaro.org \
    --cc=sam@rfc1149.net \
    --cc=sebastian.huber@embedded-brains.de \
    --cc=slp@redhat.com \
    --cc=sstabellini@kernel.org \
    --cc=stefanb@linux.vnet.ibm.com \
    --cc=tangtao1634@phytium.com.cn \
    --cc=thanos.makatos@nutanix.com \
    --cc=titusr@google.com \
    --cc=wuhaotsh@google.com \
    --cc=xen-devel@lists.xenproject.org \
    --cc=yoshinori.sato@nifty.com \
    --cc=zhangckid@gmail.com \
    --cc=zhao1.liu@intel.com \
    --cc=zhenwei.pi@linux.dev \
    --cc=zhiwei_liu@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox