linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] input: adc-joystick: Stop using scan_index for reading data
@ 2022-04-08 21:28 Chris Morgan
  2022-04-09  2:07 ` Dmitry Torokhov
  0 siblings, 1 reply; 10+ messages in thread
From: Chris Morgan @ 2022-04-08 21:28 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, Chris Morgan

From: Chris Morgan <macromorgan@hotmail.com>

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.

Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
---
 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


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

end of thread, other threads:[~2022-04-12 16:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-08 21:28 [PATCH] input: adc-joystick: Stop using scan_index for reading data Chris Morgan
2022-04-09  2:07 ` Dmitry Torokhov
2022-04-09 10:08   ` Artur Rojek
2022-04-10  1:39     ` Chris Morgan
2022-04-10 14:58       ` Artur Rojek
2022-04-10 17:43         ` Jonathan Cameron
2022-04-11 22:07           ` Chris Morgan
2022-04-12 16:44             ` Jonathan Cameron
2022-04-12 16:47               ` Chris Morgan
2022-04-10 15:07       ` 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).