usb: phy: msm: devm_ioremap() doesn't return ERR_PTRs
Subsystems (2)
PATCH 1/1 usb: phy: msm: devm_ioremap() doesn't return ERR_PTRs
In reply to a message not in the archivedevm_ioremap() returns a NULL on error so the IS_ERR() check needs to be updated.
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 ;/* * NOTE: The PHYs can be multiplexed between the chipidea controller
Quoted 11 lines · Dan Carpenter
devm_ioremap()returns a NULL on error so theIS_ERR()check needs to be updated.Fixes 6b99c68ec1f9 ('usb: phy: msm: Migrate to Managed Device Resource allocation')Signed-off-by Dan Carpenter <[email protected]>drivers/usb/phy/phy-msm-usb.c +0
-0
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?
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 theIS_ERR()check needs to be updated.Fixes 6b99c68ec1f9 ('usb: phy: msm: Migrate to Managed Device Resource allocation')Signed-off-by Dan Carpenter <[email protected]>drivers/usb/phy/phy-msm-usb.c +0
-0@@ -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
-2motg->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
Quoted 16 lines · Sergei Shtylyov
Hello.
Quoted 12 lines · Dan Carpenter
devm_ioremap()returns a NULL on error so theIS_ERR()check needs to be updated.Fixes 6b99c68ec1f9 ('usb: phy: msm: Migrate to Managed Device Resource allocation')Signed-off-by Dan Carpenter <[email protected]>drivers/usb/phy/phy-msm-usb.c +0
-0@@ -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
-0res =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