Skip to content

Commit 541b8a2

Browse files
andy-shevtiwai
authored andcommitted
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>
1 parent 25f4635 commit 541b8a2

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

sound/core/control_led.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -285,25 +285,22 @@ static void snd_ctl_led_ctl_destroy(struct snd_ctl_led_ctl *lctl)
285285
static void snd_ctl_led_clean(struct snd_card *card)
286286
{
287287
unsigned int group;
288+
struct snd_ctl_led_ctl *lctl, *_lctl;
288289
struct snd_ctl_led *led;
289-
struct snd_ctl_led_ctl *lctl;
290290

291291
for (group = 0; group < MAX_LED; group++) {
292292
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)
296295
snd_ctl_led_ctl_destroy(lctl);
297-
goto repeat;
298-
}
299296
}
300297
}
301298

302299
static int snd_ctl_led_reset(int card_number, unsigned int group)
303300
{
304301
struct snd_card *card __free(snd_card_unref) = NULL;
302+
struct snd_ctl_led_ctl *lctl, *_lctl;
305303
struct snd_ctl_led *led;
306-
struct snd_ctl_led_ctl *lctl;
307304
struct snd_kcontrol_volatile *vd;
308305
bool change = false;
309306

@@ -315,14 +312,12 @@ static int snd_ctl_led_reset(int card_number, unsigned int group)
315312
if (!snd_ctl_led_card_valid[card_number])
316313
return -ENXIO;
317314
led = &snd_ctl_leds[group];
318-
repeat:
319-
list_for_each_entry(lctl, &led->controls, list)
315+
list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
320316
if (lctl->card == card) {
321317
vd = &lctl->kctl->vd[lctl->index_offset];
322318
vd->access &= ~group_to_access(group);
323319
snd_ctl_led_ctl_destroy(lctl);
324320
change = true;
325-
goto repeat;
326321
}
327322
}
328323
if (change)

0 commit comments

Comments
 (0)