Skip to contentSkip to conversation

iio: dma-buffer: Cleanup buffer.h/buffer_impl.h includes

PATCH Superseded Lars-Peter Clausen 5 participants 6 messages Mar 24, 2020 – Mar 29, 2020 IIO

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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
index a74bd9c0587c..d348af8b9705 100644
@@ -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
index b129693af0fd..8b60dff527c8 100644
@@ -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
index 016d8a068353..ff15c61bf319 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Lars-Peter Clausen

[External]

The IIO DMA buffer is a DMA buffer implementation. As such it should include buffer_impl.h rather than buffer.h.

Quoted 7 lines

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.

Quoted 47 lines
---
 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
index a74bd9c0587c..d348af8b9705 100644
@@ -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
index b129693af0fd..8b60dff527c8 100644
@@ -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
index 016d8a068353..ff15c61bf319 100644
@@ -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;
maintainer
#2 lore raw
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.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.

Quoted 6 lines
Quoted 3 lines

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.

Applied to the togreg branch of iio.git and pushed out as testing.

Thanks

Jonathan

Quoted 47 lines
Quoted 47 lines
---
 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
index a74bd9c0587c..d348af8b9705 100644
@@ -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
index b129693af0fd..8b60dff527c8 100644
@@ -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
index 016d8a068353..ff15c61bf319 100644
@@ -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;  
#3 lore raw
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.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.

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

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.

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
---
 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
index a74bd9c0587c..d348af8b9705 100644
@@ -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
index b129693af0fd..8b60dff527c8 100644
@@ -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
index 016d8a068353..ff15c61bf319 100644
@@ -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;    
reviewer
#4 lore raw
In reply to Lars-Peter Clausen

Hi 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: 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.

Quoted 8 lines

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.

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á

#5 lore raw
Quoted 6 lines · Nuno

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

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