From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 519CCC71153 for ; Tue, 29 Aug 2023 14:04:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236756AbjH2ODi (ORCPT ); Tue, 29 Aug 2023 10:03:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236772AbjH2ODQ (ORCPT ); Tue, 29 Aug 2023 10:03:16 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 824EFE4F for ; Tue, 29 Aug 2023 07:02:47 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B8DAD1F45B; Tue, 29 Aug 2023 14:02:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1693317758; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HuJwsEjFs3aON1DYkqyWRhvakhtypYRrXkSad5cu0Ho=; b=wnrKST8XzNQfau6PiaYP7/a/I4E4NoYHecflZlPdv45CL6o7T5FDEPOKbpS5wbqgldqurz U3boTQgG7oMHSoWNnEkSS+08P7J9ne7bAqPzuOQ2oD2y4lxvX5IyGzBLM4BxC1haU4lZIm HZs6NDNYlus5DFd1os8tVxGUd6lt1Lw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1693317758; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HuJwsEjFs3aON1DYkqyWRhvakhtypYRrXkSad5cu0Ho=; b=tgCqGLmRL8fGVlha75IM7tlVI8GvC3NKfH+dVv8PFUeLplIrPmbeQTFbUf+ommOKsVJBRx oWbzxFx4mgEOO3Dw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 967AE138E2; Tue, 29 Aug 2023 14:02:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kQPiI3767WTLcAAAMHmgww (envelope-from ); Tue, 29 Aug 2023 14:02:38 +0000 Date: Tue, 29 Aug 2023 16:02:38 +0200 Message-ID: <87ttsit08x.wl-tiwai@suse.de> From: Takashi Iwai To: Andy Shevchenko Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Jaroslav Kysela , Takashi Iwai Subject: Re: [PATCH v1 1/1] ALSA: control: Use list_for_each_entry_safe() In-Reply-To: <20230829135252.3915124-1-andriy.shevchenko@linux.intel.com> References: <20230829135252.3915124-1-andriy.shevchenko@linux.intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 >