All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Subject: Re: [PATCH v1 1/1] ALSA: control: Use list_for_each_entry_safe()
Date: Tue, 29 Aug 2023 16:02:38 +0200	[thread overview]
Message-ID: <87ttsit08x.wl-tiwai@suse.de> (raw)
In-Reply-To: <20230829135252.3915124-1-andriy.shevchenko@linux.intel.com>

On Tue, 29 Aug 2023 15:52:52 +0200,
Andy Shevchenko wrote:
> 
> 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>

Through a quick glance, it should be OK, but I need to read and
understand whether this change is perfectly safe or not -- unless
Jaroslav gives his review and ack.

> ---
> 
> Takashi, if you have anybody or want yourself to spend some time,
> I believe you can simplify a lot the parser in this file with
> the help of lib/cmdline.c APIs.

Thanks for the hint.  Yeah, it looks feasible, but too late for 6.6,
it's a nice TODO ;)


Takashi

> 
>  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..afc9ffc388e3 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(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
> 

  reply	other threads:[~2023-08-29 14:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-29 13:52 [PATCH v1 1/1] ALSA: control: Use list_for_each_entry_safe() Andy Shevchenko
2023-08-29 14:02 ` Takashi Iwai [this message]
2023-08-29 14:16   ` Andy Shevchenko
2023-08-29 14:10 ` Jaroslav Kysela
2023-08-29 14:20   ` Andy Shevchenko
2023-08-29 15:55 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ttsit08x.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.