amba: simplify amba_lookup function
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.
Signed-off-by Alexander Shiyan <[email protected]>
--- drivers/amba/bus.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/amba/bus.c +3 -6
@@ -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
Sascha Hauer
AppliedQuoted 5 lines · Alexander Shiyan
Remove the unnecessary 'ret' variable and return the matching
amba_identry 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]>