mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] amba: simplify amba_lookup function
@ 2026-08-31 17:31 Alexander Shiyan
  2026-09-02  8:34 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages 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] 2+ messages in thread

* Re: [PATCH] amba: simplify amba_lookup function
  2026-08-31 17:31 [PATCH] amba: simplify amba_lookup function Alexander Shiyan
@ 2026-09-02  8:34 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2026-09-02  8:34 UTC (permalink / raw)
  To: barebox, Alexander Shiyan


On Mon, 31 Aug 2026 20:31:16 +0300, Alexander Shiyan wrote:
> 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.
> 
> 

Applied, thanks!

[1/1] amba: simplify amba_lookup function
      https://git.pengutronix.de/cgit/barebox/commit/?id=611a63bcfaf8 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-02  8:35 UTC | newest]

Thread overview: 2+ messages (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
2026-09-02  8:34 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox