[PATCH 0/2] ARM: pxa: ssp: Clean up probe and remove functions

STALE3749d

3 messages, 1 author, 2016-06-13 · open the first message on its own page

[PATCH 0/2] ARM: pxa: ssp: Clean up probe and remove functions

From: Amitoj Kaur Chawla <hidden>
Date: 2016-06-13 14:53:09

Address some issues related to devm_ functions.

The first patch cleans up the remove function of this driver of
unnecessary freeing functions: kfree, iounmap, clk_put and
release_mem_region since devm_ allocated data does not need to 
be freed.

The second patch replaces devm_request_mem_region and devm_ioremap with
devm_ioremap_resource.

Amitoj Kaur Chawla (2):
  ARM: pxa: ssp: Drop unnecessary freeing functions
  ARM: pxa: ssp: Switch to devm_ioremap_resource

 arch/arm/plat-pxa/ssp.c | 29 +++--------------------------
 1 file changed, 3 insertions(+), 26 deletions(-)

-- 
1.9.1

[PATCH 1/2] ARM: pxa: ssp: Drop unnecessary freeing functions

From: Amitoj Kaur Chawla <hidden>
Date: 2016-06-13 14:53:15

Drop clk_put, kfree, release_mem_region and iounmap for
devm_ allocated data in the remove function of the driver.

Some of these changes were made with the help of the following
Coccinelle semantic patch:
@r@
expression x;
@@

(
 x = devm_kzalloc(...)
|
 x = devm_request_irq(...)
|
 x = devm_ioremap(...)
|
 x = devm_ioremap_nocache(...)
)

@@
expression r.x;
@@

(
* kfree(x)
|
* free_irq(x)
|
* iounmap(x)
)

Signed-off-by: Amitoj Kaur Chawla <redacted>
---
 arch/arm/plat-pxa/ssp.c | 9 ---------
 1 file changed, 9 deletions(-)
diff --git a/arch/arm/plat-pxa/ssp.c b/arch/arm/plat-pxa/ssp.c
index ba13f79..97bd43c 100644
--- a/arch/arm/plat-pxa/ssp.c
+++ b/arch/arm/plat-pxa/ssp.c
@@ -230,25 +230,16 @@ static int pxa_ssp_probe(struct platform_device *pdev)
 
 static int pxa_ssp_remove(struct platform_device *pdev)
 {
-	struct resource *res;
 	struct ssp_device *ssp;
 
 	ssp = platform_get_drvdata(pdev);
 	if (ssp == NULL)
 		return -ENODEV;
 
-	iounmap(ssp->mmio_base);
-
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	release_mem_region(res->start, resource_size(res));
-
-	clk_put(ssp->clk);
-
 	mutex_lock(&ssp_lock);
 	list_del(&ssp->node);
 	mutex_unlock(&ssp_lock);
 
-	kfree(ssp);
 	return 0;
 }
 
-- 
1.9.1

[PATCH 2/2] ARM: pxa: ssp: Switch to devm_ioremap_resource

From: Amitoj Kaur Chawla <hidden>
Date: 2016-06-13 14:53:19

Replace calls to devm_request_mem_region and devm_ioremap with a
single call to devm_ioremap_resource instead and modify error
handling.

Move the call to devm_ioremap_resource adjacent to the call to
platform_get_resource and the assignment ssp->phys_base below the 
call to devm_ioremap_resource to take advantage of the null check 
on res by devm_ioremap_resource.

Signed-off-by: Amitoj Kaur Chawla <redacted>
---
 arch/arm/plat-pxa/ssp.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)
diff --git a/arch/arm/plat-pxa/ssp.c b/arch/arm/plat-pxa/ssp.c
index 97bd43c..aecc8d5 100644
--- a/arch/arm/plat-pxa/ssp.c
+++ b/arch/arm/plat-pxa/ssp.c
@@ -175,26 +175,12 @@ static int pxa_ssp_probe(struct platform_device *pdev)
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res == NULL) {
-		dev_err(dev, "no memory resource defined\n");
-		return -ENODEV;
-	}
-
-	res = devm_request_mem_region(dev, res->start, resource_size(res),
-				      pdev->name);
-	if (res == NULL) {
-		dev_err(dev, "failed to request memory resource\n");
-		return -EBUSY;
-	}
+	ssp->mmio_base = devm_ioremap_resource(dev, res);
+	if (IS_ERR(ssp->mmio_base))
+		return PTR_ERR(ssp->mmio_base);
 
 	ssp->phys_base = res->start;
 
-	ssp->mmio_base = devm_ioremap(dev, res->start, resource_size(res));
-	if (ssp->mmio_base == NULL) {
-		dev_err(dev, "failed to ioremap() registers\n");
-		return -ENODEV;
-	}
-
 	ssp->irq = platform_get_irq(pdev, 0);
 	if (ssp->irq < 0) {
 		dev_err(dev, "no IRQ resource defined\n");
-- 
1.9.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help