Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp3349790rdb; Tue, 29 Aug 2023 12:30:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsLcJmMccqmDtqw/M0e57HR/IL3P6QxODApyjrYo9C9/u4v1y8U5zO4hzENxOHMLU+8itw X-Received: by 2002:a17:902:ec84:b0:1bc:5f27:a20b with SMTP id x4-20020a170902ec8400b001bc5f27a20bmr87270plg.59.1693337432424; Tue, 29 Aug 2023 12:30:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693337432; cv=none; d=google.com; s=arc-20160816; b=D6cJBKsl6HhBBTDux9Lj5aEVKq9x/04XmYigK5aY7yVTGbx928MLiGi9E+Wp7BG7bJ Sl/Kpl8iWhIVYLRmxns4w/GAOXvQB98e5Njc9lrgcRIzin8hdf3JVnpeGr/Opt0IihkI mRFUr6q75iQWTuY18qAjKM4mnXSuNrd2kMUzFAATlOyKnO4kuZ2oEDBqVuunB9J+R6/H /VpiuNa+3E4qhVo0GReMjkCUJFpoDdTCyIxypV+3t4YogCl/5qyxcTPpZmgnVLyod5nb dRnXXEvz2DXcXQjOWOxGp0GAyLKf7junVfJgdvx7/yPEYGw1Y6AogrwDWm02gsBtLoYQ +pRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=HuJwsEjFs3aON1DYkqyWRhvakhtypYRrXkSad5cu0Ho=; fh=7TOOAFGwaU0wWcTGCeAhrYqFZWyaWg7CynfUGxnI3Z0=; b=k8Psejnqj59Iz7Af3lnRWOO0gj2K0AfD0jk5A2bWIiddAvwsnXpTkC8JrgB2cWt41I ExfPWqYfU1ohcVkVE6rdFa0cXjjo61Vz7fbATTvFSSN5LQvK4CYow1HyqmHYPpfmWVkq 2oqYLLxMys4ttFNp4VkCtgVY0kYw82Q/lwTf1Zb2BUfBCtfA/OaTjS1njVOZ9Epusr99 1yYD4lhZ0RXZAbqoFHVC5W7vQiDgUPjA3vp8FJ1ktcsYBpDcS9hMM5/bO12FsG2IrY6/ nQ145oQtf0XZsGAGcpr/6ae2VXDnRfmbScKSSJG5C0Oly3mz792gU8BZm/zYc35cYF0N IXYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=wnrKST8X; dkim=neutral (no key) header.i=@suse.de header.b=tgCqGLmR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g20-20020a170902869400b001bb7b0d358bsi1042934plo.272.2023.08.29.12.29.52; Tue, 29 Aug 2023 12:30:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=wnrKST8X; dkim=neutral (no key) header.i=@suse.de header.b=tgCqGLmR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236753AbjH2ODi (ORCPT + 99 others); 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 >