diff mbox series

[net,2/6] can: mcp251xfd: mcp251xfd_probe(): bail out if no IRQ was given

Message ID 20201127100301.512603-3-mkl@pengutronix.de
State Superseded
Headers show
Series pull-request: can 2020-11-27 | expand

Commit Message

Marc Kleine-Budde Nov. 27, 2020, 10:02 a.m. UTC
This patch add a check to the mcp251xfd_probe() function to bail out and give
the user a proper error message if no IRQ is specified. Otherwise the driver
will probe just fine but ifup will fail with a meaningless "RTNETLINK answers:
Invalid argument" error message.

Link: https://lore.kernel.org/r/20201123113522.3820052-1-mkl@pengutronix.de
Reported-by: Niels Petter <petter@ka-long.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Jakub Kicinski Nov. 27, 2020, 7:15 p.m. UTC | #1
On Fri, 27 Nov 2020 11:02:57 +0100 Marc Kleine-Budde wrote:
> This patch add a check to the mcp251xfd_probe() function to bail out and give
> the user a proper error message if no IRQ is specified. Otherwise the driver
> will probe just fine but ifup will fail with a meaningless "RTNETLINK answers:
> Invalid argument" error message.
> 
> Link: https://lore.kernel.org/r/20201123113522.3820052-1-mkl@pengutronix.de
> Reported-by: Niels Petter <petter@ka-long.de>
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
>  drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
> index 9c215f7c5f81..8a39be076e14 100644
> --- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
> +++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
> @@ -2738,6 +2738,10 @@ static int mcp251xfd_probe(struct spi_device *spi)
>  	u32 freq;
>  	int err;
>  
> +	if (!spi->irq)
> +		return dev_err_probe(&spi->dev, -ENXIO,
> +				     "No IRQ specified (maybe node \"interrupts-extended\" 

FWIW this looks like an abuse of dev_err_probe() to me. What's the point
of calling it with a constant err which is not EPROBE_DEFER?
diff mbox series

Patch

diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
index 9c215f7c5f81..8a39be076e14 100644
--- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
+++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
@@ -2738,6 +2738,10 @@  static int mcp251xfd_probe(struct spi_device *spi)
 	u32 freq;
 	int err;
 
+	if (!spi->irq)
+		return dev_err_probe(&spi->dev, -ENXIO,
+				     "No IRQ specified (maybe node \"interrupts-extended\" in DT missing)!\n");
+
 	rx_int = devm_gpiod_get_optional(&spi->dev, "microchip,rx-int",
 					 GPIOD_IN);
 	if (PTR_ERR(rx_int) == -EPROBE_DEFER)