2013-05-14 09:18:23

by Laurent Navet

[permalink] [raw]
Subject: [PATCH] drivers: video: mxsfb: clean use of devm_ioremap_resource()

Check of 'res' and calls to dev_err are already done in devm_ioremap_resource,
so no need to do them twice.

Signed-off-by: Laurent Navet <[email protected]>
---
drivers/video/mxsfb.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index 21223d4..0f3d0fc 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -884,9 +884,10 @@ static int mxsfb_probe(struct platform_device *pdev)
pdev->id_entry = of_id->data;

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(&pdev->dev, "Cannot get memory IO resource\n");
- return -ENODEV;
+ host->base = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(host->base)) {
+ ret = PTR_ERR(host->base);
+ goto fb_release;
}

fb_info = framebuffer_alloc(sizeof(struct mxsfb_info), &pdev->dev);
@@ -897,13 +898,6 @@ static int mxsfb_probe(struct platform_device *pdev)

host = to_imxfb_host(fb_info);

- host->base = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(host->base)) {
- dev_err(&pdev->dev, "ioremap failed\n");
- ret = PTR_ERR(host->base);
- goto fb_release;
- }
-
host->pdev = pdev;
platform_set_drvdata(pdev, host);

--
1.7.10.4


2013-05-16 08:41:35

by Jingoo Han

[permalink] [raw]
Subject: Re: [PATCH] drivers: video: mxsfb: clean use of devm_ioremap_resource()

Tuesday, May 14, 2013 6:25 PM, Laurent Navet wrote:
>
> Check of 'res' and calls to dev_err are already done in devm_ioremap_resource,
> so no need to do them twice.
>
> Signed-off-by: Laurent Navet <[email protected]>
> ---
> drivers/video/mxsfb.c | 14 ++++----------
> 1 file changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
> index 21223d4..0f3d0fc 100644
> --- a/drivers/video/mxsfb.c
> +++ b/drivers/video/mxsfb.c
> @@ -884,9 +884,10 @@ static int mxsfb_probe(struct platform_device *pdev)
> pdev->id_entry = of_id->data;
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - if (!res) {
> - dev_err(&pdev->dev, "Cannot get memory IO resource\n");
> - return -ENODEV;
> + host->base = devm_ioremap_resource(&pdev->dev, res);
> + if (IS_ERR(host->base)) {
> + ret = PTR_ERR(host->base);
> + goto fb_release;

It makes build warning as below:

drivers/video/mxsfb.c:887:13: warning: 'host' is used uninitialized in this function [-Wuninitialized]
drivers/video/mxsfb.c:965:21: warning: 'fb_info' may be used uninitialized in this function [-Wuninitialized]

It breaks the assignment.
host = to_imxfb_host(fb_info);

Also, 'goto fb_release;' is not good.
Please use ' return PTR_ERR(host->base);' as below:
+ host->base = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(host->base))
+ return PTR_ERR(host->base);


Best regards,
Jingoo Han

> }
>
> fb_info = framebuffer_alloc(sizeof(struct mxsfb_info), &pdev->dev);
> @@ -897,13 +898,6 @@ static int mxsfb_probe(struct platform_device *pdev)
>
> host = to_imxfb_host(fb_info);
>
> - host->base = devm_ioremap_resource(&pdev->dev, res);
> - if (IS_ERR(host->base)) {
> - dev_err(&pdev->dev, "ioremap failed\n");
> - ret = PTR_ERR(host->base);
> - goto fb_release;
> - }
> -
> host->pdev = pdev;
> platform_set_drvdata(pdev, host);
>
> --
> 1.7.10.4
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2013-05-16 09:46:23

by Laurent Navet

[permalink] [raw]
Subject: Re: [PATCH] drivers: video: mxsfb: clean use of devm_ioremap_resource()

2013/5/16, Jingoo Han <[email protected]>:
> It makes build warning as below:
>
> drivers/video/mxsfb.c:887:13: warning: 'host' is used uninitialized in this
> function [-Wuninitialized]
> drivers/video/mxsfb.c:965:21: warning: 'fb_info' may be used uninitialized
> in this function [-Wuninitialized]
>
> It breaks the assignment.
> host = to_imxfb_host(fb_info);
>
> Also, 'goto fb_release;' is not good.
> Please use ' return PTR_ERR(host->base);' as below:
> + host->base = devm_ioremap_resource(&pdev->dev, res);
> + if (IS_ERR(host->base))
> + return PTR_ERR(host->base);
>
>
> Best regards,
> Jingoo Han

Thank's for reviewing, I'll look at and resend.

Laurent,

2013-05-21 12:28:10

by Laurent Navet

[permalink] [raw]
Subject: [PATCH V2] drivers: video: mxsfb: clean use of devm_ioremap_resource()

Check of 'res' and calls to dev_err are already done in devm_ioremap_resource,
so no need to do them twice.

Signed-off-by: Laurent Navet <[email protected]>
---
drivers/video/mxsfb.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index 21223d4..6a1b338 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -883,12 +883,6 @@ static int mxsfb_probe(struct platform_device *pdev)
if (of_id)
pdev->id_entry = of_id->data;

- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(&pdev->dev, "Cannot get memory IO resource\n");
- return -ENODEV;
- }
-
fb_info = framebuffer_alloc(sizeof(struct mxsfb_info), &pdev->dev);
if (!fb_info) {
dev_err(&pdev->dev, "Failed to allocate fbdev\n");
@@ -897,9 +891,9 @@ static int mxsfb_probe(struct platform_device *pdev)

host = to_imxfb_host(fb_info);

+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
host->base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(host->base)) {
- dev_err(&pdev->dev, "ioremap failed\n");
ret = PTR_ERR(host->base);
goto fb_release;
}
--
1.7.10.4