[PATCH 06/15] i2c: busses: jz4780: Use devm_clk_get_enabled()

Andi Shyti
2023-06-11T23:16:26Z

Replace the pair of functions, devm_clk_get() and
clk_prepare_enable(), with a single function
devm_clk_get_enabled().

Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Cc: Paul Cercueil <paul@crapouillou.net>
---
drivers/i2c/busses/i2c-jz4780.c | 25 ++++++-------------------
1 file changed, 6 insertions(+), 19 deletions(-)

diff --git a/drivers/i2c/busses/i2c-jz4780.c b/drivers/i2c/busses/i2c-jz4780.c
index 0dfe603995214..7f21611ca3262 100644
--- a/drivers/i2c/busses/i2c-jz4780.c
+++ b/drivers/i2c/busses/i2c-jz4780.c
@@ -792,26 +792,21 @@ static int jz4780_i2c_probe(struct platform_device *pdev)

platform_set_drvdata(pdev, i2c);

- i2c->clk = devm_clk_get(&pdev->dev, NULL);
+ i2c->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(i2c->clk))
return PTR_ERR(i2c->clk);

- ret = clk_prepare_enable(i2c->clk);
- if (ret)
- return ret;
-
ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency",
&clk_freq);
if (ret) {
dev_err(&pdev->dev, "clock-frequency not specified in DT\n");
- goto err;
+ return ret;
}

i2c->speed = clk_freq / 1000;
if (i2c->speed == 0) {
- ret = -EINVAL;
dev_err(&pdev->dev, "clock-frequency minimum is 1000\n");
- goto err;
+ return -EINVAL;
}
jz4780_i2c_set_speed(i2c);

@@ -827,22 +822,14 @@ static int jz4780_i2c_probe(struct platform_device *pdev)

ret = platform_get_irq(pdev, 0);
if (ret < 0)
- goto err;
+ return ret;
i2c->irq = ret;
ret = devm_request_irq(&pdev->dev, i2c->irq, jz4780_i2c_irq, 0,
dev_name(&pdev->dev), i2c);
if (ret)
- goto err;
-
- ret = i2c_add_adapter(&i2c->adap);
- if (ret < 0)
- goto err;
-
- return 0;
+ return ret;

-err:
- clk_disable_unprepare(i2c->clk);
- return ret;
+ return i2c_add_adapter(&i2c->adap);
}

static void jz4780_i2c_remove(struct platform_device *pdev)
--
2.40.1