Skip to contentSkip to conversation

mtd: spi-nor: cqspi: fix error return code in cqspi_probe()

PATCH In review Gustavo A. R. Silva 2 participants 2 messages Aug 9, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: spi-nor: cqspi: fix error return code in cqspi_probe()

platform_get_irq() returns an error code, but the cadence-quadspi driver ignores it and always returns -ENXIO. This is not correct and, prevents -EPROBE_DEFER from being propagated properly.

Print and propagate the return value of platform_get_irq on failure.

This issue was detected with the help of Coccinelle.

---
 drivers/mtd/spi-nor/cadence-quadspi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/spi-nor/cadence-quadspi.c +2 -2
index 53c7d8e..15dacf5 100644
@@ -1202,8 +1202,8 @@ static int cqspi_probe(struct platform_device *pdev)
 	/* Obtain IRQ line. */
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
-		dev_err(dev, "Cannot obtain IRQ.\n");
-		return -ENXIO;
+		dev_err(dev, "Cannot obtain IRQ: %d\n", irq);
+		return irq;
 	}
 
 	ret = clk_prepare_enable(cqspi->clk);
Signature · 1 line
2.5.0
#1 lore raw
Quoted 18 lines · Gustavo A. R. Silva

platform_get_irq() returns an error code, but the cadence-quadspi driver ignores it and always returns -ENXIO. This is not correct and, prevents -EPROBE_DEFER from being propagated properly.

Print and propagate the return value of platform_get_irq on failure.

This issue was detected with the help of Coccinelle.

---
 drivers/mtd/spi-nor/cadence-quadspi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/spi-nor/cadence-quadspi.c +0 -0
index 53c7d8e..15dacf5 100644

drivers/mtd/spi-nor/cadence-quadspi.c static int cqspi_probe(struct platform_device *pdev) · line 1205

Quoted 6 lines
drivers/mtd/spi-nor/cadence-quadspi.c +1 -2
@@ -1202,8 +1202,8 @@ static int cqspi_probe(struct platform_device *pdev)
 	/* Obtain IRQ line. */
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
-		dev_err(dev, "Cannot obtain IRQ.\n");
-		return -ENXIO;
+		dev_err(dev, "Cannot obtain IRQ: %d\n", irq);

"Cannot obtain IRQ, ret=%i\n" please . It's inobvious what the value means otherwise.

Quoted 5 lines
drivers/mtd/spi-nor/cadence-quadspi.c +1 -0
+		return irq;
 	}
 
 	ret = clk_prepare_enable(cqspi->clk);
Signature · 2 lines
Best regards,
Marek Vasut