linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] iio: adc: ti-ads8688: save values correct in buffer
@ 2019-05-07  8:23 Sean Nyekjaer
  2019-05-07  8:23 ` [PATCH 2/2] iio: adc: ti-ads8688: fix timestamp is not updated " Sean Nyekjaer
  2019-05-11 11:44 ` [PATCH 1/2] iio: adc: ti-ads8688: save values correct " Jonathan Cameron
  0 siblings, 2 replies; 5+ messages in thread
From: Sean Nyekjaer @ 2019-05-07  8:23 UTC (permalink / raw)
  To: linux-iio, jic23; +Cc: Sean Nyekjaer

Fill the read values in the buffer so we comply
with the given index values.

Fixes: 2a86487786b5c ("iio: adc: ti-ads8688: add trigger and buffer support")
Signed-off-by: Sean Nyekjaer <sean@geanix.com>
---
 drivers/iio/adc/ti-ads8688.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/adc/ti-ads8688.c b/drivers/iio/adc/ti-ads8688.c
index f9461070a74a..d9c354dbd7e4 100644
--- a/drivers/iio/adc/ti-ads8688.c
+++ b/drivers/iio/adc/ti-ads8688.c
@@ -387,13 +387,12 @@ static irqreturn_t ads8688_trigger_handler(int irq, void *p)
 	struct iio_poll_func *pf = p;
 	struct iio_dev *indio_dev = pf->indio_dev;
 	u16 buffer[ADS8688_MAX_CHANNELS + sizeof(s64)/sizeof(u16)];
-	int i, j = 0;
+	int bit;
 
-	for (i = 0; i < indio_dev->masklength; i++) {
-		if (!test_bit(i, indio_dev->active_scan_mask))
-			continue;
-		buffer[j] = ads8688_read(indio_dev, i);
-		j++;
+	memset(buffer, 0, sizeof(buffer));
+
+	for_each_set_bit(bit, indio_dev->active_scan_mask, indio_dev->masklength) {
+		buffer[bit] = ads8688_read(indio_dev, bit);
 	}
 
 	iio_push_to_buffers_with_timestamp(indio_dev, buffer,
-- 
2.21.0


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

end of thread, other threads:[~2019-05-11 12:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-07  8:23 [PATCH 1/2] iio: adc: ti-ads8688: save values correct in buffer Sean Nyekjaer
2019-05-07  8:23 ` [PATCH 2/2] iio: adc: ti-ads8688: fix timestamp is not updated " Sean Nyekjaer
2019-05-11 11:50   ` Jonathan Cameron
2019-05-11 11:44 ` [PATCH 1/2] iio: adc: ti-ads8688: save values correct " Jonathan Cameron
2019-05-11 12:03   ` Sean Nyekjaer

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).