diff mbox series

[09/15] i2c: busses: owl: Use devm_clk_get_enabled()

Message ID 20230611225702.891856-10-andi.shyti@kernel.org
State New
Headers show
Series i2c: busses: Use devm_clk_get_enabled() | expand

Commit Message

Andi Shyti June 11, 2023, 10:56 p.m. UTC
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: Andreas Färber <afaerber@suse.de>
Cc: Manivannan Sadhasivam <mani@kernel.org>
---
 drivers/i2c/busses/i2c-owl.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

Comments

Wolfram Sang June 23, 2023, 10:19 a.m. UTC | #1
On Mon, Jun 12, 2023 at 12:56:56AM +0200, Andi Shyti wrote:
> 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: Andreas Färber <afaerber@suse.de>
> Cc: Manivannan Sadhasivam <mani@kernel.org>

Applied to for-next, thanks! But I still wonder why this driver does not
have a remove function?
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-owl.c b/drivers/i2c/busses/i2c-owl.c
index 99ddd88949645..5f0ef8c351418 100644
--- a/drivers/i2c/busses/i2c-owl.c
+++ b/drivers/i2c/busses/i2c-owl.c
@@ -461,21 +461,16 @@  static int owl_i2c_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	i2c_dev->clk = devm_clk_get(dev, NULL);
+	i2c_dev->clk = devm_clk_get_enabled(dev, NULL);
 	if (IS_ERR(i2c_dev->clk)) {
-		dev_err(dev, "failed to get clock\n");
+		dev_err(dev, "failed to enable clock\n");
 		return PTR_ERR(i2c_dev->clk);
 	}
 
-	ret = clk_prepare_enable(i2c_dev->clk);
-	if (ret)
-		return ret;
-
 	i2c_dev->clk_rate = clk_get_rate(i2c_dev->clk);
 	if (!i2c_dev->clk_rate) {
 		dev_err(dev, "input clock rate should not be zero\n");
-		ret = -EINVAL;
-		goto disable_clk;
+		return -EINVAL;
 	}
 
 	init_completion(&i2c_dev->msg_complete);
@@ -496,15 +491,10 @@  static int owl_i2c_probe(struct platform_device *pdev)
 			       i2c_dev);
 	if (ret) {
 		dev_err(dev, "failed to request irq %d\n", irq);
-		goto disable_clk;
+		return ret;
 	}
 
 	return i2c_add_adapter(&i2c_dev->adap);
-
-disable_clk:
-	clk_disable_unprepare(i2c_dev->clk);
-
-	return ret;
 }
 
 static const struct of_device_id owl_i2c_of_match[] = {