[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220817105643.95710-2-contact@artur-rojek.eu>
Date: Wed, 17 Aug 2022 12:56:40 +0200
From: Artur Rojek <contact@...ur-rojek.eu>
To: Paul Cercueil <paul@...pouillou.net>,
Jonathan Cameron <jic23@...nel.org>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
Chris Morgan <macromorgan@...mail.com>
Cc: linux-mips@...r.kernel.org, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-input@...r.kernel.org,
Artur Rojek <contact@...ur-rojek.eu>
Subject: [PATCH 1/4] iio/adc: ingenic: fix channel offsets in buffer
Consumers expect the buffer to only contain enabled channels. While
preparing the buffer, the driver also (incorrectly) inserts empty data
for disabled channels, causing the enabled channels to appear at wrong
offsets. Fix that.
Fixes: b96952f498db ("IIO: Ingenic JZ47xx: Add touchscreen mode.")
Tested-by: Paul Cercueil <paul@...pouillou.net>
Signed-off-by: Artur Rojek <contact@...ur-rojek.eu>
---
drivers/iio/adc/ingenic-adc.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/adc/ingenic-adc.c b/drivers/iio/adc/ingenic-adc.c
index a7325dbbb99a..5a932c375a89 100644
--- a/drivers/iio/adc/ingenic-adc.c
+++ b/drivers/iio/adc/ingenic-adc.c
@@ -804,11 +804,10 @@ static irqreturn_t ingenic_adc_irq(int irq, void *data)
unsigned int i;
u32 tdat[3];
- for (i = 0; i < ARRAY_SIZE(tdat); mask >>= 2, i++) {
+ memset(tdat, 0, ARRAY_SIZE(tdat));
+ for (i = 0; mask && i < ARRAY_SIZE(tdat); mask >>= 2) {
if (mask & 0x3)
- tdat[i] = readl(adc->base + JZ_ADC_REG_ADTCH);
- else
- tdat[i] = 0;
+ tdat[i++] = readl(adc->base + JZ_ADC_REG_ADTCH);
}
iio_push_to_buffers(iio_dev, tdat);
--
2.37.2
Powered by blists - more mailing lists