From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Mack Subject: Re: [PATCH, for-next] ALSA: usb-audio: caiaq: fix endianness bug in snd_usb_caiaq_maschine_dispatch Date: Mon, 29 Apr 2013 21:20:43 +0200 Message-ID: <517EC80B.4020609@gmail.com> References: <1367262946-8980-1-git-send-email-eldad@fogrefinery.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-bk0-f47.google.com (mail-bk0-f47.google.com [209.85.214.47]) by alsa0.perex.cz (Postfix) with ESMTP id E1AC52616B4 for ; Mon, 29 Apr 2013 21:20:33 +0200 (CEST) Received: by mail-bk0-f47.google.com with SMTP id ji1so2804731bkc.6 for ; Mon, 29 Apr 2013 12:20:33 -0700 (PDT) In-Reply-To: <1367262946-8980-1-git-send-email-eldad@fogrefinery.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Eldad Zack Cc: Takashi Iwai , alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org On 29.04.2013 21:15, Eldad Zack wrote: > 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 > Signed-off-by: Eldad Zack Appearantly, nobody (including me) has ever used the pad controls of this particular device on a BE machine. So I think it might not even be worth Cc'ing stable. Thanks for catching this, anyway! Daniel > --- > sound/usb/caiaq/input.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/sound/usb/caiaq/input.c b/sound/usb/caiaq/input.c > index efc70ae..4b3fb91 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, > unsigned int len) > { > unsigned int i, pad_id; > - uint16_t pressure; > + __le16 *pressure = (__le16 *) buf; > > for (i = 0; i < MASCHINE_PADS; i++) { > - pressure = be16_to_cpu(buf[i * 2] << 8 | buf[(i * 2) + 1]); > - pad_id = pressure >> 12; > - > - input_report_abs(cdev->input_dev, MASCHINE_PAD(pad_id), pressure & 0xfff); > + pad_id = le16_to_cpu(*pressure) >> 12; > + input_report_abs(cdev->input_dev, MASCHINE_PAD(pad_id), > + le16_to_cpu(*pressure) & 0xfff); > + pressure++; > } > > input_sync(cdev->input_dev); >