diff mbox series

[v6,15/24] iio: buffer: dmaengine: obtain buffer object from attribute

Message ID 20210215104043.91251-16-alexandru.ardelean@analog.com (mailing list archive)
State New, archived
Headers show
Series iio: core,buffer: add support for multiple IIO buffers per IIO device | expand

Commit Message

Alexandru Ardelean Feb. 15, 2021, 10:40 a.m. UTC
The reference to the IIO buffer object is stored on the attribute object.
So we need to unwind it to obtain it.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
 drivers/iio/buffer/industrialio-buffer-dmaengine.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jonathan Cameron Feb. 15, 2021, 12:44 p.m. UTC | #1
On Mon, 15 Feb 2021 12:40:34 +0200
Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:

> The reference to the IIO buffer object is stored on the attribute object.
> So we need to unwind it to obtain it.
> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>

This could have done with a little more description of 'why', but
I'm not going to hold up the series to fix it.

Jonathan

> ---
>  drivers/iio/buffer/industrialio-buffer-dmaengine.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/buffer/industrialio-buffer-dmaengine.c b/drivers/iio/buffer/industrialio-buffer-dmaengine.c
> index 9981896e1495..a64b222289be 100644
> --- a/drivers/iio/buffer/industrialio-buffer-dmaengine.c
> +++ b/drivers/iio/buffer/industrialio-buffer-dmaengine.c
> @@ -132,9 +132,9 @@ static const struct iio_dma_buffer_ops iio_dmaengine_default_ops = {
>  static ssize_t iio_dmaengine_buffer_get_length_align(struct device *dev,
>  	struct device_attribute *attr, char *buf)
>  {
> -	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> +	struct iio_buffer *buffer = to_iio_dev_attr(attr)->buffer;
>  	struct dmaengine_buffer *dmaengine_buffer =
> -		iio_buffer_to_dmaengine_buffer(indio_dev->buffer);
> +		iio_buffer_to_dmaengine_buffer(buffer);
>  
>  	return sprintf(buf, "%zu\n", dmaengine_buffer->align);
>  }
diff mbox series

Patch

diff --git a/drivers/iio/buffer/industrialio-buffer-dmaengine.c b/drivers/iio/buffer/industrialio-buffer-dmaengine.c
index 9981896e1495..a64b222289be 100644
--- a/drivers/iio/buffer/industrialio-buffer-dmaengine.c
+++ b/drivers/iio/buffer/industrialio-buffer-dmaengine.c
@@ -132,9 +132,9 @@  static const struct iio_dma_buffer_ops iio_dmaengine_default_ops = {
 static ssize_t iio_dmaengine_buffer_get_length_align(struct device *dev,
 	struct device_attribute *attr, char *buf)
 {
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+	struct iio_buffer *buffer = to_iio_dev_attr(attr)->buffer;
 	struct dmaengine_buffer *dmaengine_buffer =
-		iio_buffer_to_dmaengine_buffer(indio_dev->buffer);
+		iio_buffer_to_dmaengine_buffer(buffer);
 
 	return sprintf(buf, "%zu\n", dmaengine_buffer->align);
 }