2019-10-16 14:34:16

by Yue Haibing

[permalink] [raw]
Subject: [PATCH -next 00/13] hwrng: use devm_platform_ioremap_resource() to simplify code

devm_platform_ioremap_resource() internally have platform_get_resource()
and devm_ioremap_resource() in it. So instead of calling them separately
use devm_platform_ioremap_resource() directly.

YueHaibing (13):
hwrng: atmel - use devm_platform_ioremap_resource() to simplify code
hwrng: bcm2835 - use devm_platform_ioremap_resource() to simplify code
hwrng: exynos - use devm_platform_ioremap_resource() to simplify code
hwrng: hisi - use devm_platform_ioremap_resource() to simplify code
hwrng: ks-sa - use devm_platform_ioremap_resource() to simplify code
hwrng: meson - use devm_platform_ioremap_resource() to simplify code
hwrng: npcm - use devm_platform_ioremap_resource() to simplify code
hwrng: omap - use devm_platform_ioremap_resource() to simplify code
hwrng: pasemi - use devm_platform_ioremap_resource() to simplify code
hwrng: pic32 - use devm_platform_ioremap_resource() to simplify code
hwrng: st - use devm_platform_ioremap_resource() to simplify code
hwrng: tx4939 - use devm_platform_ioremap_resource() to simplify code
hwrng: xgene - use devm_platform_ioremap_resource() to simplify code

drivers/char/hw_random/atmel-rng.c | 4 +---
drivers/char/hw_random/bcm2835-rng.c | 5 +----
drivers/char/hw_random/exynos-trng.c | 4 +---
drivers/char/hw_random/hisi-rng.c | 4 +---
drivers/char/hw_random/ks-sa-rng.c | 4 +---
drivers/char/hw_random/meson-rng.c | 4 +---
drivers/char/hw_random/npcm-rng.c | 4 +---
drivers/char/hw_random/omap-rng.c | 4 +---
drivers/char/hw_random/pasemi-rng.c | 4 +---
drivers/char/hw_random/pic32-rng.c | 4 +---
drivers/char/hw_random/st-rng.c | 4 +---
drivers/char/hw_random/tx4939-rng.c | 4 +---
drivers/char/hw_random/xgene-rng.c | 4 +---
13 files changed, 13 insertions(+), 40 deletions(-)

--
2.7.4



2019-10-16 14:34:55

by Yue Haibing

[permalink] [raw]
Subject: [PATCH -next 01/13] hwrng: atmel - use devm_platform_ioremap_resource() to simplify code

Use devm_platform_ioremap_resource() to simplify the code a bit.
This is detected by coccinelle.

Signed-off-by: YueHaibing <[email protected]>
---
drivers/char/hw_random/atmel-rng.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/char/hw_random/atmel-rng.c b/drivers/char/hw_random/atmel-rng.c
index e557057..b3138ec2 100644
--- a/drivers/char/hw_random/atmel-rng.c
+++ b/drivers/char/hw_random/atmel-rng.c
@@ -62,15 +62,13 @@ static void atmel_trng_disable(struct atmel_trng *trng)
static int atmel_trng_probe(struct platform_device *pdev)
{
struct atmel_trng *trng;
- struct resource *res;
int ret;

trng = devm_kzalloc(&pdev->dev, sizeof(*trng), GFP_KERNEL);
if (!trng)
return -ENOMEM;

- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- trng->base = devm_ioremap_resource(&pdev->dev, res);
+ trng->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(trng->base))
return PTR_ERR(trng->base);

--
2.7.4


2019-10-16 14:35:45

by Yue Haibing

[permalink] [raw]
Subject: [PATCH -next 02/13] hwrng: bcm2835 - use devm_platform_ioremap_resource() to simplify code

Use devm_platform_ioremap_resource() to simplify the code a bit.
This is detected by coccinelle.

