Commit 4ca231b2 authored by Eldad Zack's avatar Eldad Zack Committed by Takashi Iwai

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: default avatarDaniel Mack <zonque@gmail.com>
Signed-off-by: default avatarEldad Zack <eldad@fogrefinery.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 167d0a11
...@@ -488,13 +488,13 @@ static void snd_usb_caiaq_maschine_dispatch(struct snd_usb_caiaqdev *cdev, ...@@ -488,13 +488,13 @@ static void snd_usb_caiaq_maschine_dispatch(struct snd_usb_caiaqdev *cdev,
unsigned int len) unsigned int len)
{ {
unsigned int i, pad_id; unsigned int i, pad_id;
uint16_t pressure; __le16 *pressure = (__le16 *) buf;
for (i = 0; i < MASCHINE_PADS; i++) { for (i = 0; i < MASCHINE_PADS; i++) {
pressure = be16_to_cpu(buf[i * 2] << 8 | buf[(i * 2) + 1]); pad_id = le16_to_cpu(*pressure) >> 12;
pad_id = pressure >> 12; input_report_abs(cdev->input_dev, MASCHINE_PAD(pad_id),
le16_to_cpu(*pressure) & 0xfff);
input_report_abs(cdev->input_dev, MASCHINE_PAD(pad_id), pressure & 0xfff); pressure++;
} }
input_sync(cdev->input_dev); input_sync(cdev->input_dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment