Commit 541b8a26 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Takashi Iwai

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarJaroslav Kysela <perex@perex.cz>
Message-ID: <20240424145020.1057216-1-andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 25f46354
...@@ -285,25 +285,22 @@ static void snd_ctl_led_ctl_destroy(struct snd_ctl_led_ctl *lctl) ...@@ -285,25 +285,22 @@ static void snd_ctl_led_ctl_destroy(struct snd_ctl_led_ctl *lctl)
static void snd_ctl_led_clean(struct snd_card *card) static void snd_ctl_led_clean(struct snd_card *card)
{ {
unsigned int group; unsigned int group;
struct snd_ctl_led_ctl *lctl, *_lctl;
struct snd_ctl_led *led; struct snd_ctl_led *led;
struct snd_ctl_led_ctl *lctl;
for (group = 0; group < MAX_LED; group++) { for (group = 0; group < MAX_LED; group++) {
led = &snd_ctl_leds[group]; led = &snd_ctl_leds[group];
repeat: list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
list_for_each_entry(lctl, &led->controls, list) if (!card || lctl->card == card)
if (!card || lctl->card == card) {
snd_ctl_led_ctl_destroy(lctl); snd_ctl_led_ctl_destroy(lctl);
goto repeat;
}
} }
} }
static int snd_ctl_led_reset(int card_number, unsigned int group) static int snd_ctl_led_reset(int card_number, unsigned int group)
{ {
struct snd_card *card __free(snd_card_unref) = NULL; struct snd_card *card __free(snd_card_unref) = NULL;
struct snd_ctl_led_ctl *lctl, *_lctl;
struct snd_ctl_led *led; struct snd_ctl_led *led;
struct snd_ctl_led_ctl *lctl;
struct snd_kcontrol_volatile *vd; struct snd_kcontrol_volatile *vd;
bool change = false; bool change = false;
...@@ -315,14 +312,12 @@ static int snd_ctl_led_reset(int card_number, unsigned int group) ...@@ -315,14 +312,12 @@ static int snd_ctl_led_reset(int card_number, unsigned int group)
if (!snd_ctl_led_card_valid[card_number]) if (!snd_ctl_led_card_valid[card_number])
return -ENXIO; return -ENXIO;
led = &snd_ctl_leds[group]; led = &snd_ctl_leds[group];
repeat: list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
list_for_each_entry(lctl, &led->controls, list)
if (lctl->card == card) { if (lctl->card == card) {
vd = &lctl->kctl->vd[lctl->index_offset]; vd = &lctl->kctl->vd[lctl->index_offset];
vd->access &= ~group_to_access(group); vd->access &= ~group_to_access(group);
snd_ctl_led_ctl_destroy(lctl); snd_ctl_led_ctl_destroy(lctl);
change = true; change = true;
goto repeat;
} }
} }
if (change) if (change)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment