* [PATCH v2 0/5] drivers: bus: omap_l3: Conversion to devm_*
@ 2014-03-04 9:08 Peter Ujfalusi
2014-03-04 9:08 ` [PATCH v2 1/5] drivers: bus: omap_l3: Convert to use devm_kzalloc Peter Ujfalusi
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Peter Ujfalusi @ 2014-03-04 9:08 UTC (permalink / raw)
To: Santosh Shilimkar, Tony Lindgren
Cc: Olof Johansson, Arnd Bergmann, linux-kernel, linux-omap,
linux-arm-kernel
Hi,
Changes since v1:
- Fixed Santosh's email address in the commit messages.
Cleanup of platform probe and remove (removing the remove function at the end)
with converting the driver to use the devm_* versions kzalloc, ioremap and
request_irq.
This is a resend of an old series which I found when doing some spring cleanup
on my HDD:
http://www.spinics.net/lists/linux-omap/msg90531.html
Regards,
Peter
---
Peter Ujfalusi (5):
drivers: bus: omap_l3: Convert to use devm_kzalloc
drivers: bus: omap_l3: Convert to use devm_request_and_ioremap()
drivers: bus: omap_l3: Convert to use devm_request_irq()
drivers: bus: omap_l3: Remove the platform driver's remove function
drivers: bus: omap_l3: Change pr_crit() to dev_err() when IRQ request
fails
drivers/bus/omap_l3_noc.c | 106 +++++++++++-----------------------------------
1 file changed, 24 insertions(+), 82 deletions(-)
--
1.9.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/5] drivers: bus: omap_l3: Convert to use devm_kzalloc
2014-03-04 9:08 [PATCH v2 0/5] drivers: bus: omap_l3: Conversion to devm_* Peter Ujfalusi
@ 2014-03-04 9:08 ` Peter Ujfalusi
2014-03-04 9:08 ` [PATCH v2 2/5] drivers: bus: omap_l3: Convert to use devm_request_and_ioremap() Peter Ujfalusi
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Peter Ujfalusi @ 2014-03-04 9:08 UTC (permalink / raw)
To: Santosh Shilimkar, Tony Lindgren
Cc: Olof Johansson, Arnd Bergmann, linux-kernel, linux-omap,
linux-arm-kernel
We can remove the kfree() calls from probe and remove.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
drivers/bus/omap_l3_noc.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/bus/omap_l3_noc.c b/drivers/bus/omap_l3_noc.c
index feeecae623f6..d25d727e7cfb 100644
--- a/drivers/bus/omap_l3_noc.c
+++ b/drivers/bus/omap_l3_noc.c
@@ -134,7 +134,7 @@ static int omap4_l3_probe(struct platform_device *pdev)
struct resource *res;
int ret;
- l3 = kzalloc(sizeof(*l3), GFP_KERNEL);
+ l3 = devm_kzalloc(&pdev->dev, sizeof(*l3), GFP_KERNEL);
if (!l3)
return -ENOMEM;
@@ -142,15 +142,13 @@ static int omap4_l3_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(&pdev->dev, "couldn't find resource 0\n");
- ret = -ENODEV;
- goto err0;
+ return -ENODEV;
}
l3->l3_base[0] = ioremap(res->start, resource_size(res));
if (!l3->l3_base[0]) {
dev_err(&pdev->dev, "ioremap failed\n");
- ret = -ENOMEM;
- goto err0;
+ return -ENOMEM;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
@@ -214,8 +212,6 @@ err2:
iounmap(l3->l3_base[1]);
err1:
iounmap(l3->l3_base[0]);
-err0:
- kfree(l3);
return ret;
}
@@ -228,7 +224,6 @@ static int omap4_l3_remove(struct platform_device *pdev)
iounmap(l3->l3_base[0]);
iounmap(l3->l3_base[1]);
iounmap(l3->l3_base[2]);
- kfree(l3);
return 0;
}
--
1.9.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/5] drivers: bus: omap_l3: Convert to use devm_request_and_ioremap()
2014-03-04 9:08 [PATCH v2 0/5] drivers: bus: omap_l3: Conversion to devm_* Peter Ujfalusi
2014-03-04 9:08 ` [PATCH v2 1/5] drivers: bus: omap_l3: Convert to use devm_kzalloc Peter Ujfalusi
@ 2014-03-04 9:08 ` Peter Ujfalusi
2014-03-04 9:08 ` [PATCH v2 3/5] drivers: bus: omap_l3: Convert to use devm_request_irq() Peter Ujfalusi
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Peter Ujfalusi @ 2014-03-04 9:08 UTC (permalink / raw)
To: Santosh Shilimkar, Tony Lindgren
Cc: Olof Johansson, Arnd Bergmann, linux-kernel, linux-omap,
linux-arm-kernel
We can then remove the iounmap() calls from probe and remove.
Since the driver requests the resources via index we can do the mem resource
request within a for loop.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
drivers/bus/omap_l3_noc.c | 63 +++++++++++------------------------------------
1 file changed, 15 insertions(+), 48 deletions(-)
diff --git a/drivers/bus/omap_l3_noc.c b/drivers/bus/omap_l3_noc.c
index d25d727e7cfb..ca95d3db5055 100644
--- a/drivers/bus/omap_l3_noc.c
+++ b/drivers/bus/omap_l3_noc.c
@@ -131,52 +131,28 @@ static irqreturn_t l3_interrupt_handler(int irq, void *_l3)
static int omap4_l3_probe(struct platform_device *pdev)
{
static struct omap4_l3 *l3;
- struct resource *res;
- int ret;
+ int ret, i;
l3 = devm_kzalloc(&pdev->dev, sizeof(*l3), GFP_KERNEL);
if (!l3)
return -ENOMEM;
platform_set_drvdata(pdev, l3);
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(&pdev->dev, "couldn't find resource 0\n");
- return -ENODEV;
- }
-
- l3->l3_base[0] = ioremap(res->start, resource_size(res));
- if (!l3->l3_base[0]) {
- dev_err(&pdev->dev, "ioremap failed\n");
- return -ENOMEM;
- }
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- if (!res) {
- dev_err(&pdev->dev, "couldn't find resource 1\n");
- ret = -ENODEV;
- goto err1;
- }
- l3->l3_base[1] = ioremap(res->start, resource_size(res));
- if (!l3->l3_base[1]) {
- dev_err(&pdev->dev, "ioremap failed\n");
- ret = -ENOMEM;
- goto err1;
- }
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
- if (!res) {
- dev_err(&pdev->dev, "couldn't find resource 2\n");
- ret = -ENODEV;
- goto err2;
- }
+ /* Get mem resources */
+ for (i = 0; i < 3; i++) {
+ struct resource *res = platform_get_resource(pdev,
+ IORESOURCE_MEM, i);
+ if (!res) {
+ dev_err(&pdev->dev, "couldn't find resource %d\n", i);
+ return -ENODEV;
+ }
- l3->l3_base[2] = ioremap(res->start, resource_size(res));
- if (!l3->l3_base[2]) {
- dev_err(&pdev->dev, "ioremap failed\n");
- ret = -ENOMEM;
- goto err2;
+ l3->l3_base[i] = devm_request_and_ioremap(&pdev->dev, res);
+ if (!l3->l3_base[i]) {
+ dev_err(&pdev->dev, "ioremap %d failed\n", i);
+ return -ENOMEM;
+ }
}
/*
@@ -189,7 +165,7 @@ static int omap4_l3_probe(struct platform_device *pdev)
if (ret) {
pr_crit("L3: request_irq failed to register for 0x%x\n",
l3->debug_irq);
- goto err3;
+ return ret;
}
l3->app_irq = platform_get_irq(pdev, 1);
@@ -206,12 +182,6 @@ static int omap4_l3_probe(struct platform_device *pdev)
err4:
free_irq(l3->debug_irq, l3);
-err3:
- iounmap(l3->l3_base[2]);
-err2:
- iounmap(l3->l3_base[1]);
-err1:
- iounmap(l3->l3_base[0]);
return ret;
}
@@ -221,9 +191,6 @@ static int omap4_l3_remove(struct platform_device *pdev)
free_irq(l3->app_irq, l3);
free_irq(l3->debug_irq, l3);
- iounmap(l3->l3_base[0]);
- iounmap(l3->l3_base[1]);
- iounmap(l3->l3_base[2]);
return 0;
}
--
1.9.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 3/5] drivers: bus: omap_l3: Convert to use devm_request_irq()
2014-03-04 9:08 [PATCH v2 0/5] drivers: bus: omap_l3: Conversion to devm_* Peter Ujfalusi
2014-03-04 9:08 ` [PATCH v2 1/5] drivers: bus: omap_l3: Convert to use devm_kzalloc Peter Ujfalusi
2014-03-04 9:08 ` [PATCH v2 2/5] drivers: bus: omap_l3: Convert to use devm_request_and_ioremap() Peter Ujfalusi
@ 2014-03-04 9:08 ` Peter Ujfalusi
2014-03-04 9:08 ` [PATCH v2 4/5] drivers: bus: omap_l3: Remove the platform driver's remove function Peter Ujfalusi
2014-03-04 9:08 ` [PATCH v2 5/5] drivers: bus: omap_l3: Change pr_crit() to dev_err() when IRQ request fails Peter Ujfalusi
4 siblings, 0 replies; 6+ messages in thread
From: Peter Ujfalusi @ 2014-03-04 9:08 UTC (permalink / raw)
To: Santosh Shilimkar, Tony Lindgren
Cc: Olof Johansson, Arnd Bergmann, linux-kernel, linux-omap,
linux-arm-kernel
With this we can remove the free_irq() calls from probe and remove.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
drivers/bus/omap_l3_noc.c | 23 +++++------------------
1 file changed, 5 insertions(+), 18 deletions(-)
diff --git a/drivers/bus/omap_l3_noc.c b/drivers/bus/omap_l3_noc.c
index ca95d3db5055..2bbc87bdea2b 100644
--- a/drivers/bus/omap_l3_noc.c
+++ b/drivers/bus/omap_l3_noc.c
@@ -159,9 +159,8 @@ static int omap4_l3_probe(struct platform_device *pdev)
* Setup interrupt Handlers
*/
l3->debug_irq = platform_get_irq(pdev, 0);
- ret = request_irq(l3->debug_irq,
- l3_interrupt_handler,
- IRQF_DISABLED, "l3-dbg-irq", l3);
+ ret = devm_request_irq(&pdev->dev, l3->debug_irq, l3_interrupt_handler,
+ IRQF_DISABLED, "l3-dbg-irq", l3);
if (ret) {
pr_crit("L3: request_irq failed to register for 0x%x\n",
l3->debug_irq);
@@ -169,29 +168,17 @@ static int omap4_l3_probe(struct platform_device *pdev)
}
l3->app_irq = platform_get_irq(pdev, 1);
- ret = request_irq(l3->app_irq,
- l3_interrupt_handler,
- IRQF_DISABLED, "l3-app-irq", l3);
- if (ret) {
+ ret = devm_request_irq(&pdev->dev, l3->app_irq, l3_interrupt_handler,
+ IRQF_DISABLED, "l3-app-irq", l3);
+ if (ret)
pr_crit("L3: request_irq failed to register for 0x%x\n",
l3->app_irq);
- goto err4;
- }
-
- return 0;
-err4:
- free_irq(l3->debug_irq, l3);
return ret;
}
static int omap4_l3_remove(struct platform_device *pdev)
{
- struct omap4_l3 *l3 = platform_get_drvdata(pdev);
-
- free_irq(l3->app_irq, l3);
- free_irq(l3->debug_irq, l3);
-
return 0;
}
--
1.9.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 4/5] drivers: bus: omap_l3: Remove the platform driver's remove function
2014-03-04 9:08 [PATCH v2 0/5] drivers: bus: omap_l3: Conversion to devm_* Peter Ujfalusi
` (2 preceding siblings ...)
2014-03-04 9:08 ` [PATCH v2 3/5] drivers: bus: omap_l3: Convert to use devm_request_irq() Peter Ujfalusi
@ 2014-03-04 9:08 ` Peter Ujfalusi
2014-03-04 9:08 ` [PATCH v2 5/5] drivers: bus: omap_l3: Change pr_crit() to dev_err() when IRQ request fails Peter Ujfalusi
4 siblings, 0 replies; 6+ messages in thread
From: Peter Ujfalusi @ 2014-03-04 9:08 UTC (permalink / raw)
To: Santosh Shilimkar, Tony Lindgren
Cc: Olof Johansson, Arnd Bergmann, linux-kernel, linux-omap,
linux-arm-kernel
It is NOP after the devm_* conversion.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
drivers/bus/omap_l3_noc.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/bus/omap_l3_noc.c b/drivers/bus/omap_l3_noc.c
index 2bbc87bdea2b..ed428ada44f7 100644
--- a/drivers/bus/omap_l3_noc.c
+++ b/drivers/bus/omap_l3_noc.c
@@ -177,11 +177,6 @@ static int omap4_l3_probe(struct platform_device *pdev)
return ret;
}
-static int omap4_l3_remove(struct platform_device *pdev)
-{
- return 0;
-}
-
#if defined(CONFIG_OF)
static const struct of_device_id l3_noc_match[] = {
{.compatible = "ti,omap4-l3-noc", },
@@ -194,7 +189,6 @@ MODULE_DEVICE_TABLE(of, l3_noc_match);
static struct platform_driver omap4_l3_driver = {
.probe = omap4_l3_probe,
- .remove = omap4_l3_remove,
.driver = {
.name = "omap_l3_noc",
.owner = THIS_MODULE,
--
1.9.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 5/5] drivers: bus: omap_l3: Change pr_crit() to dev_err() when IRQ request fails
2014-03-04 9:08 [PATCH v2 0/5] drivers: bus: omap_l3: Conversion to devm_* Peter Ujfalusi
` (3 preceding siblings ...)
2014-03-04 9:08 ` [PATCH v2 4/5] drivers: bus: omap_l3: Remove the platform driver's remove function Peter Ujfalusi
@ 2014-03-04 9:08 ` Peter Ujfalusi
4 siblings, 0 replies; 6+ messages in thread
From: Peter Ujfalusi @ 2014-03-04 9:08 UTC (permalink / raw)
To: Santosh Shilimkar, Tony Lindgren
Cc: Olof Johansson, Arnd Bergmann, linux-kernel, linux-omap,
linux-arm-kernel
Use dev_err() which will going to print the driver's name as well and the
KERN_ERR level is sufficient in this case (we also print via dev_err when
there is an error with the mem resources)
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
---
drivers/bus/omap_l3_noc.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/bus/omap_l3_noc.c b/drivers/bus/omap_l3_noc.c
index ed428ada44f7..3a36e3ebcb57 100644
--- a/drivers/bus/omap_l3_noc.c
+++ b/drivers/bus/omap_l3_noc.c
@@ -162,8 +162,8 @@ static int omap4_l3_probe(struct platform_device *pdev)
ret = devm_request_irq(&pdev->dev, l3->debug_irq, l3_interrupt_handler,
IRQF_DISABLED, "l3-dbg-irq", l3);
if (ret) {
- pr_crit("L3: request_irq failed to register for 0x%x\n",
- l3->debug_irq);
+ dev_err(&pdev->dev, "request_irq failed for %d\n",
+ l3->debug_irq);
return ret;
}
@@ -171,8 +171,7 @@ static int omap4_l3_probe(struct platform_device *pdev)
ret = devm_request_irq(&pdev->dev, l3->app_irq, l3_interrupt_handler,
IRQF_DISABLED, "l3-app-irq", l3);
if (ret)
- pr_crit("L3: request_irq failed to register for 0x%x\n",
- l3->app_irq);
+ dev_err(&pdev->dev, "request_irq failed for %d\n", l3->app_irq);
return ret;
}
--
1.9.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-03-04 9:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-04 9:08 [PATCH v2 0/5] drivers: bus: omap_l3: Conversion to devm_* Peter Ujfalusi
2014-03-04 9:08 ` [PATCH v2 1/5] drivers: bus: omap_l3: Convert to use devm_kzalloc Peter Ujfalusi
2014-03-04 9:08 ` [PATCH v2 2/5] drivers: bus: omap_l3: Convert to use devm_request_and_ioremap() Peter Ujfalusi
2014-03-04 9:08 ` [PATCH v2 3/5] drivers: bus: omap_l3: Convert to use devm_request_irq() Peter Ujfalusi
2014-03-04 9:08 ` [PATCH v2 4/5] drivers: bus: omap_l3: Remove the platform driver's remove function Peter Ujfalusi
2014-03-04 9:08 ` [PATCH v2 5/5] drivers: bus: omap_l3: Change pr_crit() to dev_err() when IRQ request fails Peter Ujfalusi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).