* [patch] usb: phy: msm: devm_ioremap() doesn't return ERR_PTRs
[not found] <1400050877.8431.9.camel@iivanov-dev>
@ 2014-05-14 12:55 ` Dan Carpenter
2014-05-14 13:18 ` Fabio Estevam
2014-05-14 13:24 ` Sergei Shtylyov
0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2014-05-14 12:55 UTC (permalink / raw)
To: Felipe Balbi
Cc: Greg Kroah-Hartman, Grant Likely, Rob Herring, linux-usb,
linux-kernel, devicetree, kernel-janitors
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')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index c522c4f..bd32257 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [patch] usb: phy: msm: devm_ioremap() doesn't return ERR_PTRs
2014-05-14 12:55 ` [patch] usb: phy: msm: devm_ioremap() doesn't return ERR_PTRs Dan Carpenter
@ 2014-05-14 13:18 ` Fabio Estevam
2014-05-14 13:24 ` Sergei Shtylyov
1 sibling, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2014-05-14 13:18 UTC (permalink / raw)
To: Dan Carpenter
Cc: Felipe Balbi, Greg Kroah-Hartman, Grant Likely, Rob Herring,
USB list, linux-kernel, devicetree@vger.kernel.org,
kernel-janitors
On Wed, May 14, 2014 at 9:55 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 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')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
> index c522c4f..bd32257 100644
> --- a/drivers/usb/phy/phy-msm-usb.c
> +++ b/drivers/usb/phy/phy-msm-usb.c
> @@ -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?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] usb: phy: msm: devm_ioremap() doesn't return ERR_PTRs
2014-05-14 12:55 ` [patch] usb: phy: msm: devm_ioremap() doesn't return ERR_PTRs Dan Carpenter
2014-05-14 13:18 ` Fabio Estevam
@ 2014-05-14 13:24 ` Sergei Shtylyov
2014-05-14 13:44 ` Dan Carpenter
1 sibling, 1 reply; 4+ messages in thread
From: Sergei Shtylyov @ 2014-05-14 13:24 UTC (permalink / raw)
To: Dan Carpenter, Felipe Balbi
Cc: Greg Kroah-Hartman, Grant Likely, Rob Herring, linux-usb,
linux-kernel, devicetree, kernel-janitors
Hello.
On 14-05-2014 16:55, Dan Carpenter wrote:
> 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')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
> index c522c4f..bd32257 100644
> --- a/drivers/usb/phy/phy-msm-usb.c
> +++ b/drivers/usb/phy/phy-msm-usb.c
> @@ -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?
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] usb: phy: msm: devm_ioremap() doesn't return ERR_PTRs
2014-05-14 13:24 ` Sergei Shtylyov
@ 2014-05-14 13:44 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2014-05-14 13:44 UTC (permalink / raw)
To: Sergei Shtylyov, Ivan T. Ivanov
Cc: Felipe Balbi, Greg Kroah-Hartman, Grant Likely, Rob Herring,
linux-usb, linux-kernel, devicetree, kernel-janitors
On Wed, May 14, 2014 at 05:24:52PM +0400, Sergei Shtylyov wrote:
> Hello.
>
> On 14-05-2014 16:55, Dan Carpenter wrote:
>
> >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')
> >Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> >diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
> >index c522c4f..bd32257 100644
> >--- a/drivers/usb/phy/phy-msm-usb.c
> >+++ b/drivers/usb/phy/phy-msm-usb.c
> >@@ -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?
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-05-14 13:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1400050877.8431.9.camel@iivanov-dev>
2014-05-14 12:55 ` [patch] usb: phy: msm: devm_ioremap() doesn't return ERR_PTRs Dan Carpenter
2014-05-14 13:18 ` Fabio Estevam
2014-05-14 13:24 ` Sergei Shtylyov
2014-05-14 13:44 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).