Skip to contentSkip to conversation

can: mcp251x: add message about sucessful/unsuccessful probe

PATCH Applied Ed Spiridonov 2 participants 2 messages Jun 20, 2016 – Jun 22, 2016 CAN network drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 can: mcp251x: add message about sucessful/unsuccessful probe

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.

---
 drivers/net/can/spi/mcp251x.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/can/spi/mcp251x.c +6 -1
index cf36d26..f3f05fe 100644
@@ -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);
 
@@ -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:
@@ -1168,6 +1172,7 @@ out_clk:
 out_free:
 	free_candev(net);
 
+	dev_err(&spi->dev, "Probe failed, err=%d\n", -ret);
 	return ret;
 }
 
Signature · 1 line
2.8.1
maintainer Applied
#1 lore raw
Quoted 5 lines · Ed Spiridonov

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.

Applied to can-next.

Tnx,
Marc

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |