Le 05/12/2025 à 17:49, Patrice CHOTARD a écrit :
On 12/5/25 14:36, Richard Genoud wrote:
In stm32_i2c_choose_solution, the double loop continues even after a
solution is found.
Breaking out of this double loop once a solution is found permits to
gain some precious ms.
This saves about 13ms in U-Boot.
Signed-off-by: Richard Genoud <[email protected]>
---
drivers/i2c/stm32f7_i2c.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/i2c/stm32f7_i2c.c b/drivers/i2c/stm32f7_i2c.c
index 3f51b1dd1db4..cb5e2c0e31e5 100644
--- a/drivers/i2c/stm32f7_i2c.c
+++ b/drivers/i2c/stm32f7_i2c.c
@@ -651,11 +651,13 @@ static int stm32_i2c_choose_solution(u32 i2cclk,
v->sclh = h;
sol_found = true;
memcpy(s, v, sizeof(*s));
+ goto end_loop;
}
}
}
}
}
+end_loop:
if (!sol_found) {
log_err("no solution at all\n");
base-commit: c5e6d2ab7eba68cbfb600cdc131c0c375ced2ec9
Hi Richard
If i have well understood the algorithm, the original implementation selects
the *best* solution
whereas with your patch, the algorithm selects the *first* solution.
Patrice
Hum, indeed. The solution with the lesser error is selected.
I'll have to study this algorithm a little bit more to see it we can
take some shortcut.
Thanks!
Regards,
Richard