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



Reply via email to