Skip to contentSkip to conversation

hwrng: atmel - Use devm_ioremap_resource()

PATCH In review Jingoo Han 4 participants 5 messages Feb 12, 2014 – Feb 25, 2014

Subsystems (2)
lore
Share & tools
lore

Jingoo Han

author
#0 lore raw

PATCH 1/2 hwrng: atmel - Use devm_ioremap_resource()

Use devm_ioremap_resource() in order to make the code simpler, and remove redundant return value check of platform_get_resource() because the value is checked by devm_ioremap_resource().

---
 drivers/char/hw_random/atmel-rng.c |   15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/char/hw_random/atmel-rng.c +4 -11
index bf9fc6b..dfeddf2 100644
@@ -54,21 +54,14 @@ static int atmel_trng_probe(struct platform_device *pdev)
 	struct resource *res;
 	int ret;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -EINVAL;
-
 	trng = devm_kzalloc(&pdev->dev, sizeof(*trng), GFP_KERNEL);
 	if (!trng)
 		return -ENOMEM;
 
-	if (!devm_request_mem_region(&pdev->dev, res->start,
-				     resource_size(res), pdev->name))
-		return -EBUSY;
-
-	trng->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
-	if (!trng->base)
-		return -EBUSY;
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	trng->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(trng->base))
+		return PTR_ERR(trng->base);
 
 	trng->clk = clk_get(&pdev->dev, NULL);
 	if (IS_ERR(trng->clk))
Signature · 1 line
1.7.10.4
author
#1 lore raw

PATCH 2/2 hwrng: pixocell - Use devm_ioremap_resource()

Use devm_ioremap_resource() in order to make the code simpler, and remove redundant return value check of platform_get_resource() because the value is checked by devm_ioremap_resource().

---
 drivers/char/hw_random/picoxcell-rng.c |   19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)
drivers/char/hw_random/picoxcell-rng.c +3 -16
index 3d4c229..c03beee 100644
@@ -104,22 +104,9 @@ static int picoxcell_trng_probe(struct platform_device *pdev)
 	int ret;
 	struct resource *mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-	if (!mem) {
-		dev_warn(&pdev->dev, "no memory resource\n");
-		return -ENOMEM;
-	}
-
-	if (!devm_request_mem_region(&pdev->dev, mem->start, resource_size(mem),
-				     "picoxcell_trng")) {
-		dev_warn(&pdev->dev, "unable to request io mem\n");
-		return -EBUSY;
-	}
-
-	rng_base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem));
-	if (!rng_base) {
-		dev_warn(&pdev->dev, "unable to remap io mem\n");
-		return -ENOMEM;
-	}
+	rng_base = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(rng_base))
+		return PTR_ERR(rng_base);
 
 	rng_clk = clk_get(&pdev->dev, NULL);
 	if (IS_ERR(rng_clk)) {
Signature · 1 line
1.7.10.4
Acked-by on v1 1/2
#2 lore raw
In reply to Jingoo Han
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Jingoo" == Jingoo Han <[email protected]> writes:

Use devm_ioremap_resource() in order to make the code simpler, and remove redundant return value check of platform_get_resource() because the value is checked by devm_ioremap_resource().

Quoted 21 lines
---
 drivers/char/hw_random/atmel-rng.c |   15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/char/hw_random/atmel-rng.c +0 -5
index bf9fc6b..dfeddf2 100644
@@ -54,21 +54,14 @@ static int atmel_trng_probe(struct platform_device *pdev)
 	struct resource *res;
 	int ret;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -EINVAL;
-
 	trng = devm_kzalloc(&pdev->dev, sizeof(*trng), GFP_KERNEL);
 	if (!trng)
 		return -ENOMEM;
 
-	if (!devm_request_mem_region(&pdev->dev, res->start,

drivers/char/hw_random/atmel-rng.c static int atmel_trng_probe(struct platform_device *pdev) · line 64

Quoted 10 lines
drivers/char/hw_random/atmel-rng.c +4 -6
-				     resource_size(res), pdev->name))
-		return -EBUSY;
-
-	trng->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
-	if (!trng->base)
-		return -EBUSY;
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	trng->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(trng->base))
+		return PTR_ERR(trng->base);

trng-> clk = clk_get(&pdev->dev, NULL);

Quoted 3 lines
drivers/char/hw_random/atmel-rng.c +0 -0
 	if (IS_ERR(trng->clk))
Signature · 1 line
1.7.10.4
Signature · 1 line
Bye, Peter Korsgaard
Acked-by on v1 1/2
#3 lore raw
In reply to Jingoo Han

On 12/02/2014 06:17, Jingoo Han :

Quoted 5 lines

Use devm_ioremap_resource() in order to make the code simpler, and remove redundant return value check of platform_get_resource() because the value is checked by devm_ioremap_resource().

Thanks! Bye,

Quoted 35 lines
---
 drivers/char/hw_random/atmel-rng.c |   15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/char/hw_random/atmel-rng.c +4 -11
index bf9fc6b..dfeddf2 100644
@@ -54,21 +54,14 @@ static int atmel_trng_probe(struct platform_device *pdev)
 	struct resource *res;
 	int ret;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -EINVAL;
-
 	trng = devm_kzalloc(&pdev->dev, sizeof(*trng), GFP_KERNEL);
 	if (!trng)
 		return -ENOMEM;
 
-	if (!devm_request_mem_region(&pdev->dev, res->start,
-				     resource_size(res), pdev->name))
-		return -EBUSY;
-
-	trng->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
-	if (!trng->base)
-		return -EBUSY;
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	trng->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(trng->base))
+		return PTR_ERR(trng->base);
 
 	trng->clk = clk_get(&pdev->dev, NULL);
 	if (IS_ERR(trng->clk))
Signature · 1 line
Nicolas Ferre
maintainer
#4 lore raw
In reply to Jingoo Han
Quoted 5 lines · Jingoo Han

Use devm_ioremap_resource() in order to make the code simpler, and remove redundant return value check of platform_get_resource() because the value is checked by devm_ioremap_resource().

Both patches applied.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt