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