From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F182A2C9C for ; Mon, 21 Mar 2022 12:37:20 +0000 (UTC) Received: by mail-ed1-f53.google.com with SMTP id t1so17667770edc.3 for ; Mon, 21 Mar 2022 05:37:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bRjhCmUK3oCUee61cBk8RWBfzYem6vzRvo8MfD2Xsek=; b=TXnBWcEzq++rM6dKuuLB6BLFl6gqNs6THIYwaBvze0VDaT1xhchA/2D4sZuvIkC4A+ Na98eVdTzfmRT+t+I3XEOCyQVchH6ujIL7WjDl3me4DULQxxu19jvtZi2Q6a8dieIjwc CpYWth0Ucw5mTFfayzPOTuxgo42NV7t5g8yqnhfxNPpW6ZU9gW68024901NoTsy0WhRk I3xcuC/NPtbSDQHHFRRLSnbe1nszFIcYqVtjCcNoThTcJawdDaiWYritHMJpWrx92OTZ 5YXJbV0IbZvCiVH01JgNGqIR6TfJEiLzTm+CM1eEh/dOGrEPwwlNRSAzc3qVhaZarX/d 8Lbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bRjhCmUK3oCUee61cBk8RWBfzYem6vzRvo8MfD2Xsek=; b=0PckJlJL3NhXPO7pLYTFAYnqhrRIRMPNlv/p73KCpYI/R9+qQLkae3z7f59VrvShVQ H1l3O7zSb1kTn5U0Ov9YFzZnJGJ6SocIgRHbvvhRAUyBb1GyvLFfiQfLX7ONrddQOb7A vL550x4kVvY0hgIMi8EdURIsH0RUt6soRHrndqtngVapOqu0YXIrEAkbCtQaK/YFaZsJ 7OwvW8uiAI8NVMKIP3k2pNAoo0BiBQ57CTrnHHgPG/2hzJT2cIkb0153L0j/lKOxUPdd EmQGAntmDr/zfg+eFqePd2FeQfzsrxt0G3ts4r8HthupKPXvdGTLf1JOP+ifwG3TYbav wixQ== X-Gm-Message-State: AOAM530WePVFRbq8tWlnQYpYE3y+9Sqibbb8q5ARsfXrEbgzP3v1IurJ flX4tlxQWiLVWsjnw/761ns= X-Google-Smtp-Source: ABdhPJxdZNGfZ/MJWrWNAUwKIPsAS8dgeql0tJLH/bNUH2QSyyo1NxAh4EGJxzpnmqzwon6K90lyYg== X-Received: by 2002:a05:6402:3488:b0:419:172c:e287 with SMTP id v8-20020a056402348800b00419172ce287mr14182660edc.87.1647866239250; Mon, 21 Mar 2022 05:37:19 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id g11-20020a170906538b00b006ae38eb0561sm6923828ejo.195.2022.03.21.05.37.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 05:37:18 -0700 (PDT) From: Jakob Koschel To: Vaibhav Agarwal Cc: Jakob Koschel , linux-kernel@vger.kernel.org, greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev, Mark Greer , Johan Hovold , Alex Elder , Greg Kroah-Hartman , Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." Subject: [PATCH] staging: greybus: codecs: use dedicated list iterator variable Date: Mon, 21 Mar 2022 13:37:12 +0100 Message-Id: <20220321123712.3068778-1-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In preparation to limit the scope of the list iterator to the list traversal loop, use a dedicated pointer to point to the found element [1]. Link: https://lore.kernel.org/all/YhdfEIwI4EdtHdym@kroah.com/ Signed-off-by: Jakob Koschel --- drivers/staging/greybus/audio_codec.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c index b589cf6b1d03..a446d6455fbd 100644 --- a/drivers/staging/greybus/audio_codec.c +++ b/drivers/staging/greybus/audio_codec.c @@ -497,7 +497,7 @@ static int gbcodec_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { int ret; - struct gbaudio_module_info *module; + struct gbaudio_module_info *module = NULL, *iter; struct gbaudio_data_connection *data; struct gb_bundle *bundle; struct gbaudio_codec_info *codec = dev_get_drvdata(dai->dev); @@ -511,11 +511,13 @@ static int gbcodec_prepare(struct snd_pcm_substream *substream, return -ENODEV; } - list_for_each_entry(module, &codec->module_list, list) { + list_for_each_entry(iter, &codec->module_list, list) { /* find the dai */ - data = find_data(module, dai->id); - if (data) + data = find_data(iter, dai->id); + if (data) { + module = iter; break; + } } if (!data) { dev_err(dai->dev, "DATA connection missing\n"); @@ -563,7 +565,7 @@ static int gbcodec_mute_stream(struct snd_soc_dai *dai, int mute, int stream) { int ret; struct gbaudio_data_connection *data; - struct gbaudio_module_info *module; + struct gbaudio_module_info *module = NULL, *iter; struct gb_bundle *bundle; struct gbaudio_codec_info *codec = dev_get_drvdata(dai->dev); struct gbaudio_stream_params *params; @@ -592,11 +594,13 @@ static int gbcodec_mute_stream(struct snd_soc_dai *dai, int mute, int stream) return ret; } - list_for_each_entry(module, &codec->module_list, list) { + list_for_each_entry(iter, &codec->module_list, list) { /* find the dai */ - data = find_data(module, dai->id); - if (data) + data = find_data(iter, dai->id); + if (data) { + module = iter; break; + } } if (!data) { dev_err(dai->dev, "%s:%s DATA connection missing\n", base-commit: f443e374ae131c168a065ea1748feac6b2e76613 -- 2.25.1