[PATCH 1/6] iio: buffer-dma: use lockdep instead of WARN()

Nuno Sá via B4 Relay
2025-12-03T15:10:57Z

From: Nuno Sá <nuno.sa@analog.com>

As documented, WARN() should be used with care given that it can panic
running kernels (depending on command line options). So, instead of
using it to make sure a lock is held, use the annotations we already
have in the kernel for the very same reason.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/buffer/industrialio-buffer-dma.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/buffer/industrialio-buffer-dma.c b/drivers/iio/buffer/industrialio-buffer-dma.c
index ee294a775e8a..617b2d550c2f 100644
--- a/drivers/iio/buffer/industrialio-buffer-dma.c
+++ b/drivers/iio/buffer/industrialio-buffer-dma.c
@@ -6,6 +6,7 @@

#include <linux/atomic.h>
#include <linux/cleanup.h>
+#include <linux/lockdep.h>
#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/module.h>
@@ -764,7 +765,7 @@ int iio_dma_buffer_enqueue_dmabuf(struct iio_buffer *buffer,
bool cookie;
int ret;

- WARN_ON(!mutex_is_locked(&queue->lock));
+ lockdep_assert_held(&queue->lock);

cookie = dma_fence_begin_signalling();

--
2.52.0