summaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorWolfram Sang <wsa+renesas@sang-engineering.com>2023-09-06 22:00:19 +0200
committerWolfram Sang <wsa@kernel.org>2023-09-19 11:10:28 +0200
commitbe944ceb6761a6198f5df51c36fd91eb9e112704 (patch)
treebf4025061c99d0e54056f57a32bf71189d004351 /drivers/i2c
parenti2c: i801: fix potential race in i801_block_transaction_byte_by_byte (diff)
downloadlinux-be944ceb6761a6198f5df51c36fd91eb9e112704.tar.xz
linux-be944ceb6761a6198f5df51c36fd91eb9e112704.zip
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>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-rcar.c12
1 files changed, 8 insertions, 4 deletions
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 @@ scgd_find:
priv->icccr = scgd << cdf_width | cdf;
return 0;
+
+err_no_val:
+ dev_err(dev, "it is impossible to calculate best SCL\n");
+ return -EINVAL;
}
/*