alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Daniel Mack <zonque@gmail.com>
Cc: Eldad Zack <eldad@fogrefinery.com>, alsa-devel@alsa-project.org
Subject: Re: [PATCH, for-next] ALSA: usb-audio: caiaq: fix endianness bug in snd_usb_caiaq_maschine_dispatch
Date: Tue, 30 Apr 2013 09:19:45 +0200	[thread overview]
Message-ID: <s5hr4hszdri.wl%tiwai@suse.de> (raw)
In-Reply-To: <517EC80B.4020609@gmail.com>

At Mon, 29 Apr 2013 21:20:43 +0200,
Daniel Mack wrote:
> 
> 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 <zonque@gmail.com>
> > Signed-off-by: Eldad Zack <eldad@fogrefinery.com>
> 
> 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.

OK.  Applied as is now.
Thanks.

Takashi

> 
> 
> 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);
> > 
> 

      reply	other threads:[~2013-04-30  7:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-29 19:15 [PATCH, for-next] ALSA: usb-audio: caiaq: fix endianness bug in snd_usb_caiaq_maschine_dispatch Eldad Zack
2013-04-29 19:20 ` Daniel Mack
2013-04-30  7:19   ` Takashi Iwai [this message]

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=s5hr4hszdri.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=eldad@fogrefinery.com \
    --cc=zonque@gmail.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).