Thread (10 messages) 10 messages, 6 authors, 2022-04-12

Re: [PATCH] input: adc-joystick: Stop using scan_index for reading data

flat view

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: 2022-04-09 02:07:15

Hi Chris,

On Fri, Apr 08, 2022 at 04:28:57PM -0500, Chris Morgan wrote:
From: Chris Morgan <redacted>

For my Odroid Go Advance I noticed that the adc-joystick driver was
only reporting the y channel and on the x axis. After debugging, I
found that the driver was trying to read values from channels 0 and
1 even though my device is using channels 1 and 2. By changing the code
to use the axis index instead of the scan index when unpacking the data
from the buffer, the joystick begins working as expected.
This sounds like some sort of misconfiguration, as your change
effectively removes the ability of using just some ADC channels for
joystick functionality...

Let's add Jonathan and Arthur for their take on this.
quoted hunk ↗ jump to hunk
Signed-off-by: Chris Morgan <redacted>
---
 drivers/input/joystick/adc-joystick.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/input/joystick/adc-joystick.c b/drivers/input/joystick/adc-joystick.c
index 78ebca7d400a..fe3bbd0d4566 100644
--- a/drivers/input/joystick/adc-joystick.c
+++ b/drivers/input/joystick/adc-joystick.c
@@ -32,24 +32,23 @@ static int adc_joystick_handle(const void *data, void *private)
 {
 	struct adc_joystick *joy = private;
 	enum iio_endian endianness;
-	int bytes, msb, val, idx, i;
+	int bytes, msb, val, i;
 	const u16 *data_u16;
 	bool sign;
 
 	bytes = joy->chans[0].channel->scan_type.storagebits >> 3;
 
 	for (i = 0; i < joy->num_chans; ++i) {
-		idx = joy->chans[i].channel->scan_index;
 		endianness = joy->chans[i].channel->scan_type.endianness;
 		msb = joy->chans[i].channel->scan_type.realbits - 1;
 		sign = tolower(joy->chans[i].channel->scan_type.sign) == 's';
 
 		switch (bytes) {
 		case 1:
-			val = ((const u8 *)data)[idx];
+			val = ((const u8 *)data)[i];
 			break;
 		case 2:
-			data_u16 = (const u16 *)data + idx;
+			data_u16 = (const u16 *)data + i;
 
 			/*
 			 * Data is aligned to the sample size by IIO core.
-- 
2.25.1
Thanks.

-- 
Dmitry
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help