Skip to content

Commit be944ce

Browse files
Wolfram Sangwsakernel
authored andcommitted
i2c: rcar: avoid non-standard use of goto
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> Signed-off-by: Wolfram Sang <wsa@kernel.org>
1 parent f78ca48 commit be944ce

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

drivers/i2c/busses/i2c-rcar.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,19 +317,23 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv)
317317
for (scgd = 0; scgd < 0x40; scgd++) {
318318
scl = ick / (20 + (scgd * 8) + round);
319319
if (scl <= t.bus_freq_hz)
320-
goto scgd_find;
320+
break;
321321
}
322-
dev_err(dev, "it is impossible to calculate best SCL\n");
323-
return -EIO;
324322

325-
scgd_find:
323+
if (scgd == 0x40)
324+
goto err_no_val;
325+
326326
dev_dbg(dev, "clk %d/%d(%lu), round %u, CDF:0x%x, SCGD: 0x%x\n",
327327
scl, t.bus_freq_hz, rate, round, cdf, scgd);
328328

329329
/* keep icccr value */
330330
priv->icccr = scgd << cdf_width | cdf;
331331

332332
return 0;
333+
334+
err_no_val:
335+
dev_err(dev, "it is impossible to calculate best SCL\n");
336+
return -EINVAL;
333337
}
334338

335339
/*

0 commit comments

Comments
 (0)