From: Chris Morgan <macroalpha82@gmail.com>
To: linux-input@vger.kernel.org
Cc: dmitry.torokhov@gmail.com, Chris Morgan <macromorgan@hotmail.com>
Subject: [PATCH] input: adc-joystick: Stop using scan_index for reading data
Date: Fri, 8 Apr 2022 16:28:57 -0500 [thread overview]
Message-ID: <20220408212857.9583-1-macroalpha82@gmail.com> (raw)
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
next reply other threads:[~2022-04-08 21:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-08 21:28 Chris Morgan [this message]
2022-04-09 2:07 ` [PATCH] input: adc-joystick: Stop using scan_index for reading data 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220408212857.9583-1-macroalpha82@gmail.com \
--to=macroalpha82@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=macromorgan@hotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).