Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: greybus: audio_helper: Use snd_ctl_remove_id()

Use the standard snd_ctl_remove_id() helper function instead of open
code. This allows us to reduce the manual card->rwsem lock in the
caller side.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Johan Hovold <johan@kernel.org>
Cc: Alex Elder <elder@kernel.org>
Cc: greybus-dev@lists.linaro.org
Link: https://lore.kernel.org/r/20230718141304.1032-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>

+4 -16
+4 -16
drivers/staging/greybus/audio_helper.c
··· 149 149 for (i = 0; i < num_controls; i++) { 150 150 const struct snd_kcontrol_new *control = &controls[i]; 151 151 struct snd_ctl_elem_id id; 152 - struct snd_kcontrol *kctl; 153 152 154 153 if (prefix) 155 154 snprintf(id.name, sizeof(id.name), "%s %s", prefix, ··· 160 161 id.device = control->device; 161 162 id.subdevice = control->subdevice; 162 163 id.index = control->index; 163 - kctl = snd_ctl_find_id(card, &id); 164 - if (!kctl) { 165 - dev_err(dev, "Failed to find %s\n", control->name); 166 - continue; 167 - } 168 - err = snd_ctl_remove(card, kctl); 169 - if (err < 0) { 164 + err = snd_ctl_remove_id(card, &id); 165 + if (err < 0) 170 166 dev_err(dev, "%d: Failed to remove %s\n", err, 171 167 control->name); 172 - continue; 173 - } 174 168 } 175 169 return 0; 176 170 } ··· 173 181 unsigned int num_controls) 174 182 { 175 183 struct snd_card *card = component->card->snd_card; 176 - int err; 177 184 178 - down_write(&card->controls_rwsem); 179 - err = gbaudio_remove_controls(card, component->dev, controls, 180 - num_controls, component->name_prefix); 181 - up_write(&card->controls_rwsem); 182 - return err; 185 + return gbaudio_remove_controls(card, component->dev, controls, 186 + num_controls, component->name_prefix); 183 187 }