linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH] iio: buffer: Don't allow buffers without any channels enabled to be activated
@ 2020-03-20 10:40 Alexandru Ardelean
  2020-03-20 10:55 ` Lars-Peter Clausen
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Alexandru Ardelean @ 2020-03-20 10:40 UTC (permalink / raw)
  To: linux-iio; +Cc: lars, jic23, Alexandru Ardelean

From: Lars-Peter Clausen <lars@metafoo.de>

Before activating a buffer make sure that at least one channel is enabled.
Activating a buffer with 0 channels enabled doesn't make too much sense and
disallowing this case makes sure that individual driver don't have to add
special case code to handle it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---

* Found this relic-patch in our tree, from 6 years ago:
  https://github.com/analogdevicesinc/linux/commit/6d680e49d459c
  It got moved around a bit, and this is the current form in the ADI tree.
  So, this is also a bit of an RFC, but if the idea is valid, maybe it's
  worth considering upstream. I don't know of any arguments against it,
  but I could be surprised.

 drivers/iio/industrialio-buffer.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 4ada5592aa2b..f222a118d0d3 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -1031,6 +1031,12 @@ static int __iio_update_buffers(struct iio_dev *indio_dev,
 		return ret;
 
 	if (insert_buffer) {
+		if (bitmap_empty(insert_buffer->scan_mask,
+			indio_dev->masklength)) {
+			ret = -EINVAL;
+			goto err_free_config;
+		}
+
 		ret = iio_buffer_request_update(indio_dev, insert_buffer);
 		if (ret)
 			goto err_free_config;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2020-03-28 13:13 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-20 10:40 [RFC][PATCH] iio: buffer: Don't allow buffers without any channels enabled to be activated Alexandru Ardelean
2020-03-20 10:55 ` Lars-Peter Clausen
2020-03-20 11:16   ` Ardelean, Alexandru
2020-03-21 18:21     ` Jonathan Cameron
2020-03-21 21:44       ` Andy Shevchenko
2020-03-25  8:17       ` Ardelean, Alexandru
2020-03-25  8:23         ` Ardelean, Alexandru
2020-03-25 10:01 ` [PATCH v2] " Alexandru Ardelean
2020-03-25 10:12   ` Ardelean, Alexandru
2020-03-25 15:57   ` Andy Shevchenko
2020-03-26  7:42     ` Ardelean, Alexandru
2020-03-26  7:44       ` Lars-Peter Clausen
2020-03-26  7:46         ` Ardelean, Alexandru
2020-03-26  9:30 ` [PATCH v3] " Alexandru Ardelean
2020-03-28 13:13   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).