Skip to content

Commit

Permalink
i2c: uniphier: 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 ff896ef commit 8a86133
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions drivers/i2c/busses/i2c-uniphier.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,21 +335,16 @@ static int uniphier_i2c_probe(struct platform_device *pdev)
return -EINVAL;
}

priv->clk = devm_clk_get(dev, NULL);
priv->clk = devm_clk_get_enabled(dev, NULL);
if (IS_ERR(priv->clk)) {
dev_err(dev, "failed to get clock\n");
dev_err(dev, "failed to enable clock\n");
return PTR_ERR(priv->clk);
}

ret = clk_prepare_enable(priv->clk);
if (ret)
return ret;

clk_rate = clk_get_rate(priv->clk);
if (!clk_rate) {
dev_err(dev, "input clock rate should not be zero\n");
ret = -EINVAL;
goto disable_clk;
return -EINVAL;
}

priv->clk_cycle = clk_rate / bus_speed;
Expand All @@ -369,23 +364,17 @@ static int uniphier_i2c_probe(struct platform_device *pdev)
priv);
if (ret) {
dev_err(dev, "failed to request irq %d\n", irq);
goto disable_clk;
return ret;
}

ret = i2c_add_adapter(&priv->adap);
disable_clk:
if (ret)
clk_disable_unprepare(priv->clk);

return ret;
return i2c_add_adapter(&priv->adap);
}

static void uniphier_i2c_remove(struct platform_device *pdev)
{
struct uniphier_i2c_priv *priv = platform_get_drvdata(pdev);

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

static int __maybe_unused uniphier_i2c_suspend(struct device *dev)
Expand Down

0 comments on commit 8a86133

Please sign in to comment.