diff options
author | Eldad Zack <eldad@fogrefinery.com> | 2013-04-29 15:15:46 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-04-30 03:19:02 -0400 |
commit | 4ca231b2e6ed171107c5b21f9e92d1965fd6fd9e (patch) | |
tree | 25acf07f6210c17b7a1f930e7d136d0202094dba /sound/usb/caiaq | |
parent | 167d0a11d5feedd1f9cb9ae128ac543e97148eff (diff) |
ALSA: usb-audio: caiaq: fix endianness bug in snd_usb_caiaq_maschine_dispatch
Current code does this:
be16_to_cpu(buf[i * 2] << 8 | buf[(i * 2) + 1])
Which is effectively (neglecting the index):
be16_to_cpu(be16_to_cpu(*((u16 *) buf)))
This means the int16 in the buffer is not converted at all.
Daniel Mack confirmed that the driver works on little endian
CPUs, leading to the conclusion that the device-side structure
is actually little endian.
This changes the code to use le16_to_cpu().
Caught by sparse.
Acked-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Eldad Zack <eldad@fogrefinery.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/caiaq')
-rw-r--r-- | sound/usb/caiaq/input.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sound/usb/caiaq/input.c b/sound/usb/caiaq/input.c index efc70ae915c5..4b3fb91deecd 100644 --- a/sound/usb/caiaq/input.c +++ b/sound/usb/caiaq/input.c | |||
@@ -488,13 +488,13 @@ static void snd_usb_caiaq_maschine_dispatch(struct snd_usb_caiaqdev *cdev, | |||
488 | unsigned int len) | 488 | unsigned int len) |
489 | { | 489 | { |
490 | unsigned int i, pad_id; | 490 | unsigned int i, pad_id; |
491 | uint16_t pressure; | 491 | __le16 *pressure = (__le16 *) buf; |
492 | 492 | ||
493 | for (i = 0; i < MASCHINE_PADS; i++) { | 493 | for (i = 0; i < MASCHINE_PADS; i++) { |
494 | pressure = be16_to_cpu(buf[i * 2] << 8 | buf[(i * 2) + 1]); | 494 | pad_id = le16_to_cpu(*pressure) >> 12; |
495 | pad_id = pressure >> 12; | 495 | input_report_abs(cdev->input_dev, MASCHINE_PAD(pad_id), |
496 | 496 | le16_to_cpu(*pressure) & 0xfff); | |
497 | input_report_abs(cdev->input_dev, MASCHINE_PAD(pad_id), pressure & 0xfff); | 497 | pressure++; |
498 | } | 498 | } |
499 | 499 | ||
500 | input_sync(cdev->input_dev); | 500 | input_sync(cdev->input_dev); |