From: Takashi Iwai Subject: Re: [PATCH 1/9] ALSA: usb-audio: UAC2: clean up parsing of bmaControls Date: Mon, 31 May 2010 18:35:22 +0200 Message-ID: References: <1275305744-6590-1-git-send-email-daniel@caiaq.de> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 02DB1244AF for ; Mon, 31 May 2010 18:35:23 +0200 (CEST) In-Reply-To: <1275305744-6590-1-git-send-email-daniel@caiaq.de> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Daniel Mack Cc: alsa-devel@alsa-project.org, gregkh@suse.de, clemens@ladisch.de List-Id: alsa-devel@alsa-project.org At Mon, 31 May 2010 13:35:36 +0200, Daniel Mack wrote: > > Introduce two new static inline functions for a more readable parsing > of UAC2 bmaControls. > > Signed-off-by: Daniel Mack Thanks! Now I applied all patches for 2.6.35-rc2. But, basically I don't want to touch too much after this. So, please avoid refactoring patches for 2.6.35. If any, prepare a separate one for 2.6.36, and let's concentrate on fixes during 2.6.35-rc. Takashi > --- > include/linux/usb/audio-v2.h | 10 ++++++++++ > sound/usb/mixer.c | 8 ++++---- > 2 files changed, 14 insertions(+), 4 deletions(-) > > diff --git a/include/linux/usb/audio-v2.h b/include/linux/usb/audio-v2.h > index 92f1d99..8f91be3 100644 > --- a/include/linux/usb/audio-v2.h > +++ b/include/linux/usb/audio-v2.h > @@ -18,6 +18,16 @@ > /* v1.0 and v2.0 of this standard have many things in common. For the rest > * of the definitions, please refer to audio.h */ > > +static inline bool uac2_control_is_readable(u32 bmControls, u8 control) > +{ > + return (bmControls >> (control * 2)) & 0x1; > +} > + > +static inline bool uac2_control_is_writeable(u32 bmControls, u8 control) > +{ > + return (bmControls >> (control * 2)) & 0x2; > +} > + > /* 4.7.2.1 Clock Source Descriptor */ > > struct uac_clock_source_descriptor { > diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c > index 03ce971..43d6417 100644 > --- a/sound/usb/mixer.c > +++ b/sound/usb/mixer.c > @@ -1188,9 +1188,9 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void > > for (j = 0; j < channels; j++) { > unsigned int mask = snd_usb_combine_bytes(bmaControls + csize * (j+1), csize); > - if (mask & (1 << (i * 2))) { > + if (uac2_control_is_readable(mask, i)) { > ch_bits |= (1 << j); > - if (~mask & (1 << ((i * 2) + 1))) > + if (!uac2_control_is_writeable(mask, i)) > ch_read_only |= (1 << j); > } > } > @@ -1198,9 +1198,9 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void > /* FIXME: the whole unit is read-only if any of the channels is marked read-only */ > if (ch_bits & 1) /* the first channel must be set (for ease of programming) */ > build_feature_ctl(state, _ftr, ch_bits, i, &iterm, unitid, !!ch_read_only); > - if (master_bits & (1 << i * 2)) > + if (uac2_control_is_readable(master_bits, i)) > build_feature_ctl(state, _ftr, 0, i, &iterm, unitid, > - ~master_bits & (1 << ((i * 2) + 1))); > + !uac2_control_is_writeable(master_bits, i)); > } > } > > -- > 1.7.1 >