* [PATCH] amba: simplify amba_lookup function
@ 2026-08-31 17:31 Alexander Shiyan
0 siblings, 0 replies; only message in thread
From: Alexander Shiyan @ 2026-08-31 17:31 UTC (permalink / raw)
To: barebox; +Cc: Alexander Shiyan
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-31 17:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-31 17:31 [PATCH] amba: simplify amba_lookup function Alexander Shiyan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox