usb: phy: msm: change devm_ioremap() to devm_ioremap_resource()
Subsystems (2)
PATCH v2 1/1 usb: phy: msm: change devm_ioremap() to devm_ioremap_resource()
There are several issues here:
1) platform_get_resource() can return NULL and that wasn't handled.
2) We should request the memory before we remap it, and devm_ioremap_resource() does that.
3) devm_ioremap() returns a NULL but we were checking for IS_ERR().
---
v2: the first version just swapped the IS_ERR() check for a NULL check
Thanks everyone for the review. In the end, it was still a one line fix so I forgive you Ivan.
drivers/usb/phy/phy-msm-usb.c +1 -1
@@ -1586,7 +1586,7 @@ static int msm_otg_probe(struct platform_device *pdev) np ? "alt_core" : "usb_hs_core_clk"); res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - motg->regs =devm_ioremap (&pdev->dev, res->start,resource_size (res)); + motg->regs =devm_ioremap_resource (&pdev->dev, res);if (IS_ERR (motg->regs))return PTR_ERR (motg->regs);
Quoted 19 lines · Dan Carpenter
There are several issues here:
1)platform_get_resource()can return NULL and that wasn't handled.
2) We should request the memory before we remap it, anddevm_ioremap_resource()does that.
3)devm_ioremap()returns a NULL but we were checking forIS_ERR().Fixes 6b99c68ec1f9 ('usb: phy: msm: Migrate to Managed Device Resource allocation')Signed-off-by Dan Carpenter <[email protected]>---
v2: the first version just swapped theIS_ERR()check for a NULL checkThanks everyone for the review. In the end, it was still a one line fix so I forgive you Ivan.
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 1589
Quoted 5 lines
drivers/usb/phy/phy-msm-usb.c +1
-1@@ -1586,7 +1586,7 @@ static int msm_otg_probe(struct platform_device *pdev) np ? "alt_core" : "usb_hs_core_clk"); res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - motg->regs =devm_ioremap (&pdev->dev, res->start,resource_size (res)); + motg->regs =devm_ioremap_resource (&pdev->dev, res);
Thank you Dan, but this will not going to work. Address space is shared between this PHY driver and CI device controller driver. First version plus adding required check for 'res' as suggested by Sergei will fix this.
Regards,
Ivan
Quoted 22 lines · Ivan T. Ivanov
Quoted 21 lines · Dan Carpenter
There are several issues here:
1)platform_get_resource()can return NULL and that wasn't handled.
2) We should request the memory before we remap it, anddevm_ioremap_resource()does that.
3)devm_ioremap()returns a NULL but we were checking forIS_ERR().Fixes 6b99c68ec1f9 ('usb: phy: msm: Migrate to Managed Device Resource allocation')Signed-off-by Dan Carpenter <[email protected]>---
v2: the first version just swapped theIS_ERR()check for a NULL checkThanks everyone for the review. In the end, it was still a one line fix so I forgive you Ivan.
drivers/usb/phy/phy-msm-usb.c +0
-0@@ -1586,7 +1586,7 @@ static int msm_otg_probe(struct platform_device *pdev) np ? "alt_core" : "usb_hs_core_clk");
Quoted 10 lines
drivers/usb/phy/phy-msm-usb.c static int msm_otg_probe(struct platform_device *pdev) · line 1589
Quoted 3 lines
drivers/usb/phy/phy-msm-usb.c +1
-1res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - motg->regs =devm_ioremap (&pdev->dev, res->start,resource_size (res)); + motg->regs =devm_ioremap_resource (&pdev->dev, res);Thank you Dan, but this will not going to work. Address space is shared between this PHY driver and CI device controller driver. First version plus adding required check for 'res' as suggested by Sergei will fix this.
People, I'm really sorry about this. I knew there was a risk when I sent the patch. I don't have a way to test this and my changelog was too confident, more than it should have been. This was my fault.
I will send a patch to fix it.
regards,
dan carpenter