diff mbox

PM / devfreq: exynos-nocp: Checking for IS_ERR instead of NULL

Message ID 20160518103707.GA9436@mwanda (mailing list archive)
State Not Applicable
Headers show

Commit Message

Dan Carpenter May 18, 2016, 10:37 a.m. UTC
The platform_get_resource() function returns NULL on error, it never
returns error pointers.

Fixes: 0179a913875a ('PM / devfreq: event: Add new Exynos NoC probe driver')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Chanwoo Choi May 18, 2016, 10:57 a.m. UTC | #1
Hi Dan,

On 2016? 05? 18? 19:37, Dan Carpenter wrote:
> The platform_get_resource() function returns NULL on error, it never
> returns error pointers.
> 
> Fixes: 0179a913875a ('PM / devfreq: event: Add new Exynos NoC probe driver')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/devfreq/event/exynos-nocp.c b/drivers/devfreq/event/exynos-nocp.c
> index 6b6a5f3..03b35d5 100644
> --- a/drivers/devfreq/event/exynos-nocp.c
> +++ b/drivers/devfreq/event/exynos-nocp.c
> @@ -220,8 +220,8 @@ static int exynos_nocp_parse_dt(struct platform_device *pdev,
>  
>  	/* Maps the memory mapped IO to control nocp register */
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (IS_ERR(res))
> -		return PTR_ERR(res);
> +	if (!res)
> +		return -ENXIO;
>  
>  	base = devm_ioremap_resource(dev, res);
>  	if (IS_ERR(base))

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>

Thanks,
Chanwoo Choi


--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chanwoo Choi May 25, 2016, 12:34 p.m. UTC | #2
On 2016년 05월 18일 19:37, Dan Carpenter wrote:
> The platform_get_resource() function returns NULL on error, it never
> returns error pointers.
> 
> Fixes: 0179a913875a ('PM / devfreq: event: Add new Exynos NoC probe driver')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/devfreq/event/exynos-nocp.c b/drivers/devfreq/event/exynos-nocp.c
> index 6b6a5f3..03b35d5 100644
> --- a/drivers/devfreq/event/exynos-nocp.c
> +++ b/drivers/devfreq/event/exynos-nocp.c
> @@ -220,8 +220,8 @@ static int exynos_nocp_parse_dt(struct platform_device *pdev,
>  
>  	/* Maps the memory mapped IO to control nocp register */
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (IS_ERR(res))
> -		return PTR_ERR(res);
> +	if (!res)
> +		return -ENXIO;
>  
>  	base = devm_ioremap_resource(dev, res);
>  	if (IS_ERR(base))

Looks good to me.

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>

Thanks,
Chanwoo Choi

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Julia Lawall May 25, 2016, 3:11 p.m. UTC | #3
On Wed, 25 May 2016, Chanwoo Choi wrote:

> On 2016년 05월 18일 19:37, Dan Carpenter wrote:
> > The platform_get_resource() function returns NULL on error, it never
> > returns error pointers.
> >
> > Fixes: 0179a913875a ('PM / devfreq: event: Add new Exynos NoC probe driver')
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > diff --git a/drivers/devfreq/event/exynos-nocp.c b/drivers/devfreq/event/exynos-nocp.c
> > index 6b6a5f3..03b35d5 100644
> > --- a/drivers/devfreq/event/exynos-nocp.c
> > +++ b/drivers/devfreq/event/exynos-nocp.c
> > @@ -220,8 +220,8 @@ static int exynos_nocp_parse_dt(struct platform_device *pdev,
> >
> >  	/* Maps the memory mapped IO to control nocp register */
> >  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > -	if (IS_ERR(res))
> > -		return PTR_ERR(res);
> > +	if (!res)
> > +		return -ENXIO;
> >
> >  	base = devm_ioremap_resource(dev, res);
> >  	if (IS_ERR(base))
>
> Looks good to me.

I believe that there is no need for the test at all.
devm_ioremap_resource should make the test.

julia

>
> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
>
> Thanks,
> Chanwoo Choi
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
Dan Carpenter May 26, 2016, 6:39 a.m. UTC | #4
On Wed, May 25, 2016 at 05:11:33PM +0200, Julia Lawall wrote:
> 
> 
> On Wed, 25 May 2016, Chanwoo Choi wrote:
> 
> > On 2016년 05월 18일 19:37, Dan Carpenter wrote:
> > > The platform_get_resource() function returns NULL on error, it never
> > > returns error pointers.
> > >
> > > Fixes: 0179a913875a ('PM / devfreq: event: Add new Exynos NoC probe driver')
> > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > >
> > > diff --git a/drivers/devfreq/event/exynos-nocp.c b/drivers/devfreq/event/exynos-nocp.c
> > > index 6b6a5f3..03b35d5 100644
> > > --- a/drivers/devfreq/event/exynos-nocp.c
> > > +++ b/drivers/devfreq/event/exynos-nocp.c
> > > @@ -220,8 +220,8 @@ static int exynos_nocp_parse_dt(struct platform_device *pdev,
> > >
> > >  	/* Maps the memory mapped IO to control nocp register */
> > >  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > > -	if (IS_ERR(res))
> > > -		return PTR_ERR(res);
> > > +	if (!res)
> > > +		return -ENXIO;
> > >
> > >  	base = devm_ioremap_resource(dev, res);
> > >  	if (IS_ERR(base))
> >
> > Looks good to me.
> 
> I believe that there is no need for the test at all.
> devm_ioremap_resource should make the test.

True.  The static checker warning here is just that "res" isn't an error
pointer, not that we dereference it.

I'll resend.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/devfreq/event/exynos-nocp.c b/drivers/devfreq/event/exynos-nocp.c
index 6b6a5f3..03b35d5 100644
--- a/drivers/devfreq/event/exynos-nocp.c
+++ b/drivers/devfreq/event/exynos-nocp.c
@@ -220,8 +220,8 @@  static int exynos_nocp_parse_dt(struct platform_device *pdev,
 
 	/* Maps the memory mapped IO to control nocp register */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (IS_ERR(res))
-		return PTR_ERR(res);
+	if (!res)
+		return -ENXIO;
 
 	base = devm_ioremap_resource(dev, res);
 	if (IS_ERR(base))