Skip to content

Commit

Permalink
i2c: lpc2k: 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>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
  • Loading branch information
Andi Shyti authored and Wolfram Sang committed Jun 23, 2023
1 parent 2153244 commit 9d8b7b6
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions drivers/i2c/busses/i2c-lpc2k.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,23 +365,17 @@ static int i2c_lpc2k_probe(struct platform_device *pdev)

init_waitqueue_head(&i2c->wait);

i2c->clk = devm_clk_get(&pdev->dev, NULL);
i2c->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(i2c->clk)) {
dev_err(&pdev->dev, "error getting clock\n");
dev_err(&pdev->dev, "failed to enable clock.\n");
return PTR_ERR(i2c->clk);
}

ret = clk_prepare_enable(i2c->clk);
if (ret) {
dev_err(&pdev->dev, "unable to enable clock.\n");
return ret;
}

ret = devm_request_irq(&pdev->dev, i2c->irq, i2c_lpc2k_handler, 0,
dev_name(&pdev->dev), i2c);
if (ret < 0) {
dev_err(&pdev->dev, "can't request interrupt.\n");
goto fail_clk;
return ret;
}

disable_irq_nosync(i2c->irq);
Expand All @@ -397,8 +391,7 @@ static int i2c_lpc2k_probe(struct platform_device *pdev)
clkrate = clk_get_rate(i2c->clk);
if (clkrate == 0) {
dev_err(&pdev->dev, "can't get I2C base clock\n");
ret = -EINVAL;
goto fail_clk;
return -EINVAL;
}

/* Setup I2C dividers to generate clock with proper duty cycle */
Expand All @@ -424,23 +417,18 @@ static int i2c_lpc2k_probe(struct platform_device *pdev)

ret = i2c_add_adapter(&i2c->adap);
if (ret < 0)
goto fail_clk;
return ret;

dev_info(&pdev->dev, "LPC2K I2C adapter\n");

return 0;

fail_clk:
clk_disable_unprepare(i2c->clk);
return ret;
}

static void i2c_lpc2k_remove(struct platform_device *dev)
{
struct lpc2k_i2c *i2c = platform_get_drvdata(dev);

i2c_del_adapter(&i2c->adap);
clk_disable_unprepare(i2c->clk);
}

#ifdef CONFIG_PM
Expand Down

0 comments on commit 9d8b7b6

Please sign in to comment.