2013-07-29 23:51:41

by Wei Yongjun

[permalink] [raw]
Subject: [PATCH -next] ASoC: rcar: fix return value check in rsnd_gen1_probe()

From: Wei Yongjun <[email protected]>

In case of error, the function devm_ioremap_resource() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check should be
replaced with IS_ERR(), and also remove the dev_err call to avoid redundant
error message.

Signed-off-by: Wei Yongjun <[email protected]>
---
sound/soc/sh/rcar/gen.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c
index 5e4ae0d..61232cd 100644
--- a/sound/soc/sh/rcar/gen.c
+++ b/sound/soc/sh/rcar/gen.c
@@ -150,25 +150,16 @@ static int rsnd_gen1_probe(struct platform_device *pdev,
sru_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN1_SRU);
adg_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN1_ADG);
ssi_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN1_SSI);
- if (!sru_res ||
- !adg_res ||
- !ssi_res) {
- dev_err(dev, "Not enough SRU/SSI/ADG platform resources.\n");
- return -ENODEV;
- }
-
- gen->ops = &rsnd_gen1_ops;

gen->base[RSND_GEN1_SRU] = devm_ioremap_resource(dev, sru_res);
gen->base[RSND_GEN1_ADG] = devm_ioremap_resource(dev, adg_res);
gen->base[RSND_GEN1_SSI] = devm_ioremap_resource(dev, ssi_res);
- if (!gen->base[RSND_GEN1_SRU] ||
- !gen->base[RSND_GEN1_ADG] ||
- !gen->base[RSND_GEN1_SSI]) {
- dev_err(dev, "SRU/SSI/ADG ioremap failed\n");
+ if (IS_ERR(gen->base[RSND_GEN1_SRU]) ||
+ IS_ERR(gen->base[RSND_GEN1_ADG]) ||
+ IS_ERR(gen->base[RSND_GEN1_SSI]))
return -ENODEV;
- }

+ gen->ops = &rsnd_gen1_ops;
rsnd_gen1_reg_map_init(gen);

dev_dbg(dev, "Gen1 device probed\n");


2013-07-29 23:59:16

by Kuninori Morimoto

[permalink] [raw]
Subject: Re: [PATCH -next] ASoC: rcar: fix return value check in rsnd_gen1_probe()


Hi Wei

Thank you for your patch

> From: Wei Yongjun <[email protected]>
>
> In case of error, the function devm_ioremap_resource() returns ERR_PTR()
> and never returns NULL. The NULL test in the return value check should be
> replaced with IS_ERR(), and also remove the dev_err call to avoid redundants
> error message.
>
> Signed-off-by: Wei Yongjun <[email protected]>
> ---

Acked-by: Kuninori Morimoto <[email protected]>

> sound/soc/sh/rcar/gen.c | 17 ++++-------------
> 1 file changed, 4 insertions(+), 13 deletions(-)
>
> diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c
> index 5e4ae0d..61232cd 100644
> --- a/sound/soc/sh/rcar/gen.c
> +++ b/sound/soc/sh/rcar/gen.c
> @@ -150,25 +150,16 @@ static int rsnd_gen1_probe(struct platform_device *pdev,
> sru_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN1_SRU);
> adg_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN1_ADG);
> ssi_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN1_SSI);
> - if (!sru_res ||
> - !adg_res ||
> - !ssi_res) {
> - dev_err(dev, "Not enough SRU/SSI/ADG platform resources.\n");
> - return -ENODEV;
> - }
> -
> - gen->ops = &rsnd_gen1_ops;
>
> gen->base[RSND_GEN1_SRU] = devm_ioremap_resource(dev, sru_res);
> gen->base[RSND_GEN1_ADG] = devm_ioremap_resource(dev, adg_res);
> gen->base[RSND_GEN1_SSI] = devm_ioremap_resource(dev, ssi_res);
> - if (!gen->base[RSND_GEN1_SRU] ||
> - !gen->base[RSND_GEN1_ADG] ||
> - !gen->base[RSND_GEN1_SSI]) {
> - dev_err(dev, "SRU/SSI/ADG ioremap failed\n");
> + if (IS_ERR(gen->base[RSND_GEN1_SRU]) ||
> + IS_ERR(gen->base[RSND_GEN1_ADG]) ||
> + IS_ERR(gen->base[RSND_GEN1_SSI]))
> return -ENODEV;
> - }
>
> + gen->ops = &rsnd_gen1_ops;
> rsnd_gen1_reg_map_init(gen);
>
> dev_dbg(dev, "Gen1 device probed\n");
>

2013-07-31 14:00:22

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH -next] ASoC: rcar: fix return value check in rsnd_gen1_probe()

On Tue, Jul 30, 2013 at 07:51:37AM +0800, Wei Yongjun wrote:
> From: Wei Yongjun <[email protected]>
>
> In case of error, the function devm_ioremap_resource() returns ERR_PTR()
> and never returns NULL. The NULL test in the return value check should be
> replaced with IS_ERR(), and also remove the dev_err call to avoid redundant
> error message.

Applied, thanks.


Attachments:
(No filename) (380.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments