can: mcp251xfd: mcp251xfd_probe(): bail out if no IRQ was given
authorMarc Kleine-Budde <mkl@pengutronix.de>
Sat, 21 Nov 2020 19:14:19 +0000 (20:14 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Thu, 26 Nov 2020 10:50:32 +0000 (11:50 +0100)
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

index 9c215f7c5f81b84652505fb982ab176972875ed9..8a39be076e143e21634b976e9494d986eec3c054 100644 (file)
@@ -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)