From: Takashi Iwai Subject: Re: get rid of controls with snd_ctl_remove Date: Fri, 29 Aug 2008 15:01:27 +0200 Message-ID: References: <200808291454.42441.harryrat@postnuklear.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 BF07D243F7 for ; Fri, 29 Aug 2008 15:01:27 +0200 (CEST) In-Reply-To: <200808291454.42441.harryrat@postnuklear.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: Harald Radke Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Fri, 29 Aug 2008 14:54:42 +0200, Harald Radke wrote: > > Hi there! > > Please be patient with me, I am quite inexperienced with alsa programming, so > this might be a dumb question: > > We have a WM8750 working in our PDA, the codec is working so far but I want to > remove some of the control since they aren't needed. > > Instead of copying the wm8750.c file and adjusting it, I want to write another > module which basically get rid of those controls, something like: > > [...] > > static const char* unused_controls[] = {"AAAA", "BBBB,"CCCC"}; > > struct snd_kcontrol *ctl; > > list_for_each_entry(ctl, &card->controls, list) You can't use list_for_each_entry() together with removal. Use list_for_each_entry_safe() for such a purpose. But... > for(i=0; i < ARRAY_SIZE(unused_controls); i++) > if (!strcmp(unused_controls[i],ctl->id.name)) { > down_write(&card->controls_rwsem); > snd_ctl_remove(card,ctl); > up_write(&card->controls_rwsem); > break; > } It'd be easier like the following: for (i = 0; i < ARRAY_SIZE(unused_controls); i++) { struct snd_ctl_elem_id id; memset(&id, 0, sizeof(id)); strcpy(id.name, unused_controls[i]); id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; snd_ctl_remove_id(card, &id); } Takashi