Skip to contentSkip to conversation

amba: simplify amba_lookup function

PATCH Applied Alexander Shiyan 2 participants 2 messages Aug 31 – Sep 2 Arm primecell bus support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 amba: simplify amba_lookup function

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.

---
 drivers/amba/bus.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/amba/bus.c +3 -6
index 2ac3c0bc29..4a9ab09714 100644
@@ -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)
Signature · 1 line
2.52.0
Applied
#1 lore raw
Quoted 5 lines · 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.

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,

Signature · 1 line
Sascha Hauer <[email protected]>