OSDN Git Service

iio: buffer: wrap all buffer attributes into iio_dev_attr
authorAlexandru Ardelean <alexandru.ardelean@analog.com>
Mon, 15 Feb 2021 10:40:33 +0000 (12:40 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 11 Mar 2021 20:47:04 +0000 (20:47 +0000)
commit15097c7a1adc0554ce8eb6f5fd6758d063bfea44
treebb2d38aa07ab43258f23087adc7127c76794b742
parent3e3d11b2e43b9a967d98261250c19636b893b7ed
iio: buffer: wrap all buffer attributes into iio_dev_attr

This change wraps all buffer attributes into iio_dev_attr objects, and
assigns a reference to the IIO buffer they belong to.

With the addition of multiple IIO buffers per one IIO device, we need a way
to know which IIO buffer is being enabled/disabled/controlled.

We know that all buffer attributes are device_attributes. So we can wrap
them with a iio_dev_attr types. In the iio_dev_attr type, we can also hold
a reference to an IIO buffer.
So, we end up being able to allocate wrapped attributes for all buffer
attributes (even the one from other drivers).

The neat part with this mechanism, is that we don't need to add any extra
cleanup, because these attributes are being added to a dynamic list that
will get cleaned up via iio_free_chan_devattr_list().

With this change, the 'buffer->scan_el_dev_attr_list' list is being renamed
to 'buffer->buffer_attr_list', effectively merging (or finalizing the
merge) of the buffer/ & scan_elements/ attributes internally.

Accessing these new buffer attributes can now be done via
'to_iio_dev_attr(attr)->buffer' inside the show/store handlers.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-15-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/industrialio-buffer.c
drivers/iio/industrialio-core.c
include/linux/iio/buffer_impl.h