Re: [PATCH v7 08/17] iio: core: add hierarchical channel relationships

Andy Shevchenko <[email protected]>
Newsgroups org.kernel.vger.linux-hardening,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-doc,org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel
Organization Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo
Message-ID <[email protected]>
On Tue, Jul 07, 2026 at 03:04:29PM +0100, Rodrigo Alencar via B4 Relay wrote:

> Add parent-child relationship between iio channels by creating a parent
> pointer field in iio_chan_spec struct and exposing a sysfs attribute that
> returns the parent channel prefix.

...

> +static ssize_t iio_read_channel_parent(struct device *dev,
> +				       struct device_attribute *attr,
> +				       char *buf)
> +{
> +	const struct iio_chan_spec *chan = to_iio_dev_attr(attr)->c->parent;
> +	ssize_t len;
> +
> +	len = __iio_chan_prefix_emit(dev, chan, IIO_SEPARATE, buf, PAGE_SIZE);
> +	if (len < 0)
> +		return len;
> +
> +	buf[len] = '\n';
> +
> +	return len + 1;

	buf[len++] = '\n';

	return len;

? To me this variant is more robust as we don't forget about \n in the len
count.

> +}

-- 
With Best Regards,
Andy Shevchenko
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.