From: Alexander Shiyan <eagle.alexander923@gmail.com>
To: barebox@lists.infradead.org
Cc: Alexander Shiyan <eagle.alexander923@gmail.com>
Subject: [PATCH] amba: simplify amba_lookup function
Date: Mon, 31 Aug 2026 20:31:16 +0300 [thread overview]
Message-ID: <20260831173116.232488-1-eagle.alexander923@gmail.com> (raw)
Remove the unnecessary 'ret' variable and return the matching amba_id
entry directly when the condition is met. This makes the code shorter
and more readable without changing any functional behavior.
Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
drivers/amba/bus.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 2ac3c0bc29..4a9ab09714 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -17,16 +17,13 @@
static const struct amba_id *
amba_lookup(const struct amba_id *table, struct amba_device *dev)
{
- int ret = 0;
-
while (table->mask) {
- ret = (dev->periphid & table->mask) == table->id;
- if (ret)
- break;
+ if (dev->periphid & table->mask == table->id)
+ return table;
table++;
}
- return ret ? table : NULL;
+ return NULL;
}
static int amba_match(struct device *dev, const struct driver *drv)
--
2.52.0
next reply other threads:[~2026-08-31 17:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 17:31 Alexander Shiyan [this message]
2026-09-02 8:34 ` [PATCH] amba: simplify amba_lookup function Sascha Hauer
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=20260831173116.232488-1-eagle.alexander923@gmail.com \
--to=eagle.alexander923@gmail.com \
--cc=barebox@lists.infradead.org \
/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.