Signed-off-by: YueHaibing <[email protected]>
---
drivers/char/hw_random/bcm2835-rng.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/char/hw_random/bcm2835-rng.c b/drivers/char/hw_random/bcm2835-rng.c
index f759790..d2a5791 100644
--- a/drivers/char/hw_random/bcm2835-rng.c
+++ b/drivers/char/hw_random/bcm2835-rng.c
@@ -142,7 +142,6 @@ static int bcm2835_rng_probe(struct platform_device *pdev)
struct device_node *np = dev->of_node;
const struct of_device_id *rng_id;
struct bcm2835_rng_priv *priv;
- struct resource *r;
int err;

priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -151,10 +150,8 @@ static int bcm2835_rng_probe(struct platform_device *pdev)

platform_set_drvdata(pdev, priv);

- r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
/* map peripheral */
- priv->base = devm_ioremap_resource(dev, r);
+ priv->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->base))
return PTR_ERR(priv->base);

--
2.7.4


2019-10-16 14:38:33

by Yue Haibing

[permalink] [raw]
Subject: [PATCH -next 07/13] hwrng: npcm - use devm_platform_ioremap_resource() to simplify code

Use devm_platform_ioremap_resource() to simplify the code a bit.
This is detected by coccinelle.

Signed-off-by: YueHaibing <[email protected]>
---
drivers/char/hw_random/npcm-rng.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/char/hw_random/npcm-rng.c b/drivers/char/hw_random/npcm-rng.c
index b7c8c7e..01d0440 100644
--- a/drivers/char/hw_random/npcm-rng.c
+++ b/drivers/char/hw_random/npcm-rng.c
@@ -87,15 +87,13 @@ static int npcm_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
static int npcm_rng_probe(struct platform_device *pdev)
{
struct npcm_rng *priv;
- struct resource *res;
int ret;

priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;

- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- priv->base = devm_ioremap_resource(&pdev->dev, res);
+ priv->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->base))
return PTR_ERR(priv->base);

--
2.7.4


2019-10-16 14:40:37

by Yue Haibing

[permalink] [raw]
Subject: [PATCH -next 09/13] hwrng: pasemi - use devm_platform_ioremap_resource() to simplify code

Use devm_platform_ioremap_resource() to simplify the code a bit.
This is detected by coccinelle.

Signed-off-by: YueHaibing <[email protected]>
---
drivers/char/hw_random/pasemi-rng.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/char/hw_random/pasemi-rng.c b/drivers/char/hw_random/pasemi-rng.c
index 24b1460..2498d4e 100644
--- a/drivers/char/hw_random/pasemi-rng.c
+++ b/drivers/char/hw_random/pasemi-rng.c
@@ -86,10 +86,8 @@ static struct hwrng pasemi_rng = {
static int rng_probe(struct platform_device *pdev)
{
void __iomem *rng_regs;
- struct resource *res;

- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- rng_regs = devm_ioremap_resource(&pdev->dev, res);
+ rng_regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(rng_regs))
return PTR_ERR(rng_regs);

--
2.7.4


2019-10-16 14:40:39

by Yue Haibing

[permalink] [raw]
Subject: [PATCH -next 12/13] hwrng: tx4939 - use devm_platform_ioremap_resource() to simplify code

Use devm_platform_ioremap_resource() to simplify the code a bit.
This is detected by coccinelle.

Signed-off-by: YueHaibing <[email protected]>
---
drivers/char/hw_random/tx4939-rng.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/char/hw_random/tx4939-rng.c b/drivers/char/hw_random/tx4939-rng.c
index 1093583..c8bd34e 100644
--- a/drivers/char/hw_random/tx4939-rng.c
+++ b/drivers/char/hw_random/tx4939-rng.c
@@ -107,14 +107,12 @@ static int tx4939_rng_data_read(struct hwrng *rng, u32 *buffer)
static int __init tx4939_rng_probe(struct platform_device *dev)
{
struct tx4939_rng *rngdev;
- struct resource *r;
int i;

rngdev = devm_kzalloc(&dev->dev, sizeof(*rngdev), GFP_KERNEL);
if (!rngdev)
return -ENOMEM;
- r = platform_get_resource(dev, IORESOURCE_MEM, 0);
- rngdev->base = devm_ioremap_resource(&dev->dev, r);
+ rngdev->base = devm_platform_ioremap_resource(dev, 0);
if (IS_ERR(rngdev->base))
return PTR_ERR(rngdev->base);

--
2.7.4


2019-10-16 14:40:51

by Yue Haibing

[permalink] [raw]
Subject: [PATCH -next 13/13] hwrng: xgene - use devm_platform_ioremap_resource() to simplify code

Use devm_platform_ioremap_resource() to simplify the code a bit.
This is detected by coccinelle.

Signed-off-by: YueHaibing <[email protected]>
---
drivers/char/hw_random/xgene-rng.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/char/hw_random/xgene-rng.c b/drivers/char/hw_random/xgene-rng.c
index 7e568db..d7516a4 100644
--- a/drivers/char/hw_random/xgene-rng.c
+++ b/drivers/char/hw_random/xgene-rng.c
@@ -313,7 +313,6 @@ static struct hwrng xgene_rng_func = {

static int xgene_rng_probe(struct platform_device *pdev)
{
- struct resource *res;
struct xgene_rng_dev *ctx;
int rc = 0;

@@ -324,8 +323,7 @@ static int xgene_rng_probe(struct platform_device *pdev)
ctx->dev = &pdev->dev;
platform_set_drvdata(pdev, ctx);

- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- ctx->csr_base = devm_ioremap_resource(&pdev->dev, res);
+ ctx->csr_base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(ctx->csr_base))
return PTR_ERR(ctx->csr_base);

--
2.7.4


2019-10-16 14:41:29

by Yue Haibing

[permalink] [raw]
Subject: [PATCH -next 10/13] hwrng: pic32 - use devm_platform_ioremap_resource() to simplify code

Use devm_platform_ioremap_resource() to simplify the code a bit.
This is detected by coccinelle.

Signed-off-by: YueHaibing <[email protected]>
---
drivers/char/hw_random/pic32-rng.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/char/hw_random/pic32-rng.c b/drivers/char/hw_random/pic32-rng.c
index 90f498c..81080cb 100644
--- a/drivers/char/hw_random/pic32-rng.c
+++ b/drivers/char/hw_random/pic32-rng.c
@@ -70,7 +70,6 @@ static int pic32_rng_read(struct hwrng *rng, void *buf, size_t max,
static int pic32_rng_probe(struct platform_device *pdev)
{
struct pic32_rng *priv;
- struct resource *res;
u32 v;
int ret;

@@ -78,8 +77,7 @@ static int pic32_rng_probe(struct platform_device *pdev)
if (!priv)
return -ENOMEM;

- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- priv->base = devm_ioremap_resource(&pdev->dev, res);
+ priv->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->base))
return PTR_ERR(priv->base);

--
2.7.4


2019-10-16 14:43:23

by Yue Haibing

[permalink] [raw]
Subject: [PATCH -next 05/13] hwrng: ks-sa - use devm_platform_ioremap_resource() to simplify code

Use devm_platform_ioremap_resource() to simplify the code a bit.
This is detected by coccinelle.

Signed-off-by: YueHaibing <[email protected]>
---
drivers/char/hw_random/ks-sa-rng.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/char/hw_random/ks-sa-rng.c b/drivers/char/hw_random/ks-sa-rng.c
index a674300..556400a 100644
--- a/drivers/char/hw_random/ks-sa-rng.c
+++ b/drivers/char/hw_random/ks-sa-rng.c
@@ -174,7 +174,6 @@ static int ks_sa_rng_probe(struct platform_device *pdev)
struct ks_sa_rng *ks_sa_rng;
struct device *dev = &pdev->dev;
int ret;
- struct resource *mem;

ks_sa_rng = devm_kzalloc(dev, sizeof(*ks_sa_rng), GFP_KERNEL);
if (!ks_sa_rng)
@@ -190,8 +189,7 @@ static int ks_sa_rng_probe(struct platform_device *pdev)
};
ks_sa_rng->rng.priv = (unsigned long)dev;

- mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- ks_sa_rng->reg_rng = devm_ioremap_resource(dev, mem);
+ ks_sa_rng->reg_rng = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(ks_sa_rng->reg_rng))
return PTR_ERR(ks_sa_rng->reg_rng);

--
2.7.4


2019-10-16 14:44:10

by Yue Haibing

[permalink] [raw]
Subject: [PATCH -next 06/13] hwrng: meson - use devm_platform_ioremap_resource() to simplify code

Use devm_platform_ioremap_resource() to simplify the code a bit.
This is detected by coccinelle.

Signed-off-by: YueHaibing <[email protected]>
---
drivers/char/hw_random/meson-rng.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/char/hw_random/meson-rng.c b/drivers/char/hw_random/meson-rng.c
index 76e693d..e446236 100644
--- a/drivers/char/hw_random/meson-rng.c
+++ b/drivers/char/hw_random/meson-rng.c
@@ -42,7 +42,6 @@ static int meson_rng_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct meson_rng_data *data;
- struct resource *res;
int ret;

data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
@@ -51,8 +50,7 @@ static int meson_rng_probe(struct platform_device *pdev)

data->pdev = pdev;

- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- data->base = devm_ioremap_resource(dev, res);
+ data->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(data->base))
return PTR_ERR(data->base);

--
2.7.4


2019-10-17 12:28:18

by Kevin Hilman

[permalink] [raw]
Subject: Re: [PATCH -next 06/13] hwrng: meson - use devm_platform_ioremap_resource() to simplify code

YueHaibing <[email protected]> writes:

> Use devm_platform_ioremap_resource() to simplify the code a bit.
> This is detected by coccinelle.
>
> Signed-off-by: YueHaibing <[email protected]>

Reviewed-by: Kevin Hilman <[email protected]>

2019-10-17 12:32:05

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH -next 02/13] hwrng: bcm2835 - use devm_platform_ioremap_resource() to simplify code

On 10/16/19 3:46 AM, YueHaibing wrote:
> Use devm_platform_ioremap_resource() to simplify the code a bit.
> This is detected by coccinelle.
>
> Signed-off-by: YueHaibing <[email protected]>

Acked-by: Florian Fainelli <[email protected]>
--
Florian

2019-10-18 05:29:19

by Yue Haibing

[permalink] [raw]
Subject: Re: [PATCH -next 00/13] hwrng: use devm_platform_ioremap_resource() to simplify code



On 2019/10/17 0:44, Florian Fainelli wrote:
> On 10/16/19 3:46 AM, YueHaibing wrote:
>> devm_platform_ioremap_resource() internally have platform_get_resource()
>> and devm_ioremap_resource() in it. So instead of calling them separately
>> use devm_platform_ioremap_resource() directly.
>
> Did your coccinelle script not cover
> drivers/char/hw_random/iproc-rng200.c somehow? Do you mind including it
> as a separate patch?

A patch from Markus Elfring has be queued:

commit a68b931932c5574aa5bd459529c766ba577c72b3
Author: Markus Elfring <[email protected]>
Date: Wed Sep 18 09:09:22 2019 +0200

hwrng: iproc-rng200 - Use devm_platform_ioremap_resource() in iproc_rng200_probe()

Simplify this function implementation by using a known wrapper function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <[email protected]>
Reviewed-by: Ray Jui <[email protected]>
Reviewed-by: Florian Fainelli <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>




> Thanks
>
>>
>> YueHaibing (13):
>> hwrng: atmel - use devm_platform_ioremap_resource() to simplify code
>> hwrng: bcm2835 - use devm_platform_ioremap_resource() to simplify code
>> hwrng: exynos - use devm_platform_ioremap_resource() to simplify code
>> hwrng: hisi - use devm_platform_ioremap_resource() to simplify code
>> hwrng: ks-sa - use devm_platform_ioremap_resource() to simplify code
>> hwrng: meson - use devm_platform_ioremap_resource() to simplify code
>> hwrng: npcm - use devm_platform_ioremap_resource() to simplify code
>> hwrng: omap - use devm_platform_ioremap_resource() to simplify code
>> hwrng: pasemi - use devm_platform_ioremap_resource() to simplify code
>> hwrng: pic32 - use devm_platform_ioremap_resource() to simplify code
>> hwrng: st - use devm_platform_ioremap_resource() to simplify code
>> hwrng: tx4939 - use devm_platform_ioremap_resource() to simplify code
>> hwrng: xgene - use devm_platform_ioremap_resource() to simplify code
>>
>> drivers/char/hw_random/atmel-rng.c | 4 +---
>> drivers/char/hw_random/bcm2835-rng.c | 5 +----
>> drivers/char/hw_random/exynos-trng.c | 4 +---
>> drivers/char/hw_random/hisi-rng.c | 4 +---
>> drivers/char/hw_random/ks-sa-rng.c | 4 +---
>> drivers/char/hw_random/meson-rng.c | 4 +---
>> drivers/char/hw_random/npcm-rng.c | 4 +---
>> drivers/char/hw_random/omap-rng.c | 4 +---
>> drivers/char/hw_random/pasemi-rng.c | 4 +---
>> drivers/char/hw_random/pic32-rng.c | 4 +---
>> drivers/char/hw_random/st-rng.c | 4 +---
>> drivers/char/hw_random/tx4939-rng.c | 4 +---
>> drivers/char/hw_random/xgene-rng.c | 4 +---
>> 13 files changed, 13 insertions(+), 40 deletions(-)
>>
>
>

2019-10-25 20:40:07

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH -next 00/13] hwrng: use devm_platform_ioremap_resource() to simplify code

On Wed, Oct 16, 2019 at 06:46:08PM +0800, YueHaibing wrote:
> devm_platform_ioremap_resource() internally have platform_get_resource()
> and devm_ioremap_resource() in it. So instead of calling them separately
> use devm_platform_ioremap_resource() directly.
>
> YueHaibing (13):
> hwrng: atmel - use devm_platform_ioremap_resource() to simplify code
> hwrng: bcm2835 - use devm_platform_ioremap_resource() to simplify code
> hwrng: exynos - use devm_platform_ioremap_resource() to simplify code
> hwrng: hisi - use devm_platform_ioremap_resource() to simplify code
> hwrng: ks-sa - use devm_platform_ioremap_resource() to simplify code
> hwrng: meson - use devm_platform_ioremap_resource() to simplify code
> hwrng: npcm - use devm_platform_ioremap_resource() to simplify code
> hwrng: omap - use devm_platform_ioremap_resource() to simplify code
> hwrng: pasemi - use devm_platform_ioremap_resource() to simplify code
> hwrng: pic32 - use devm_platform_ioremap_resource() to simplify code
> hwrng: st - use devm_platform_ioremap_resource() to simplify code
> hwrng: tx4939 - use devm_platform_ioremap_resource() to simplify code
> hwrng: xgene - use devm_platform_ioremap_resource() to simplify code
>
> drivers/char/hw_random/atmel-rng.c | 4 +---
> drivers/char/hw_random/bcm2835-rng.c | 5 +----
> drivers/char/hw_random/exynos-trng.c | 4 +---
> drivers/char/hw_random/hisi-rng.c | 4 +---
> drivers/char/hw_random/ks-sa-rng.c | 4 +---
> drivers/char/hw_random/meson-rng.c | 4 +---
> drivers/char/hw_random/npcm-rng.c | 4 +---
> drivers/char/hw_random/omap-rng.c | 4 +---
> drivers/char/hw_random/pasemi-rng.c | 4 +---
> drivers/char/hw_random/pic32-rng.c | 4 +---
> drivers/char/hw_random/st-rng.c | 4 +---
> drivers/char/hw_random/tx4939-rng.c | 4 +---
> drivers/char/hw_random/xgene-rng.c | 4 +---
> 13 files changed, 13 insertions(+), 40 deletions(-)

All applied. Thanks.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt