Message ID | 20230906200024.5305-2-wsa+renesas@sang-engineering.com (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Geert Uytterhoeven |
Headers | show |
Series | i2c: clock calculation cleanups for Renesas devices | expand |
On Wed, 6 Sep 2023, Wolfram Sang wrote: > Kernel functions goto somewhere on error conditions. Using goto for the > default path is irritating. Let's bail out on error instead and use a > proper retval. > > Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index a32a93f9a60d..49dfbeebf6b8 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c @@ -317,12 +317,12 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv) for (scgd = 0; scgd < 0x40; scgd++) { scl = ick / (20 + (scgd * 8) + round); if (scl <= t.bus_freq_hz) - goto scgd_find; + break; } - dev_err(dev, "it is impossible to calculate best SCL\n"); - return -EIO; -scgd_find: + if (scgd == 0x40) + goto err_no_val; + dev_dbg(dev, "clk %d/%d(%lu), round %u, CDF:0x%x, SCGD: 0x%x\n", scl, t.bus_freq_hz, rate, round, cdf, scgd); @@ -330,6 +330,10 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv) priv->icccr = scgd << cdf_width | cdf; return 0; + +err_no_val: + dev_err(dev, "it is impossible to calculate best SCL\n"); + return -EINVAL; } /*
Kernel functions goto somewhere on error conditions. Using goto for the default path is irritating. Let's bail out on error instead and use a proper retval. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> --- I dropped the Rev-bys because I think the changes are not trivial. YMMV. drivers/i2c/busses/i2c-rcar.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)