Re: [PATCH v2 0/5] iio: split struct iio_dev_attr into typed core attributes
From: Jonathan Cameron
Date: Fri Nov 27 2026 - 20:10:29 EST
On Fri, 27 Nov 2026 09:47:43 +0000
Rodrigo Alencar via B4 Relay <devnull+rodrigo.alencar.analog.com@xxxxxxxxxx> wrote:
> struct iio_dev_attr does three unrelated jobs: it backs the static
> attributes declared by drivers through IIO_DEVICE_ATTR*(), the channel
> and event attributes generated by the IIO core, and the per-buffer
> attributes. Every user carries every field (l, c, buffer), whether it
> needs them or not, and the meaning of @address depends on the context:
> an info mask bit, an ext_info index, a scan index or, for events, the
> event_spec index and the event info packed together.
>
> This series keeps struct iio_dev_attr as what drivers use (dev_attr and
> address) and moves the core-only state into private types embedding it:
>
> struct iio_chan_attr - core channel attributes (channel, list node)
> struct iio_event_attr - extends it with the event spec
> struct iio_buffer_attr - extends it with the owning buffer
>
> Attribute creation is split into iio_chan_attr_prepare(), which builds
> the full name and runs the duplicate check, and iio_chan_attr_add(),
> which initializes an attribute allocated by the caller. Each context
> allocates its own type and sets its own fields, so the core needs no
> size, offset or context pointer.
Nice. All looks good to me, but as it is a core change I'll let
it sit for a little while before applying so others can take a good look.
Jonathan