From: Chaosheng Qu <redacted>
This is a robustness and consistency cleanup, this issue has not been seen
on real hardware.
at91_can_probe() looks up the memory resource and the interrupt together
and collapses both failures into -ENODEV:
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
irq = platform_get_irq(pdev, 0);
if (!res || irq <= 0) {
err = -ENODEV;
goto exit_put;
}
The irq <= 0 test also covers a 0 return, which platform_get_irq() never
produces; it warns and returns -EINVAL instead.
Split the two lookups: the memory resource keeps -ENODEV, the interrupt
returns the lookup error unchanged, as the neighbouring CAN platform
drivers do, e.g. commit ("can: cc770: don't discard the IRQ lookup error in
probe"). This also drops an IRQ lookup that cannot succeed when the memory
resource is missing.
A device tree without an interrupt now reports -ENXIO rather than
-ENODEV; the driver core treats both as a failed probe.
Build tested on x86_64.
Signed-off-by: Chaosheng Qu <redacted>
Link: https://patch.msgid.link/303815792800553c34842147941cab083823c212.1792118040.git.chaosheng.qu.linux@gmail.com (local)
[mkl: update patch description]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/at91_can.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c
index 58da323f14d7..3977de761636 100644
--- a/drivers/net/can/at91_can.c
+++ b/drivers/net/can/at91_can.c
@@ -1069,12 +1069,17 @@ static int at91_can_probe(struct platform_device *pdev)
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- irq = platform_get_irq(pdev, 0);
- if (!res || irq <= 0) {
+ if (!res) {
err = -ENODEV;
goto exit_put;
}
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0) {
+ err = irq;
+ goto exit_put;
+ }
+
if (!request_mem_region(res->start,
resource_size(res),
pdev->name)) {--
2.53.0