iio: dma-buffer: Cleanup buffer.h/buffer_impl.h includes
PATCH 1/1 iio: dma-buffer: Cleanup buffer.h/buffer_impl.h includes
The IIO DMA buffer is a DMA buffer implementation. As such it should include buffer_impl.h rather than buffer.h.
The include to buffer.h in buffer-dma.h should be buffer_impl.h so it has access to the struct iio_buffer definition. The code currently only works because all places that use buffer-dma.h include buffer_impl.h before it.
The include to buffer.h in industrialio-buffer-dma.c and industrialio-buffer-dmaengine.c can be removed since those files don't reference any of buffer consumer functions.
--- drivers/iio/buffer/industrialio-buffer-dma.c | 1 - drivers/iio/buffer/industrialio-buffer-dmaengine.c | 1 - include/linux/iio/buffer-dma.h | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-)
drivers/iio/buffer/industrialio-buffer-dma.c +0 -1
@@ -12,7 +12,6 @@#include <linux/mutex.h> #include <linux/sched.h> #include <linux/poll.h> -#include <linux/iio/buffer.h> #include <linux/iio/buffer_impl.h> #include <linux/iio/buffer-dma.h> #include <linux/dma-mapping.h>
drivers/iio/buffer/industrialio-buffer-dmaengine.c +0 -1
@@ -14,7 +14,6 @@#include <linux/iio/iio.h> #include <linux/iio/sysfs.h> -#include <linux/iio/buffer.h> #include <linux/iio/buffer_impl.h> #include <linux/iio/buffer-dma.h> #include <linux/iio/buffer-dmaengine.h>
include/linux/iio/buffer-dma.h +1 -1
@@ -11,7 +11,7 @@#include <linux/kref.h> #include <linux/spinlock.h> #include <linux/mutex.h> -#include <linux/iio/buffer.h> +#include <linux/iio/buffer_impl.h> struct iio_dma_buffer_queue ;struct iio_dma_buffer_ops ;
Signature · 1 line
2.20.1
Quoted 5 lines · Lars-Peter Clausen
[External]
The IIO DMA buffer is a DMA buffer implementation. As such it should include
buffer_impl.hrather thanbuffer.h.
Quoted 7 lines
The include to
buffer.hinbuffer-dma.hshould bebuffer_impl.hso it has access to the structiio_bufferdefinition. The code currently only works because all places that usebuffer-dma.hincludebuffer_impl.hbefore it.The include to
buffer.hinindustrialio-buffer-dma.candindustrialio-buffer-dmaengine.ccan be removed since those files don't reference any of buffer consumer functions.
Quoted 47 lines
Signed-off-by Lars-Peter Clausen <[email protected]>--- drivers/iio/buffer/industrialio-buffer-dma.c | 1 - drivers/iio/buffer/industrialio-buffer-dmaengine.c | 1 - include/linux/iio/buffer-dma.h | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-)drivers/iio/buffer/industrialio-buffer-dma.c +0
-1@@ -12,7 +12,6 @@#include <linux/mutex.h> #include <linux/sched.h> #include <linux/poll.h> -#include <linux/iio/buffer.h> #include <linux/iio/buffer_impl.h> #include <linux/iio/buffer-dma.h> #include <linux/dma-mapping.h> drivers/iio/buffer/industrialio-buffer-dmaengine.c +0
-1@@ -14,7 +14,6 @@#include <linux/iio/iio.h> #include <linux/iio/sysfs.h> -#include <linux/iio/buffer.h> #include <linux/iio/buffer_impl.h> #include <linux/iio/buffer-dma.h> #include <linux/iio/buffer-dmaengine.h> include/linux/iio/buffer-dma.h +1
-1@@ -11,7 +11,7 @@#include <linux/kref.h> #include <linux/spinlock.h> #include <linux/mutex.h> -#include <linux/iio/buffer.h> +#include <linux/iio/buffer_impl.h> struct iio_dma_buffer_queue ;struct iio_dma_buffer_ops ;
Jonathan Cameron
maintainerQuoted 10 lines · Alexandru
Quoted 9 lines · Lars-Peter Clausen
[External]
The IIO DMA buffer is a DMA buffer implementation. As such it should include
buffer_impl.hrather thanbuffer.h.The include to
buffer.hinbuffer-dma.hshould bebuffer_impl.hso it has access to the structiio_bufferdefinition. The code currently only works because all places that usebuffer-dma.hincludebuffer_impl.hbefore it.
Quoted 6 lines
Quoted 3 lines
The include to
buffer.hinindustrialio-buffer-dma.candindustrialio-buffer-dmaengine.ccan be removed since those files don't reference any of buffer consumer functions.Reviewed-by Alexandru Ardelean <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing.
Thanks
Jonathan
Quoted 47 lines
Quoted 47 lines
Signed-off-by Lars-Peter Clausen <[email protected]>--- drivers/iio/buffer/industrialio-buffer-dma.c | 1 - drivers/iio/buffer/industrialio-buffer-dmaengine.c | 1 - include/linux/iio/buffer-dma.h | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-)drivers/iio/buffer/industrialio-buffer-dma.c +0
-1@@ -12,7 +12,6 @@#include <linux/mutex.h> #include <linux/sched.h> #include <linux/poll.h> -#include <linux/iio/buffer.h> #include <linux/iio/buffer_impl.h> #include <linux/iio/buffer-dma.h> #include <linux/dma-mapping.h> drivers/iio/buffer/industrialio-buffer-dmaengine.c +0
-1@@ -14,7 +14,6 @@#include <linux/iio/iio.h> #include <linux/iio/sysfs.h> -#include <linux/iio/buffer.h> #include <linux/iio/buffer_impl.h> #include <linux/iio/buffer-dma.h> #include <linux/iio/buffer-dmaengine.h> include/linux/iio/buffer-dma.h +1
-1@@ -11,7 +11,7 @@#include <linux/kref.h> #include <linux/spinlock.h> #include <linux/mutex.h> -#include <linux/iio/buffer.h> +#include <linux/iio/buffer_impl.h> struct iio_dma_buffer_queue ;struct iio_dma_buffer_ops ;
Quoted 13 lines · On Sat, 28 Mar 2020 16:43:35 +0000 Jonathan Cameron <[email protected]> wrote:
Quoted 10 lines · Alexandru
Quoted 9 lines · Lars-Peter Clausen
[External]
The IIO DMA buffer is a DMA buffer implementation. As such it should include
buffer_impl.hrather thanbuffer.h.The include to
buffer.hinbuffer-dma.hshould bebuffer_impl.hso it has access to the structiio_bufferdefinition. The code currently only works because all places that usebuffer-dma.hincludebuffer_impl.hbefore it.
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
The include to
buffer.hinindustrialio-buffer-dma.candindustrialio-buffer-dmaengine.ccan be removed since those files don't reference any of buffer consumer functions.Reviewed-by Alexandru Ardelean <[email protected]>Applied to the togreg branch of iio.git and pushed out as testing.
And reverted again.
The usecase that was introduced in another path meant this finally got built in my tests and this patch broke it :(
Seems we use iio_buffer_set_attrs in the dmaengine buffer and that's in buffer.h.
I haven't looked to see how to fix this (e.g. can we just move that definition to buffer_impl).
Jonathan
Quoted 53 lines
Thanks
Jonathan
Quoted 47 lines
Quoted 47 lines
Signed-off-by Lars-Peter Clausen <[email protected]>--- drivers/iio/buffer/industrialio-buffer-dma.c | 1 - drivers/iio/buffer/industrialio-buffer-dmaengine.c | 1 - include/linux/iio/buffer-dma.h | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-)drivers/iio/buffer/industrialio-buffer-dma.c +0
-1@@ -12,7 +12,6 @@#include <linux/mutex.h> #include <linux/sched.h> #include <linux/poll.h> -#include <linux/iio/buffer.h> #include <linux/iio/buffer_impl.h> #include <linux/iio/buffer-dma.h> #include <linux/dma-mapping.h> drivers/iio/buffer/industrialio-buffer-dmaengine.c +0
-1@@ -14,7 +14,6 @@#include <linux/iio/iio.h> #include <linux/iio/sysfs.h> -#include <linux/iio/buffer.h> #include <linux/iio/buffer_impl.h> #include <linux/iio/buffer-dma.h> #include <linux/iio/buffer-dmaengine.h> include/linux/iio/buffer-dma.h +1
-1@@ -11,7 +11,7 @@#include <linux/kref.h> #include <linux/spinlock.h> #include <linux/mutex.h> -#include <linux/iio/buffer.h> +#include <linux/iio/buffer_impl.h> struct iio_dma_buffer_queue ;struct iio_dma_buffer_ops ;
Sa, Nuno
reviewerHi Lars,
Quoted 14 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Lars-Peter Clausen
Sent: Dienstag, 24. März 2020 15:16
To: Jonathan Cameron <[email protected]>
Cc: Hartmut Knaack <[email protected]>; Peter Meerwald-Stadler <[email protected]>; Ardelean, Alexandru <[email protected]>; [email protected]; Lars-Peter Clausen <[email protected]>
Subject: [PATCH] iio: dma-buffer: Cleanupbuffer.h/buffer_impl.hincludesThe IIO DMA buffer is a DMA buffer implementation. As such it should include
buffer_impl.hrather thanbuffer.h.
Quoted 8 lines
The include to
buffer.hinbuffer-dma.hshould bebuffer_impl.hso it has access to the structiio_bufferdefinition. The code currently only works because all places that usebuffer-dma.hincludebuffer_impl.hbefore it.The include to
buffer.hinindustrialio-buffer-dma.candindustrialio-buffer-dmaengine.ccan be removed since those files don't reference any of buffer consumer functions.
I also came across with this in ADI internal tree. Did you considered to also split buffer_dma.h into a public and an impl header? Hence, users of buffer_dma do not get access to the internals of buffer.h? That was the approach I suggested in our tree since the split of buffer and buffer_impl is exactly for users not to know about the internals...
Or do you think that it's not worth it to go over this split in buffer_dma?
- Nuno Sá
Quoted 6 lines · Nuno
I also came across with this in ADI internal tree. Did you considered to also split
buffer_dma.hinto a public and an impl header? Hence, users ofbuffer_dmado not get access to the internals ofbuffer.h? That was the approach I suggested in our tree since the split of buffer andbuffer_implis exactly for users not to know about the internals...Or do you think that it's not
At the moment I think there are no users of buffer-dma.h that are not implementations of a buffer. At least in upstream.
There are a few drivers in the ADI tree, which include buffer-dma.h. But this is because they provide their own overloaded implementation for some of the callbacks. In a sense that makes them a buffer implementation. Most of them use the same simple implementation for the overloaded operations. It should be possible to factor this out and use it as a default. Then the include to buffer_dma.h can be removed.
- Lars