Skip to contentSkip to conversation

spi: bcm63xx-hsspi: checking for ERR_PTR instead of NULL

PATCH Superseded Dan Carpenter 3 participants 6 messages Dec 6, 2013 – Dec 9, 2013 3 messages not in the archive

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

PATCH 1/1 spi: bcm63xx-hsspi: checking for ERR_PTR instead of NULL

devm_request_and_ioremap() returns NULL on error, it doesn't return an ERR_PTR().

Fixes 142168eba9dc ('spi: bcm63xx-hsspi: add bcm63xx HSSPI driver')
drivers/spi/spi-bcm63xx-hsspi.c +2 -2
index bc8d848d33b7..da9f85d55c81 100644
@@ -339,8 +339,8 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
 
 	res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	regs = devm_request_and_ioremap(dev, res_mem);
-	if (IS_ERR(regs))
-		return PTR_ERR(regs);
+	if (!regs)
+		return -EADDRNOTAVAIL;
 
 	clk = clk_get(dev, "hsspi");
 

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 11 lines · Dan Carpenter

devm_request_and_ioremap() returns NULL on error, it doesn't return an ERR_PTR().

Fixes 142168eba9dc ('spi: bcm63xx-hsspi: add bcm63xx HSSPI driver')
drivers/spi/spi-bcm63xx-hsspi.c +0 -0
index bc8d848d33b7..da9f85d55c81 100644

drivers/spi/spi-bcm63xx-hsspi.c static int bcm63xx_hsspi_probe(struct platform_device *pdev) · line 343

Quoted 7 lines
drivers/spi/spi-bcm63xx-hsspi.c +2 -2
@@ -339,8 +339,8 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
 
        res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        regs = devm_request_and_ioremap(dev, res_mem);
-       if (IS_ERR(regs))
-               return PTR_ERR(regs);
+       if (!regs)
+               return -EADDRNOTAVAIL;

Instead of fixing the wrong handling of the return value, let's change it to use devm_ioremap_resource() which actually returns the expected ERR_PTR() and is preferred over request_and_ioremap().

Regards
Jonas

#3 lore raw
Quoted 13 lines · Jonas Gorski
Quoted 12 lines · Dan Carpenter

devm_request_and_ioremap() returns NULL on error, it doesn't return an ERR_PTR().

Fixes 142168eba9dc ('spi: bcm63xx-hsspi: add bcm63xx HSSPI driver')
drivers/spi/spi-bcm63xx-hsspi.c +0 -0
index bc8d848d33b7..da9f85d55c81 100644
@@ -339,8 +339,8 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
 
Quoted 11 lines

drivers/spi/spi-bcm63xx-hsspi.c static int bcm63xx_hsspi_probe(struct platform_device *pdev) · line 343

Quoted 6 lines
drivers/spi/spi-bcm63xx-hsspi.c +2 -2
        res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        regs = devm_request_and_ioremap(dev, res_mem);
-       if (IS_ERR(regs))
-               return PTR_ERR(regs);
+       if (!regs)
+               return -EADDRNOTAVAIL;

Instead of fixing the wrong handling of the return value, let's change it to use devm_ioremap_resource() which actually returns the expected ERR_PTR() and is preferred over request_and_ioremap().

Sure. I'll resend a v2.

regards,
dan carpenter

A message that is not in the archive (sent off-list or not yet received): CAOiHx=k87c_bFqFtJ7zJc9HxnjOEr2oMofNUsLkQbfQPrC04hQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#5 lore raw

PATCH v2 1/1 spi: bcm63xx-hsspi: checking for ERR_PTR instead of NULL

devm_request_and_ioremap() returns NULL on error, it doesn't return an ERR_PTR(). This patch fixes it by switching to devm_ioremap_resource() which is the prefered function anyway.

Fixes 142168eba9dc ('spi: bcm63xx-hsspi: add bcm63xx HSSPI driver')

---
v2: switch to devm_ioremap_resource()

drivers/spi/spi-bcm63xx-hsspi.c +1 -1
index bc8d848d33b7..2cfe8eb619fd 100644
@@ -338,7 +338,7 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
 	}
 
 	res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	regs = devm_request_and_ioremap(dev, res_mem);
+	regs = devm_ioremap_resource(dev, res_mem);
 	if (IS_ERR(regs))
 		return PTR_ERR(regs);
 

A message that is not in the archive (sent off-list or not yet received): [email protected]

Acked-by
#7 lore raw
Quoted 6 lines · Dan Carpenter

devm_request_and_ioremap() returns NULL on error, it doesn't return an ERR_PTR(). This patch fixes it by switching to devm_ioremap_resource() which is the prefered function anyway.

Fixes 142168eba9dc ('spi: bcm63xx-hsspi: add bcm63xx HSSPI driver')

Thanks.

Jonas

Quoted 20 lines

---
v2: switch to devm_ioremap_resource()

drivers/spi/spi-bcm63xx-hsspi.c +1 -2
index bc8d848d33b7..2cfe8eb619fd 100644
@@ -338,7 +338,7 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
        }
 
        res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       regs = devm_request_and_ioremap(dev, res_mem);
+       regs = devm_ioremap_resource(dev, res_mem);
        if (IS_ERR(regs))
                return PTR_ERR(regs);
 
--

To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer Applied
#8 lore raw
In reply to Dan Carpenter
Quoted 3 lines · Dan Carpenter

devm_request_and_ioremap() returns NULL on error, it doesn't return an ERR_PTR(). This patch fixes it by switching to devm_ioremap_resource() which is the prefered function anyway.

Applied, thanks.