Skip to content

Commit

Permalink
can: mcp251x: add message about sucessful/unsuccessful probe
Browse files Browse the repository at this point in the history
Silent ignorance of errors during probe procedure is a bad thing, this
patch fixes it. Extra message added for hardware initialization
failure. Such common issues are mostly caused by wrong wiring.  Message
about success added as well, it should be useful to debug new hardware
configuration, especially in case of several CAN buses.

Signed-off-by: Ed Spiridonov <edo.rus@gmail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Ed Spiridonov authored and Marc Kleine-Budde committed Jun 23, 2016
1 parent 926f103 commit b63f69d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/net/can/spi/mcp251x.c
Original file line number Diff line number Diff line change
Expand Up @@ -1145,8 +1145,11 @@ static int mcp251x_can_probe(struct spi_device *spi)

/* Here is OK to not lock the MCP, no one knows about it yet */
ret = mcp251x_hw_probe(spi);
if (ret)
if (ret) {
if (ret == -ENODEV)
dev_err(&spi->dev, "Cannot initialize MCP%x. Wrong wiring?\n", priv->model);
goto error_probe;
}

mcp251x_hw_sleep(spi);

Expand All @@ -1156,6 +1159,7 @@ static int mcp251x_can_probe(struct spi_device *spi)

devm_can_led_init(net);

netdev_info(net, "MCP%x successfully initialized.\n", priv->model);
return 0;

error_probe:
Expand All @@ -1168,6 +1172,7 @@ static int mcp251x_can_probe(struct spi_device *spi)
out_free:
free_candev(net);

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

Expand Down

0 comments on commit b63f69d

Please sign in to comment.