* [PATCH 0/2] ARM: pxa: ssp: Clean up probe and remove functions @ 2016-06-13 14:53 ` Amitoj Kaur Chawla 0 siblings, 0 replies; 6+ messages in thread From: Amitoj Kaur Chawla @ 2016-06-13 14:53 UTC (permalink / raw) To: linux-arm-kernel 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 0/2] ARM: pxa: ssp: Clean up probe and remove functions @ 2016-06-13 14:53 ` Amitoj Kaur Chawla 0 siblings, 0 replies; 6+ messages in thread From: Amitoj Kaur Chawla @ 2016-06-13 14:53 UTC (permalink / raw) To: linux, linux-arm-kernel, linux-kernel; +Cc: julia.lawall 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] ARM: pxa: ssp: Drop unnecessary freeing functions 2016-06-13 14:53 ` Amitoj Kaur Chawla @ 2016-06-13 14:53 ` Amitoj Kaur Chawla -1 siblings, 0 replies; 6+ messages in thread From: Amitoj Kaur Chawla @ 2016-06-13 14:53 UTC (permalink / raw) To: linux-arm-kernel 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 <amitoj1606@gmail.com> --- 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 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 1/2] ARM: pxa: ssp: Drop unnecessary freeing functions @ 2016-06-13 14:53 ` Amitoj Kaur Chawla 0 siblings, 0 replies; 6+ messages in thread From: Amitoj Kaur Chawla @ 2016-06-13 14:53 UTC (permalink / raw) To: linux, linux-arm-kernel, linux-kernel; +Cc: julia.lawall 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 <amitoj1606@gmail.com> --- 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 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] ARM: pxa: ssp: Switch to devm_ioremap_resource 2016-06-13 14:53 ` Amitoj Kaur Chawla @ 2016-06-13 14:53 ` Amitoj Kaur Chawla -1 siblings, 0 replies; 6+ messages in thread From: Amitoj Kaur Chawla @ 2016-06-13 14:53 UTC (permalink / raw) To: linux-arm-kernel 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 <amitoj1606@gmail.com> --- 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 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] ARM: pxa: ssp: Switch to devm_ioremap_resource @ 2016-06-13 14:53 ` Amitoj Kaur Chawla 0 siblings, 0 replies; 6+ messages in thread From: Amitoj Kaur Chawla @ 2016-06-13 14:53 UTC (permalink / raw) To: linux, linux-arm-kernel, linux-kernel; +Cc: julia.lawall 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 <amitoj1606@gmail.com> --- 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 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-06-13 14:53 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-06-13 14:53 [PATCH 0/2] ARM: pxa: ssp: Clean up probe and remove functions Amitoj Kaur Chawla 2016-06-13 14:53 ` Amitoj Kaur Chawla 2016-06-13 14:53 ` [PATCH 1/2] ARM: pxa: ssp: Drop unnecessary freeing functions Amitoj Kaur Chawla 2016-06-13 14:53 ` Amitoj Kaur Chawla 2016-06-13 14:53 ` [PATCH 2/2] ARM: pxa: ssp: Switch to devm_ioremap_resource Amitoj Kaur Chawla 2016-06-13 14:53 ` Amitoj Kaur Chawla
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.