Skip to contentSkip to conversation

usb: phy: msm: devm_ioremap() doesn't return ERR_PTRs

PATCH In review Dan Carpenter 3 participants 4 messages May 14, 2014 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 1400050877.8431.9.camel@iivanov-dev

#1 lore raw

PATCH 1/1 usb: phy: msm: devm_ioremap() doesn't return ERR_PTRs

devm_ioremap() returns a NULL on error so the IS_ERR() check needs to be updated.

Fixes 6b99c68ec1f9 ('usb: phy: msm: Migrate to Managed Device Resource allocation')
drivers/usb/phy/phy-msm-usb.c +2 -2
index c522c4f..bd32257 100644
@@ -1587,8 +1587,8 @@ static int msm_otg_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	motg->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res));
-	if (IS_ERR(motg->regs))
-		return PTR_ERR(motg->regs);
+	if (!motg->regs)
+		return -ENOMEM;
 
 	/*
 	 * NOTE: The PHYs can be multiplexed between the chipidea controller
#2 lore raw
Quoted 11 lines · Dan Carpenter

devm_ioremap() returns a NULL on error so the IS_ERR() check needs to be updated.

Fixes 6b99c68ec1f9 ('usb: phy: msm: Migrate to Managed Device Resource allocation')
drivers/usb/phy/phy-msm-usb.c +0 -0
index c522c4f..bd32257 100644

drivers/usb/phy/phy-msm-usb.c static int msm_otg_probe(struct platform_device *pdev) · line 1591

Quoted 7 lines
drivers/usb/phy/phy-msm-usb.c +2 -2
@@ -1587,8 +1587,8 @@ static int msm_otg_probe(struct platform_device *pdev)
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        motg->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res));
-       if (IS_ERR(motg->regs))
-               return PTR_ERR(motg->regs);
+       if (!motg->regs)
+               return -ENOMEM;

What about doing devm_ioremap_resource() instead?

#3 lore raw
In reply to Dan Carpenter

Hello.

drivers/usb/phy/phy-msm-usb.c static int msm_otg_probe(struct platform_device *pdev) · line 1588

Quoted 13 lines · Dan Carpenter

devm_ioremap() returns a NULL on error so the IS_ERR() check needs to be updated.

Fixes 6b99c68ec1f9 ('usb: phy: msm: Migrate to Managed Device Resource allocation')
drivers/usb/phy/phy-msm-usb.c +0 -0
index c522c4f..bd32257 100644
@@ -1587,8 +1587,8 @@ static int msm_otg_probe(struct platform_device *pdev)
 
  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);

Hm, 'res' can be NULL too, why this isn't checked?

drivers/usb/phy/phy-msm-usb.c static int msm_otg_probe(struct platform_device *pdev) · line 1594

Quoted 8 lines
drivers/usb/phy/phy-msm-usb.c +2 -2
  	motg->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res));
-	if (IS_ERR(motg->regs))
-		return PTR_ERR(motg->regs);
+	if (!motg->regs)
+		return -ENOMEM;
 
  	/*
  	 * NOTE: The PHYs can be multiplexed between the chipidea controller

WBR, Sergei

#4 lore raw
Quoted 16 lines · Sergei Shtylyov

Hello.

Quoted 12 lines · Dan Carpenter

devm_ioremap() returns a NULL on error so the IS_ERR() check needs to be updated.

Fixes 6b99c68ec1f9 ('usb: phy: msm: Migrate to Managed Device Resource allocation')
drivers/usb/phy/phy-msm-usb.c +0 -0
index c522c4f..bd32257 100644
@@ -1587,8 +1587,8 @@ static int msm_otg_probe(struct platform_device *pdev)
 
Quoted 3 lines

drivers/usb/phy/phy-msm-usb.c static int msm_otg_probe(struct platform_device *pdev) · line 1588

Quoted 1 line
drivers/usb/phy/phy-msm-usb.c +0 -0
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);

Hm, 'res' can be NULL too, why this isn't checked?

Yeah. You're right. The correct idiom is to use devm_ioremap_resource() like Fabio says, since it has checking built in. Also the original code was missing a call to a request_mem_region function here but so that's buggy.

Ivan, I am so cross with you right now... *Grumble*.

v2 coming up.

regards,
dan carpenter