From: Jonathan Cameron <jic23@kernel.org>
To: Rodrigo Alencar via B4 Relay
<devnull+rodrigo.alencar.analog.com@kernel.org>
Cc: rodrigo.alencar@analog.com, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org,
David Lechner <dlechner@baylibre.com>,
Andy Shevchenko <andy@kernel.org>
Subject: Re: [PATCH RFC 4/5] iio: buffer: add struct iio_buffer_attr
Date: Sat, 21 Nov 2026 01:52:58 +0000 [thread overview]
Message-ID: <20261121015258.568572b1@jic23-hlaptop> (raw)
In-Reply-To: <20261120-iio-core-attr-review-v1-4-05b41f8133c2@analog.com>
On Fri, 20 Nov 2026 18:04:00 +0000
Rodrigo Alencar via B4 Relay <devnull+rodrigo.alencar.analog.com@kernel.org> wrote:
> From: Rodrigo Alencar <rodrigo.alencar@analog.com>
>
> Buffer attributes find their buffer through the buffer field of
> struct iio_dev_attr, which is unused by every other attribute.
>
> Add struct iio_buffer_attr, extending struct iio_chan_attr with the
> buffer the attribute belongs to, and use it both for the scan element
> attributes and for the buffer attributes wrapped by the buffer core.
> iio_attr_to_buffer() now resolves the buffer through it.
>
> Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
> ---
> drivers/iio/industrialio-buffer.c | 63 +++++++++++++++++++++++++--------------
> 1 file changed, 40 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> index 48fdaed6d703..af5c9ecd1b3f 100644
> --- a/drivers/iio/industrialio-buffer.c
> +++ b/drivers/iio/industrialio-buffer.c
> @@ -69,6 +69,22 @@ static const char * const iio_endian_prefix[] = {
> [IIO_LE] = "le",
> };
>
> +/**
> + * struct iio_buffer_attr - IIO buffer attribute
> + * @chan_attr: underlying IIO channel attribute (channel is NULL for buffer
> + * wide attributes)
> + * @buffer: the IIO buffer to which this attribute belongs to
> + */
> +struct iio_buffer_attr {
> + struct iio_chan_attr chan_attr;
> + struct iio_buffer *buffer;
> +};
> @@ -1526,25 +1543,25 @@ static struct attribute *iio_buffer_wrap_attr(struct iio_buffer *buffer,
> struct attribute *attr)
> {
> struct device_attribute *dattr = to_dev_attr(attr);
> - struct iio_chan_attr *chan_attr;
> + struct iio_buffer_attr *buf_attr;
> struct iio_dev_attr *iio_attr;
>
> - chan_attr = kzalloc_obj(*chan_attr);
> - if (!chan_attr)
> + buf_attr = kzalloc_obj(*buf_attr);
Maybe some free magic is appropriate here.
> + if (!buf_attr)
> return NULL;
>
> - iio_attr = &chan_attr->iio_attr;
> - iio_attr->buffer = buffer;
> + buf_attr->buffer = buffer;
> + iio_attr = &buf_attr->chan_attr.iio_attr;
> memcpy(&iio_attr->dev_attr, dattr, sizeof(iio_attr->dev_attr));
> iio_attr->dev_attr.attr.name = kstrdup_const(attr->name, GFP_KERNEL);
> if (!iio_attr->dev_attr.attr.name) {
> - kfree(chan_attr);
> + kfree(buf_attr);
> return NULL;
> }
>
> sysfs_attr_init(&iio_attr->dev_attr.attr);
>
> - list_add(&chan_attr->l, &buffer->buffer_attr_list);
> + list_add(&buf_attr->chan_attr.l, &buffer->buffer_attr_list);
>
> return &iio_attr->dev_attr.attr;
> }
>
next prev parent reply other threads:[~2026-11-21 1:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 18:03 [PATCH RFC 0/5] iio: split struct iio_dev_attr into typed core attributes Rodrigo Alencar via B4 Relay
2026-11-20 18:03 ` [PATCH RFC 1/5] iio: buffer: add iio_attr_to_buffer() helper Rodrigo Alencar via B4 Relay
2026-11-20 18:03 ` [PATCH RFC 2/5] iio: core: add struct iio_chan_attr and split attribute creation Rodrigo Alencar via B4 Relay
2026-11-21 1:25 ` Jonathan Cameron
2026-11-20 18:03 ` [PATCH RFC 3/5] iio: event: add struct iio_event_attr Rodrigo Alencar via B4 Relay
2026-11-20 18:04 ` [PATCH RFC 4/5] iio: buffer: add struct iio_buffer_attr Rodrigo Alencar via B4 Relay
2026-11-21 1:52 ` Jonathan Cameron [this message]
2026-11-20 18:04 ` [PATCH RFC 5/5] iio: sysfs: drop core-only fields from struct iio_dev_attr Rodrigo Alencar via B4 Relay
2026-11-21 1:36 ` Jonathan Cameron
2026-11-21 1:39 ` [PATCH RFC 0/5] iio: split struct iio_dev_attr into typed core attributes Jonathan Cameron
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=20261121015258.568572b1@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=devnull+rodrigo.alencar.analog.com@kernel.org \
--cc=dlechner@baylibre.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rodrigo.alencar@analog.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
all inboxes | Powered by JetHome®