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

ALSA: control: Use list_for_each_entry_safe()

Instead of reiterating the list, use list_for_each_entry_safe()
that allows to continue without starting over.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Message-ID: <20240424145020.1057216-1-andriy.shevchenko@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Andy Shevchenko and committed by
Takashi Iwai
541b8a26 25f46354

+5 -10
+5 -10
sound/core/control_led.c
··· 285 285 static void snd_ctl_led_clean(struct snd_card *card) 286 286 { 287 287 unsigned int group; 288 + struct snd_ctl_led_ctl *lctl, *_lctl; 288 289 struct snd_ctl_led *led; 289 - struct snd_ctl_led_ctl *lctl; 290 290 291 291 for (group = 0; group < MAX_LED; group++) { 292 292 led = &snd_ctl_leds[group]; 293 - repeat: 294 - list_for_each_entry(lctl, &led->controls, list) 295 - if (!card || lctl->card == card) { 293 + list_for_each_entry_safe(lctl, _lctl, &led->controls, list) 294 + if (!card || lctl->card == card) 296 295 snd_ctl_led_ctl_destroy(lctl); 297 - goto repeat; 298 - } 299 296 } 300 297 } 301 298 302 299 static int snd_ctl_led_reset(int card_number, unsigned int group) 303 300 { 304 301 struct snd_card *card __free(snd_card_unref) = NULL; 302 + struct snd_ctl_led_ctl *lctl, *_lctl; 305 303 struct snd_ctl_led *led; 306 - struct snd_ctl_led_ctl *lctl; 307 304 struct snd_kcontrol_volatile *vd; 308 305 bool change = false; 309 306 ··· 312 315 if (!snd_ctl_led_card_valid[card_number]) 313 316 return -ENXIO; 314 317 led = &snd_ctl_leds[group]; 315 - repeat: 316 - list_for_each_entry(lctl, &led->controls, list) 318 + list_for_each_entry_safe(lctl, _lctl, &led->controls, list) 317 319 if (lctl->card == card) { 318 320 vd = &lctl->kctl->vd[lctl->index_offset]; 319 321 vd->access &= ~group_to_access(group); 320 322 snd_ctl_led_ctl_destroy(lctl); 321 323 change = true; 322 - goto repeat; 323 324 } 324 325 } 325 326 if (change)