public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/1] ALSA: control: Use list_for_each_entry_safe()
@ 2024-04-23 21:10 Andy Shevchenko
  2024-04-24  7:24 ` Takashi Iwai
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2024-04-23 21:10 UTC (permalink / raw)
  To: Takashi Iwai, linux-sound, linux-kernel
  Cc: Jaroslav Kysela, Takashi Iwai, Andy Shevchenko

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>
---
v2: added tag (Jaroslav)
 sound/core/control_led.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/sound/core/control_led.c b/sound/core/control_led.c
index 061a8ea23340..ea95405c76a4 100644
--- a/sound/core/control_led.c
+++ b/sound/core/control_led.c
@@ -290,16 +290,13 @@ static void snd_ctl_led_clean(struct snd_card *card)
 {
 	unsigned int group;
 	struct snd_ctl_led *led;
-	struct snd_ctl_led_ctl *lctl;
+	struct snd_ctl_led_ctl *lctl, *_lctl;
 
 	for (group = 0; group < MAX_LED; group++) {
 		led = &snd_ctl_leds[group];
-repeat:
-		list_for_each_entry(lctl, &led->controls, list)
-			if (!card || lctl->card == card) {
+		list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
+			if (!card || lctl->card == card)
 				snd_ctl_led_ctl_destroy(lctl);
-				goto repeat;
-			}
 	}
 }
 
-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH v2 1/1] ALSA: control: Use list_for_each_entry_safe()
@ 2023-08-29 14:23 Andy Shevchenko
  2023-08-29 17:50 ` kernel test robot
  2023-08-29 19:55 ` kernel test robot
  0 siblings, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2023-08-29 14:23 UTC (permalink / raw)
  To: alsa-devel, linux-kernel; +Cc: Jaroslav Kysela, Takashi Iwai, Andy Shevchenko

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>
---
v2: fixed a typo (Jaroslav), added tag (Jaroslav)
 sound/core/control_led.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/sound/core/control_led.c b/sound/core/control_led.c
index a78eb48927c7..43ea995c095a 100644
--- a/sound/core/control_led.c
+++ b/sound/core/control_led.c
@@ -297,16 +297,13 @@ static void snd_ctl_led_clean(struct snd_card *card)
 {
 	unsigned int group;
 	struct snd_ctl_led *led;
-	struct snd_ctl_led_ctl *lctl;
+	struct snd_ctl_led_ctl *lctl, _lctl;
 
 	for (group = 0; group < MAX_LED; group++) {
 		led = &snd_ctl_leds[group];
-repeat:
-		list_for_each_entry(lctl, &led->controls, list)
-			if (!card || lctl->card == card) {
+		list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
+			if (!card || lctl->card == card)
 				snd_ctl_led_ctl_destroy(lctl);
-				goto repeat;
-			}
 	}
 }
 
@@ -314,7 +311,7 @@ static int snd_ctl_led_reset(int card_number, unsigned int group)
 {
 	struct snd_card *card;
 	struct snd_ctl_led *led;
-	struct snd_ctl_led_ctl *lctl;
+	struct snd_ctl_led_ctl *lctl, _lctl;
 	struct snd_kcontrol_volatile *vd;
 	bool change = false;
 
@@ -329,14 +326,12 @@ static int snd_ctl_led_reset(int card_number, unsigned int group)
 		return -ENXIO;
 	}
 	led = &snd_ctl_leds[group];
-repeat:
-	list_for_each_entry(lctl, &led->controls, list)
+	list_for_each_entry_safe(lctl, _lctl, &led->controls, list)
 		if (lctl->card == card) {
 			vd = &lctl->kctl->vd[lctl->index_offset];
 			vd->access &= ~group_to_access(group);
 			snd_ctl_led_ctl_destroy(lctl);
 			change = true;
-			goto repeat;
 		}
 	mutex_unlock(&snd_ctl_led_mutex);
 	if (change)
-- 
2.40.0.1.gaa8946217a0b


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-04-24 14:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-23 21:10 [PATCH v2 1/1] ALSA: control: Use list_for_each_entry_safe() Andy Shevchenko
2024-04-24  7:24 ` Takashi Iwai
2024-04-24 14:49   ` Andy Shevchenko
  -- strict thread matches above, loose matches on Subject: below --
2023-08-29 14:23 Andy Shevchenko
2023-08-29 17:50 ` kernel test robot
2023-08-29 19:55 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox