Skip to content

Commit

Permalink
can: hi311x: hi3110_can_probe(): convert to use dev_err_probe()
Browse files Browse the repository at this point in the history
When deferred the reason is saved for further debugging. Besides that,
it's fine to call dev_err_probe() in ->probe() when error code is
known. Convert the driver to use dev_err_probe().

Link: https://lore.kernel.org/all/20211206165542.69887-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Andy Shevchenko authored and Marc Kleine-Budde committed Dec 8, 2021
1 parent dc64d98 commit 6a93ea3
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions drivers/net/can/spi/hi311x.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,10 +837,8 @@ static int hi3110_can_probe(struct spi_device *spi)
int ret;

clk = devm_clk_get_optional(&spi->dev, NULL);
if (IS_ERR(clk)) {
dev_err(&spi->dev, "no CAN clock source defined\n");
return PTR_ERR(clk);
}
if (IS_ERR(clk))
return dev_err_probe(dev, PTR_ERR(clk), "no CAN clock source defined\n");

if (clk) {
freq = clk_get_rate(clk);
Expand Down Expand Up @@ -925,9 +923,7 @@ static int hi3110_can_probe(struct spi_device *spi)

ret = hi3110_hw_probe(spi);
if (ret) {
if (ret == -ENODEV)
dev_err(&spi->dev, "Cannot initialize %x. Wrong wiring?\n",
priv->model);
dev_err_probe(dev, ret, "Cannot initialize %x. Wrong wiring?\n", priv->model);
goto error_probe;
}
hi3110_hw_sleep(spi);
Expand All @@ -950,8 +946,7 @@ static int hi3110_can_probe(struct spi_device *spi)
out_free:
free_candev(net);

dev_err(&spi->dev, "Probe failed, err=%d\n", -ret);
return ret;
return dev_err_probe(dev, ret, "Probe failed\n");
}

static int hi3110_can_remove(struct spi_device *spi)
Expand Down

0 comments on commit 6a93ea3

Please sign in to comment.