diff mbox series

[1/3] i2c: rcar: avoid non-standard use of goto

Message ID 20230904135852.12146-2-wsa+renesas@sang-engineering.com
State New
Headers show
Series [1/3] i2c: rcar: avoid non-standard use of goto | expand

Commit Message

Wolfram Sang Sept. 4, 2023, 1:58 p.m. UTC
Kernel functions goto somewhere on error conditions. Using goto for the
default path is irritating. Let's bail out on error instead.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/i2c/busses/i2c-rcar.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Andi Shyti Sept. 5, 2023, 11:30 a.m. UTC | #1
Hi Wolfram,

On Mon, Sep 04, 2023 at 03:58:49PM +0200, 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.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Reviewed-by: Andi Shyti <andi.shyti@kernel.org> 

Andi
Geert Uytterhoeven Sept. 6, 2023, 6:57 a.m. UTC | #2
On Tue, Sep 5, 2023 at 6:22 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> Kernel functions goto somewhere on error conditions. Using goto for the
> default path is irritating. Let's bail out on error instead.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 2d9c37410ebd..f2b953df0c4d 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -317,12 +317,14 @@  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;
+	}
+
+	if (scgd == 0x40) {
+		dev_err(dev, "it is impossible to calculate best SCL\n");
+		return -EIO;
 	}
-	dev_err(dev, "it is impossible to calculate best SCL\n");
-	return -EIO;
 
-scgd_find:
 	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);