diff mbox series

[02/15] i2c: busses: xiic: Use devm_clk_get_enabled()

Message ID 20230611225702.891856-3-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: Michal Simek <michal.simek@amd.com>
---
 drivers/i2c/busses/i2c-xiic.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

Comments

Michal Simek June 12, 2023, 8:07 a.m. UTC | #1
On 6/12/23 00:56, 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: Michal Simek <michal.simek@amd.com>
> ---
>   drivers/i2c/busses/i2c-xiic.c | 20 +++++++-------------
>   1 file changed, 7 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
> index 61288f8dd0672..f879af4def5ed 100644
> --- a/drivers/i2c/busses/i2c-xiic.c
> +++ b/drivers/i2c/busses/i2c-xiic.c
> @@ -1256,16 +1256,11 @@ static int xiic_i2c_probe(struct platform_device *pdev)
>   
>   	mutex_init(&i2c->lock);
>   
> -	i2c->clk = devm_clk_get(&pdev->dev, NULL);
> +	i2c->clk = devm_clk_get_enabled(&pdev->dev, NULL);
>   	if (IS_ERR(i2c->clk))
>   		return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk),
> -				     "input clock not found.\n");
> +				     "failed to enable input clock.\n");
>   
> -	ret = clk_prepare_enable(i2c->clk);
> -	if (ret) {
> -		dev_err(&pdev->dev, "Unable to enable clock.\n");
> -		return ret;
> -	}
>   	i2c->dev = &pdev->dev;
>   	pm_runtime_set_autosuspend_delay(i2c->dev, XIIC_PM_TIMEOUT);
>   	pm_runtime_use_autosuspend(i2c->dev);
> @@ -1286,7 +1281,7 @@ static int xiic_i2c_probe(struct platform_device *pdev)
>   
>   	if (ret < 0) {
>   		dev_err(&pdev->dev, "Cannot claim IRQ\n");
> -		goto err_clk_dis;
> +		goto err_pm_disable;
>   	}
>   
>   	i2c->singlemaster =
> @@ -1307,14 +1302,14 @@ static int xiic_i2c_probe(struct platform_device *pdev)
>   	ret = xiic_reinit(i2c);
>   	if (ret < 0) {
>   		dev_err(&pdev->dev, "Cannot xiic_reinit\n");
> -		goto err_clk_dis;
> +		goto err_pm_disable;
>   	}
>   
>   	/* add i2c adapter to i2c tree */
>   	ret = i2c_add_adapter(&i2c->adap);
>   	if (ret) {
>   		xiic_deinit(i2c);
> -		goto err_clk_dis;
> +		goto err_pm_disable;
>   	}
>   
>   	if (pdata) {
> @@ -1328,10 +1323,10 @@ static int xiic_i2c_probe(struct platform_device *pdev)
>   
>   	return 0;
>   
> -err_clk_dis:
> +err_pm_disable:
>   	pm_runtime_set_suspended(&pdev->dev);
>   	pm_runtime_disable(&pdev->dev);
> -	clk_disable_unprepare(i2c->clk);
> +
>   	return ret;
>   }
>   
> @@ -1352,7 +1347,6 @@ static void xiic_i2c_remove(struct platform_device *pdev)
>   		xiic_deinit(i2c);
>   
>   	pm_runtime_put_sync(i2c->dev);
> -	clk_disable_unprepare(i2c->clk);
>   	pm_runtime_disable(&pdev->dev);
>   	pm_runtime_set_suspended(&pdev->dev);
>   	pm_runtime_dont_use_autosuspend(&pdev->dev);

Acked-by: Michal Simek <michal.simek@amd.com>

Thanks,
Michal
Wolfram Sang June 23, 2023, 9:54 a.m. UTC | #2
On Mon, Jun 12, 2023 at 12:56:49AM +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: Michal Simek <michal.simek@amd.com>

Applied to for-next, thanks! No need for 'busses' in $subject, tough. I
removed it while applying.
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 61288f8dd0672..f879af4def5ed 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -1256,16 +1256,11 @@  static int xiic_i2c_probe(struct platform_device *pdev)
 
 	mutex_init(&i2c->lock);
 
-	i2c->clk = devm_clk_get(&pdev->dev, NULL);
+	i2c->clk = devm_clk_get_enabled(&pdev->dev, NULL);
 	if (IS_ERR(i2c->clk))
 		return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk),
-				     "input clock not found.\n");
+				     "failed to enable input clock.\n");
 
-	ret = clk_prepare_enable(i2c->clk);
-	if (ret) {
-		dev_err(&pdev->dev, "Unable to enable clock.\n");
-		return ret;
-	}
 	i2c->dev = &pdev->dev;
 	pm_runtime_set_autosuspend_delay(i2c->dev, XIIC_PM_TIMEOUT);
 	pm_runtime_use_autosuspend(i2c->dev);
@@ -1286,7 +1281,7 @@  static int xiic_i2c_probe(struct platform_device *pdev)
 
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Cannot claim IRQ\n");
-		goto err_clk_dis;
+		goto err_pm_disable;
 	}
 
 	i2c->singlemaster =
@@ -1307,14 +1302,14 @@  static int xiic_i2c_probe(struct platform_device *pdev)
 	ret = xiic_reinit(i2c);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Cannot xiic_reinit\n");
-		goto err_clk_dis;
+		goto err_pm_disable;
 	}
 
 	/* add i2c adapter to i2c tree */
 	ret = i2c_add_adapter(&i2c->adap);
 	if (ret) {
 		xiic_deinit(i2c);
-		goto err_clk_dis;
+		goto err_pm_disable;
 	}
 
 	if (pdata) {
@@ -1328,10 +1323,10 @@  static int xiic_i2c_probe(struct platform_device *pdev)
 
 	return 0;
 
-err_clk_dis:
+err_pm_disable:
 	pm_runtime_set_suspended(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-	clk_disable_unprepare(i2c->clk);
+
 	return ret;
 }
 
@@ -1352,7 +1347,6 @@  static void xiic_i2c_remove(struct platform_device *pdev)
 		xiic_deinit(i2c);
 
 	pm_runtime_put_sync(i2c->dev);
-	clk_disable_unprepare(i2c->clk);
 	pm_runtime_disable(&pdev->dev);
 	pm_runtime_set_suspended(&pdev->dev);
 	pm_runtime_dont_use_autosuspend(&pdev->dev);