Commit 369cf4e6 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Marc Kleine-Budde

can: hi311x: hi3110_can_probe(): use devm_clk_get_optional() to get the input clock

It's not clear what was the intention of redundant usage of IS_ERR()
around the clock pointer since with the error check of devm_clk_get()
followed by bailout it can't be invalid,

Simplify the code which fetches the input clock by using
devm_clk_get_optional(). It will allow to switch to device properties
approach in the future.

Link: https://lore.kernel.org/all/20211206165542.69887-1-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 671f852c
...@@ -835,7 +835,7 @@ static int hi3110_can_probe(struct spi_device *spi) ...@@ -835,7 +835,7 @@ static int hi3110_can_probe(struct spi_device *spi)
struct clk *clk; struct clk *clk;
int freq, ret; int freq, ret;
clk = devm_clk_get(&spi->dev, NULL); clk = devm_clk_get_optional(&spi->dev, NULL);
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
dev_err(&spi->dev, "no CAN clock source defined\n"); dev_err(&spi->dev, "no CAN clock source defined\n");
return PTR_ERR(clk); return PTR_ERR(clk);
...@@ -851,11 +851,9 @@ static int hi3110_can_probe(struct spi_device *spi) ...@@ -851,11 +851,9 @@ static int hi3110_can_probe(struct spi_device *spi)
if (!net) if (!net)
return -ENOMEM; return -ENOMEM;
if (!IS_ERR(clk)) {
ret = clk_prepare_enable(clk); ret = clk_prepare_enable(clk);
if (ret) if (ret)
goto out_free; goto out_free;
}
net->netdev_ops = &hi3110_netdev_ops; net->netdev_ops = &hi3110_netdev_ops;
net->flags |= IFF_ECHO; net->flags |= IFF_ECHO;
...@@ -938,7 +936,6 @@ static int hi3110_can_probe(struct spi_device *spi) ...@@ -938,7 +936,6 @@ static int hi3110_can_probe(struct spi_device *spi)
hi3110_power_enable(priv->power, 0); hi3110_power_enable(priv->power, 0);
out_clk: out_clk:
if (!IS_ERR(clk))
clk_disable_unprepare(clk); clk_disable_unprepare(clk);
out_free: out_free:
...@@ -957,7 +954,6 @@ static int hi3110_can_remove(struct spi_device *spi) ...@@ -957,7 +954,6 @@ static int hi3110_can_remove(struct spi_device *spi)
hi3110_power_enable(priv->power, 0); hi3110_power_enable(priv->power, 0);
if (!IS_ERR(priv->clk))
clk_disable_unprepare(priv->clk); clk_disable_unprepare(priv->clk);
free_candev(net); free_candev(net);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment