ARM: pxa: ssp: Clean up probe and remove functions
Subsystems (2)
cover ARM: pxa: ssp: Clean up probe and remove functions
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(-)
Signature · 1 line
1.9.1
PATCH 1/2 ARM: pxa: ssp: Drop unnecessary freeing functions
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)
)
--- arch/arm/plat-pxa/ssp.c | 9 --------- 1 file changed, 9 deletions(-)
arch/arm/plat-pxa/ssp.c +0 -9
@@ -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 ; }
Signature · 1 line
1.9.1
PATCH 2/2 ARM: pxa: ssp: Switch to devm_ioremap_resource
In reply to Amitoj Kaur ChawlaReplace 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.
--- arch/arm/plat-pxa/ssp.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-)
arch/arm/plat-pxa/ssp.c +3 -17
@@ -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" );
Signature · 1 line
1.9.1