From: Jakob Koschel <jakobkoschel@gmail.com>
To: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>,
linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org,
Mike Rapoport <rppt@kernel.org>,
"Brian Johannesmeyer" <bjohannesmeyer@gmail.com>,
Cristiano Giuffrida <c.giuffrida@vu.nl>,
"Bos, H.J." <h.j.bos@vu.nl>,
Jakob Koschel <jakobkoschel@gmail.com>
Subject: [PATCH] sh: replace usage of found with dedicated list iterator variable
Date: Thu, 24 Mar 2022 08:24:09 +0100 [thread overview]
Message-ID: <20220324072409.62899-1-jakobkoschel@gmail.com> (raw)
To move the list iterator variable into the list_for_each_entry_*()
macro in the future it should be avoided to use the list iterator
variable after the loop body.
To *never* use the list iterator variable after the loop it was
concluded to use a separate iterator variable instead of a
found boolean [1].
This removes the need to use a found variable and simply checking if
the variable was set, can determine if the break/goto was hit.
Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
arch/sh/drivers/dma/dma-api.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/arch/sh/drivers/dma/dma-api.c b/arch/sh/drivers/dma/dma-api.c
index ab9170494dcc..b1a54269b03c 100644
--- a/arch/sh/drivers/dma/dma-api.c
+++ b/arch/sh/drivers/dma/dma-api.c
@@ -127,20 +127,19 @@ static int search_cap(const char **haystack, const char *needle)
*/
int request_dma_bycap(const char **dmac, const char **caps, const char *dev_id)
{
- unsigned int found = 0;
- struct dma_info *info;
+ struct dma_info *info = NULL, *iter;
const char **p;
int i;
BUG_ON(!dmac || !caps);
- list_for_each_entry(info, ®istered_dmac_list, list)
- if (strcmp(*dmac, info->name) == 0) {
- found = 1;
+ list_for_each_entry(iter, ®istered_dmac_list, list)
+ if (strcmp(*dmac, iter->name) == 0) {
+ info = iter;
break;
}
- if (!found)
+ if (!info)
return -ENODEV;
for (i = 0; i < info->nr_channels; i++) {
@@ -242,17 +241,16 @@ EXPORT_SYMBOL(dma_wait_for_completion);
int register_chan_caps(const char *dmac, struct dma_chan_caps *caps)
{
- struct dma_info *info;
- unsigned int found = 0;
+ struct dma_info *info = NULL, *iter;
int i;
- list_for_each_entry(info, ®istered_dmac_list, list)
- if (strcmp(dmac, info->name) == 0) {
- found = 1;
+ list_for_each_entry(iter, ®istered_dmac_list, list)
+ if (strcmp(dmac, iter->name) == 0) {
+ info = iter;
break;
}
- if (unlikely(!found))
+ if (unlikely(!info))
return -ENODEV;
for (i = 0; i < info->nr_channels; i++, caps++) {
base-commit: f443e374ae131c168a065ea1748feac6b2e76613
--
2.25.1
reply other threads:[~2022-03-24 7:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220324072409.62899-1-jakobkoschel@gmail.com \
--to=jakobkoschel@gmail.com \
--cc=bjohannesmeyer@gmail.com \
--cc=c.giuffrida@vu.nl \
--cc=dalias@libc.org \
--cc=h.j.bos@vu.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=rppt@kernel.org \
--cc=ysato@users.sourceforge.jp \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®