Skip to content

Commit

Permalink
i2c: at91-core: Use devm_clk_get_enabled()
Browse files Browse the repository at this point in the history
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>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
[wsa: rebased]
Signed-off-by: Wolfram Sang <wsa@kernel.org>
  • Loading branch information
Andi Shyti authored and Wolfram Sang committed Oct 21, 2023
1 parent ba63f99 commit 29c9e85
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions drivers/i2c/busses/i2c-at91-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,10 @@ static int at91_twi_probe(struct platform_device *pdev)

platform_set_drvdata(pdev, dev);

dev->clk = devm_clk_get(dev->dev, NULL);
dev->clk = devm_clk_get_enabled(dev->dev, NULL);
if (IS_ERR(dev->clk))
return dev_err_probe(dev->dev, PTR_ERR(dev->clk), "no clock defined\n");

clk_prepare_enable(dev->clk);
return dev_err_probe(dev->dev, PTR_ERR(dev->clk),
"failed to enable clock\n");

snprintf(dev->adapter.name, sizeof(dev->adapter.name), "AT91");
i2c_set_adapdata(&dev->adapter, dev);
Expand Down Expand Up @@ -254,8 +253,6 @@ static int at91_twi_probe(struct platform_device *pdev)

rc = i2c_add_numbered_adapter(&dev->adapter);
if (rc) {
clk_disable_unprepare(dev->clk);

pm_runtime_disable(dev->dev);
pm_runtime_set_suspended(dev->dev);

Expand All @@ -272,7 +269,6 @@ static void at91_twi_remove(struct platform_device *pdev)
struct at91_twi_dev *dev = platform_get_drvdata(pdev);

i2c_del_adapter(&dev->adapter);
clk_disable_unprepare(dev->clk);

pm_runtime_disable(dev->dev);
pm_runtime_set_suspended(dev->dev);
Expand Down

0 comments on commit 29c9e85

Please sign in to comment.