From: Takashi Iwai Subject: Re: [Fwd: Scratch Live amplifier switch] Date: Mon, 02 Nov 2009 14:03:25 +0100 Message-ID: References: <4A978CCD.3000408@gmx.net> <4AD8CF10.9050707@gmx.net> 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 469F2103885 for ; Mon, 2 Nov 2009 14:03:25 +0100 (CET) In-Reply-To: <4AD8CF10.9050707@gmx.net> 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: LCID Fire Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Fri, 16 Oct 2009 21:52:48 +0200, LCID Fire wrote: > > Signed-off-by: Andreas Bergmeier Thanks for the renewed patch. Below is a quick review. > diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c > index 00397c8..532d02d 100644 > --- a/sound/usb/usbmixer.c > +++ b/sound/usb/usbmixer.c > @@ -2013,6 +2013,281 @@ static void snd_audigy2nx_proc_read(struct snd_info_entry *entry, > } > } > > +static void snd_usb_cleanup_interrupt_urb(struct urb *pUrb) Avoid Windows-style variable names as much as possible. > +{ > + if (pUrb->transfer_buffer_length > 0) > + kfree(pUrb->transfer_buffer); > + > + kfree(pUrb->context); > + > + usb_free_urb(pUrb); > +} > + > +/* Wrapper for setting and submitting the interrupt urb().*/ > +static int snd_usb_interrupt_trans(struct usb_device *dev, > + unsigned int pipe, void *data, __u16 size, usb_complete_t callback) No need to use __u16. Here it can be simply unsigned int. > +{ > + int err = 0; > + void *buf = NULL; > + struct urb *pUrb = NULL; No need for initializations of all of these. (snip) > +/* gets called multiple times! */ > +static int snd_sl_controls_create(struct usb_mixer_interface *mixer) > +{ > + int i, err; > + > + for (i = 0; i < ARRAY_SIZE(snd_sl_controls); ++i) { > + struct snd_kcontrol *kcontrol = > + snd_ctl_new1(&snd_sl_controls[i], mixer); Missing NULL check here. > + > + /* Since we only need one control and the routine > + * is called multiple times we have to ignore all > + * attempts to attach controls multiple times*/ Hm, why is it called so many times? Can't it be limited with a check of iface or altsetting? > + if (snd_ctl_find_id(mixer->chip->card, &kcontrol->id)) { > + /* we found the control - it is already present > + * so just continue*/ > + snd_ctl_free_one(kcontrol); > + continue; > + } > + > + /* add frees the control if on err < 0! */ > + err = snd_ctl_add(mixer->chip->card, > + kcontrol); > + if (err < 0) > + return err; > + > + /* Make sure device is set to default */ > + err = snd_sl_phono_set(kcontrol, kcontrol->private_value); > + > + if (err < 0) { > + snd_ctl_free_one(kcontrol); Don't free this after adding via snd_ctl_add(). Just keep it. The final destructor will clean up everything eventually. thanks, Takashi