diff mbox series

[10/15] i2c: busses: pasemi-platform: Use devm_clk_get_enabled()

Message ID 20230611225702.891856-11-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: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Hector Martin <marcan@marcan.st>
Cc: Sven Peter <sven@svenpeter.dev>
Cc: Alyssa Rosenzweig <alyssa@rosenzweig.io>
---
 drivers/i2c/busses/i2c-pasemi-platform.c | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

Comments

Alyssa Rosenzweig June 12, 2023, 12:58 p.m. UTC | #1
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>

June 11, 2023 6:56 PM, "Andi Shyti" <andi.shyti@kernel.org> 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: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Cc: Hector Martin <marcan@marcan.st>
> Cc: Sven Peter <sven@svenpeter.dev>
> Cc: Alyssa Rosenzweig <alyssa@rosenzweig.io>
> ---
> drivers/i2c/busses/i2c-pasemi-platform.c | 22 ++++------------------
> 1 file changed, 4 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-pasemi-platform.c b/drivers/i2c/busses/i2c-pasemi-platform.c
> index 0a44f64897c7a..5fbfb9b417440 100644
> --- a/drivers/i2c/busses/i2c-pasemi-platform.c
> +++ b/drivers/i2c/busses/i2c-pasemi-platform.c
> @@ -66,22 +66,18 @@ static int pasemi_platform_i2c_probe(struct platform_device *pdev)
> if (of_property_read_u32(dev->of_node, "clock-frequency", &frequency))
> frequency = I2C_MAX_STANDARD_MODE_FREQ;
> 
> - data->clk_ref = devm_clk_get(dev, NULL);
> + data->clk_ref = devm_clk_get_enabled(dev, NULL);
> if (IS_ERR(data->clk_ref))
> return PTR_ERR(data->clk_ref);
> 
> - error = clk_prepare_enable(data->clk_ref);
> - if (error)
> - return error;
> -
> error = pasemi_platform_i2c_calc_clk_div(data, frequency);
> if (error)
> - goto out_clk_disable;
> + return error;
> 
> smbus->adapter.dev.of_node = pdev->dev.of_node;
> error = pasemi_i2c_common_probe(smbus);
> if (error)
> - goto out_clk_disable;
> + return error;
> 
> irq_num = platform_get_irq(pdev, 0);
> error = devm_request_irq(smbus->dev, irq_num, pasemi_irq_handler, 0, "pasemi_apple_i2c", (void
> *)smbus);
> @@ -91,19 +87,9 @@ static int pasemi_platform_i2c_probe(struct platform_device *pdev)
> platform_set_drvdata(pdev, data);
> 
> return 0;
> -
> -out_clk_disable:
> - clk_disable_unprepare(data->clk_ref);
> -
> - return error;
> }
> 
> -static void pasemi_platform_i2c_remove(struct platform_device *pdev)
> -{
> - struct pasemi_platform_i2c_data *data = platform_get_drvdata(pdev);
> -
> - clk_disable_unprepare(data->clk_ref);
> -}
> +static void pasemi_platform_i2c_remove(struct platform_device *pdev) { }
> 
> static const struct of_device_id pasemi_platform_i2c_of_match[] = {
> { .compatible = "apple,t8103-i2c" },
> -- 
> 2.40.1
Wolfram Sang June 23, 2023, 9:56 a.m. UTC | #2
On Mon, Jun 12, 2023 at 12:56:57AM +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: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Cc: Hector Martin <marcan@marcan.st>
> Cc: Sven Peter <sven@svenpeter.dev>
> Cc: Alyssa Rosenzweig <alyssa@rosenzweig.io>

Applied to for-next, thanks!
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-pasemi-platform.c b/drivers/i2c/busses/i2c-pasemi-platform.c
index 0a44f64897c7a..5fbfb9b417440 100644
--- a/drivers/i2c/busses/i2c-pasemi-platform.c
+++ b/drivers/i2c/busses/i2c-pasemi-platform.c
@@ -66,22 +66,18 @@  static int pasemi_platform_i2c_probe(struct platform_device *pdev)
 	if (of_property_read_u32(dev->of_node, "clock-frequency", &frequency))
 		frequency = I2C_MAX_STANDARD_MODE_FREQ;
 
-	data->clk_ref = devm_clk_get(dev, NULL);
+	data->clk_ref = devm_clk_get_enabled(dev, NULL);
 	if (IS_ERR(data->clk_ref))
 		return PTR_ERR(data->clk_ref);
 
-	error = clk_prepare_enable(data->clk_ref);
-	if (error)
-		return error;
-
 	error = pasemi_platform_i2c_calc_clk_div(data, frequency);
 	if (error)
-		goto out_clk_disable;
+		return error;
 
 	smbus->adapter.dev.of_node = pdev->dev.of_node;
 	error = pasemi_i2c_common_probe(smbus);
 	if (error)
-		goto out_clk_disable;
+		return error;
 
 	irq_num = platform_get_irq(pdev, 0);
 	error = devm_request_irq(smbus->dev, irq_num, pasemi_irq_handler, 0, "pasemi_apple_i2c", (void *)smbus);
@@ -91,19 +87,9 @@  static int pasemi_platform_i2c_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, data);
 
 	return 0;
-
-out_clk_disable:
-	clk_disable_unprepare(data->clk_ref);
-
-	return error;
 }
 
-static void pasemi_platform_i2c_remove(struct platform_device *pdev)
-{
-	struct pasemi_platform_i2c_data *data = platform_get_drvdata(pdev);
-
-	clk_disable_unprepare(data->clk_ref);
-}
+static void pasemi_platform_i2c_remove(struct platform_device *pdev) { }
 
 static const struct of_device_id pasemi_platform_i2c_of_match[] = {
 	{ .compatible = "apple,t8103-i2c" },