From: Markus Armbruster <armbru@redhat.com>
To: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Cc: qemu-devel@nongnu.org, marcandre.lureau@redhat.com,
milesg@linux.ibm.com, qemu-ppc@nongnu.org, qemu-arm@nongnu.org
Subject: Re: [PATCH 8/8] hw/gpio/pca955x: Simplify pin and led getters and setters
Date: Mon, 09 Nov 2026 11:19:53 +0100 [thread overview]
Message-ID: <871p8u71di.fsf@pond.sub.org> (raw)
In-Reply-To: <291007a5-c42c-4efd-b4ef-3d11924c3944@nutanix.com> (Mark Cave-Ayland's message of "Mon, 9 Nov 2026 09:09:05 +0000")
Mark Cave-Ayland <mark.caveayland@nutanix.com> writes:
> On 06/11/2026 11:04, Markus Armbruster wrote:
>
>> Pass the index via object_class_property_add() parameter @opaque
>> instead extracting it from the property name.
>>
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
[...]
> Interesting. I think I had a similar issue trying to get the index of a
> gpio when converting one of the hw/adc devices. No objection here, but
> we should try and be consistent about how we obtain the index in these
> cases as I can see this coming up frequently.
Yes, consistency is desirable.
Permit me a digression.
QOM is designed to be maximally flexible, at the cost of extra
boilerplate. It also enables different solutions to similar problems.
Consider properties. Property accessors get passed the object and a
void *opaque. Maximally flexible: the object is necessary, and @opaque
can be anything. In practice, this pushes you towards writing one
bespoke getter/setter pair per property, ignoring @opaque.
When that becomes too cumbersome, people use @opaque however they see
fit. For instance, the object_property_add_T_ptr() convenience
functions use it to pass a member offset. But @opaque can be anything,
and this lets people get creative.
Qdev is different: accessors get passed a property descriptor (struct
Property), which (among other things) includes an @offset. This pushes
you towards writing a single getter/setter pair per kind of property,
using @offset to access the object memory backing the property. Less
flexible, less freedom, less boilerplate, more consistency.
Since qdev was rebased onto QOM, it uses @opaque to pass the property
descriptor through QOM to qdev accessors.
End of digression.
We should use @opaque for its intended purpose: pass whatever additional
information the getter/setter needs. We should not abuse the property
name to pass such information.
object_class_property_add_enum() doesn't support @opaque. Maybe it
should.
We don't have an object_class_property_add_enum_ptr(). Maybe we should.
prev parent reply other threads:[~2026-11-09 10:20 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 11:04 [PATCH 0/8] hw/gpio/pca955x: Improvements around props "pin" and "led" Markus Armbruster
2026-11-06 11:04 ` [PATCH 1/8] hw/gpio/pca9552: Convert pin and led properties to class properties Markus Armbruster
2026-11-06 20:17 ` Miles Glenn
2026-11-09 8:51 ` Mark Cave-Ayland
2026-11-06 11:04 ` [PATCH 2/8] hw/gpio/pca9554: Move most code from .h to .c Markus Armbruster
2026-11-06 20:18 ` Miles Glenn
2026-11-09 8:55 ` Mark Cave-Ayland
2026-11-09 9:40 ` Markus Armbruster
2026-11-06 11:04 ` [PATCH 3/8] hw/gpio/pca9554: Simplify QOM type creation Markus Armbruster
2026-11-06 20:19 ` Miles Glenn
2026-11-09 8:56 ` Mark Cave-Ayland
2026-11-06 11:04 ` [PATCH 4/8] hw/gpio/pca9554: New abstract base "pca9554-base" Markus Armbruster
2026-11-06 20:19 ` Miles Glenn
2026-11-09 9:02 ` Mark Cave-Ayland
2026-11-09 10:17 ` Mark Cave-Ayland
2026-11-09 11:56 ` Markus Armbruster
2026-11-09 14:20 ` Mark Cave-Ayland
2026-11-09 14:44 ` Markus Armbruster
2026-11-09 10:24 ` Markus Armbruster
2026-11-09 13:52 ` BALATON Zoltan
2026-11-09 14:17 ` Markus Armbruster
2026-11-06 11:04 ` [PATCH 5/8] hw/gpio/pca9554: Convert pin properties to class properties Markus Armbruster
2026-11-06 20:20 ` Miles Glenn
2026-11-09 9:03 ` Mark Cave-Ayland
2026-11-06 11:04 ` [PATCH 6/8] hw/gpio/pca955x: use QAPI enums for led and pin properties Markus Armbruster
2026-11-06 20:20 ` Miles Glenn
2026-11-09 9:05 ` Mark Cave-Ayland
2026-11-09 10:20 ` Markus Armbruster
2026-11-06 11:04 ` [PATCH 7/8] hw/gpio/pca955x: Improve @qapi-type reported by qom-list etc Markus Armbruster
2026-11-06 20:21 ` Miles Glenn
2026-11-09 9:06 ` Mark Cave-Ayland
2026-11-06 11:04 ` [PATCH 8/8] hw/gpio/pca955x: Simplify pin and led getters and setters Markus Armbruster
2026-11-06 20:21 ` Miles Glenn
2026-11-09 9:09 ` Mark Cave-Ayland
2026-11-09 10:19 ` Markus Armbruster [this message]
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=871p8u71di.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mark.caveayland@nutanix.com \
--cc=milesg@linux.ibm.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/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 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.