linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] drivers: bus: omap_l3: Conversion to devm_*
@ 2014-03-04  9:01 Peter Ujfalusi
  2014-03-04  9:01 ` [PATCH 1/5] drivers: bus: omap_l3: Convert to use devm_kzalloc Peter Ujfalusi
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Peter Ujfalusi @ 2014-03-04  9:01 UTC (permalink / raw)
  To: Santosh Shilimkar, Tony Lindgren
  Cc: Olof Johansson, Arnd Bergmann, linux-kernel, linux-omap,
	linux-arm-kernel

Hi,

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] 14+ messages in thread

* [PATCH 1/5] drivers: bus: omap_l3: Convert to use devm_kzalloc
  2014-03-04  9:01 [PATCH 0/5] drivers: bus: omap_l3: Conversion to devm_* Peter Ujfalusi
@ 2014-03-04  9:01 ` Peter Ujfalusi
  2014-03-04  9:07   ` Peter Ujfalusi
  2014-03-04  9:01 ` [PATCH 2/5] drivers: bus: omap_l3: Convert to use devm_request_and_ioremap() Peter Ujfalusi
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Peter Ujfalusi @ 2014-03-04  9:01 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>
---
 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] 14+ messages in thread

* [PATCH 2/5] drivers: bus: omap_l3: Convert to use devm_request_and_ioremap()
  2014-03-04  9:01 [PATCH 0/5] drivers: bus: omap_l3: Conversion to devm_* Peter Ujfalusi
  2014-03-04  9:01 ` [PATCH 1/5] drivers: bus: omap_l3: Convert to use devm_kzalloc Peter Ujfalusi
@ 2014-03-04  9:01 ` Peter Ujfalusi
  2014-03-04  9:12   ` Alexander Shiyan
  2014-03-04  9:01 ` [PATCH 3/5] drivers: bus: omap_l3: Convert to use devm_request_irq() Peter Ujfalusi
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Peter Ujfalusi @ 2014-03-04  9:01 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>
---
 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] 14+ messages in thread

* [PATCH 3/5] drivers: bus: omap_l3: Convert to use devm_request_irq()
  2014-03-04  9:01 [PATCH 0/5] drivers: bus: omap_l3: Conversion to devm_* Peter Ujfalusi
  2014-03-04  9:01 ` [PATCH 1/5] drivers: bus: omap_l3: Convert to use devm_kzalloc Peter Ujfalusi
  2014-03-04  9:01 ` [PATCH 2/5] drivers: bus: omap_l3: Convert to use devm_request_and_ioremap() Peter Ujfalusi
@ 2014-03-04  9:01 ` Peter Ujfalusi
  2014-03-04  9:01 ` [PATCH 4/5] drivers: bus: omap_l3: Remove the platform driver's remove function Peter Ujfalusi
  2014-03-04  9:01 ` [PATCH 5/5] drivers: bus: omap_l3: Change pr_crit() to dev_err() when IRQ request fails Peter Ujfalusi
  4 siblings, 0 replies; 14+ messages in thread
From: Peter Ujfalusi @ 2014-03-04  9:01 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>
---
 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] 14+ messages in thread

* [PATCH 4/5] drivers: bus: omap_l3: Remove the platform driver's remove function
  2014-03-04  9:01 [PATCH 0/5] drivers: bus: omap_l3: Conversion to devm_* Peter Ujfalusi
                   ` (2 preceding siblings ...)
  2014-03-04  9:01 ` [PATCH 3/5] drivers: bus: omap_l3: Convert to use devm_request_irq() Peter Ujfalusi
@ 2014-03-04  9:01 ` Peter Ujfalusi
  2014-03-04  9:01 ` [PATCH 5/5] drivers: bus: omap_l3: Change pr_crit() to dev_err() when IRQ request fails Peter Ujfalusi
  4 siblings, 0 replies; 14+ messages in thread
From: Peter Ujfalusi @ 2014-03-04  9:01 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>
---
 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] 14+ messages in thread

* [PATCH 5/5] drivers: bus: omap_l3: Change pr_crit() to dev_err() when IRQ request fails
  2014-03-04  9:01 [PATCH 0/5] drivers: bus: omap_l3: Conversion to devm_* Peter Ujfalusi
                   ` (3 preceding siblings ...)
  2014-03-04  9:01 ` [PATCH 4/5] drivers: bus: omap_l3: Remove the platform driver's remove function Peter Ujfalusi
@ 2014-03-04  9:01 ` Peter Ujfalusi
  4 siblings, 0 replies; 14+ messages in thread
From: Peter Ujfalusi @ 2014-03-04  9:01 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>
---
 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] 14+ messages in thread

* Re: [PATCH 1/5] drivers: bus: omap_l3: Convert to use devm_kzalloc
  2014-03-04  9:01 ` [PATCH 1/5] drivers: bus: omap_l3: Convert to use devm_kzalloc Peter Ujfalusi
@ 2014-03-04  9:07   ` Peter Ujfalusi
  0 siblings, 0 replies; 14+ messages in thread
From: Peter Ujfalusi @ 2014-03-04  9:07 UTC (permalink / raw)
  To: Santosh Shilimkar, Tony Lindgren
  Cc: Olof Johansson, Arnd Bergmann, linux-kernel, linux-omap,
	linux-arm-kernel

On 03/04/2014 11:01 AM, Peter Ujfalusi wrote:
> 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>

Where did the ".com" went from Santosh's email address??
I'll resend it in a minute with a fixed commit message.

-- 
Péter

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/5] drivers: bus: omap_l3: Convert to use devm_request_and_ioremap()
  2014-03-04  9:01 ` [PATCH 2/5] drivers: bus: omap_l3: Convert to use devm_request_and_ioremap() Peter Ujfalusi
@ 2014-03-04  9:12   ` Alexander Shiyan
  2014-03-04  9:23     ` Alexander Shiyan
                       ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Alexander Shiyan @ 2014-03-04  9:12 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Santosh Shilimkar, Tony Lindgren, Olof Johansson, linux-omap,
	linux-kernel, Arnd Bergmann, linux-arm-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=utf-8, Size: 1294 bytes --]

Вторник,  4 марта 2014, 11:01 +02:00 от Peter Ujfalusi <peter.ujfalusi@ti.com>:
> 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>
> ---

> +	/* 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;
> +		}

No need to check "res". devm_request_and_ioremap() do all for us.

> -	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]) {

if (IS_ERR(l3->l3_base[i]))

> +			dev_err(&pdev->dev, "ioremap %d failed\n", i);

Unnecessary.

> +			return -ENOMEM;

return PTR_ERR(l3->l3_base[i]);

---
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/5] drivers: bus: omap_l3: Convert to use devm_request_and_ioremap()
  2014-03-04  9:12   ` Alexander Shiyan
@ 2014-03-04  9:23     ` Alexander Shiyan
  2014-03-04  9:42       ` Peter Ujfalusi
  2014-03-04  9:42     ` Peter Ujfalusi
  2014-03-04 10:50     ` Peter Ujfalusi
  2 siblings, 1 reply; 14+ messages in thread
From: Alexander Shiyan @ 2014-03-04  9:23 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Santosh Shilimkar, Tony Lindgren, Olof Johansson, linux-omap,
	linux-kernel, Arnd Bergmann, linux-arm-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=utf-8, Size: 1440 bytes --]

Вторник,  4 марта 2014, 13:12 +04:00 от Alexander Shiyan <shc_work@mail.ru>:
> Вторник,  4 марта 2014, 11:01 +02:00 от Peter Ujfalusi <peter.ujfalusi@ti.com>:
> > 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>
> > ---
> 
> > +	/* 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;
> > +		}
> 
> No need to check "res". devm_request_and_ioremap() do all for us.
> 
> > -	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]) {
> 
> if (IS_ERR(l3->l3_base[i]))

Ahh, I messed up this with devm_ioremap_resource().
However, if there is reason to use devm_request_and_ioremap() here?

---
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/5] drivers: bus: omap_l3: Convert to use devm_request_and_ioremap()
  2014-03-04  9:23     ` Alexander Shiyan
@ 2014-03-04  9:42       ` Peter Ujfalusi
  0 siblings, 0 replies; 14+ messages in thread
From: Peter Ujfalusi @ 2014-03-04  9:42 UTC (permalink / raw)
  To: Alexander Shiyan
  Cc: Santosh Shilimkar, Tony Lindgren, Olof Johansson, linux-omap,
	linux-kernel, Arnd Bergmann, linux-arm-kernel

On 03/04/2014 11:23 AM, Alexander Shiyan wrote:
>>> -	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]) {
>>
>> if (IS_ERR(l3->l3_base[i]))
> 
> Ahh, I messed up this with devm_ioremap_resource().
> However, if there is reason to use devm_request_and_ioremap() here?

devm_request_and_ioremap() is just a wrapper for devm_ioremap_resource(). It
returns NULL in case of error (eats up the error code at the same time).
I don't have strong preference on this so I can change it to
devm_ioremap_resource()

-- 
Péter

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/5] drivers: bus: omap_l3: Convert to use devm_request_and_ioremap()
  2014-03-04  9:12   ` Alexander Shiyan
  2014-03-04  9:23     ` Alexander Shiyan
@ 2014-03-04  9:42     ` Peter Ujfalusi
  2014-03-04 10:50     ` Peter Ujfalusi
  2 siblings, 0 replies; 14+ messages in thread
From: Peter Ujfalusi @ 2014-03-04  9:42 UTC (permalink / raw)
  To: Alexander Shiyan
  Cc: Santosh Shilimkar, Tony Lindgren, Olof Johansson, linux-omap,
	linux-kernel, Arnd Bergmann, linux-arm-kernel

On 03/04/2014 11:12 AM, Alexander Shiyan wrote:
> Вторник,  4 марта 2014, 11:01 +02:00 от Peter Ujfalusi <peter.ujfalusi@ti.com>:
>> 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>
>> ---
> 
>> +	/* 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;
>> +		}
> 
> No need to check "res". devm_request_and_ioremap() do all for us.

True.

-- 
Péter

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/5] drivers: bus: omap_l3: Convert to use devm_request_and_ioremap()
  2014-03-04  9:12   ` Alexander Shiyan
  2014-03-04  9:23     ` Alexander Shiyan
  2014-03-04  9:42     ` Peter Ujfalusi
@ 2014-03-04 10:50     ` Peter Ujfalusi
  2 siblings, 0 replies; 14+ messages in thread
From: Peter Ujfalusi @ 2014-03-04 10:50 UTC (permalink / raw)
  To: Alexander Shiyan
  Cc: Santosh Shilimkar, Tony Lindgren, Olof Johansson, linux-omap,
	linux-kernel, Arnd Bergmann, linux-arm-kernel

On 03/04/2014 11:12 AM, Alexander Shiyan wrote:
> Вторник,  4 марта 2014, 11:01 +02:00 от Peter Ujfalusi <peter.ujfalusi@ti.com>:
>> 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>
>> ---
> 
>> +	/* 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;
>> +		}
> 
> No need to check "res". devm_request_and_ioremap() do all for us.
> 
>> -	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]) {
> 
> if (IS_ERR(l3->l3_base[i]))
> 
>> +			dev_err(&pdev->dev, "ioremap %d failed\n", i);
> 
> Unnecessary.

I'm going to keep this since it tells which resource of the three has failed.

> 
>> +			return -ENOMEM;
> 
> return PTR_ERR(l3->l3_base[i]);
> 
> ---
> 


-- 
Péter

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/5] drivers: bus: omap_l3: Conversion to devm_*
  2013-05-02 12:09 [PATCH 0/5] drivers: bus: omap_l3: Conversion to devm_* Peter Ujfalusi
@ 2013-05-07 12:54 ` Santosh Shilimkar
  0 siblings, 0 replies; 14+ messages in thread
From: Santosh Shilimkar @ 2013-05-07 12:54 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Tony Lindgren, Olof Johansson, Arnd Bergmann, linux-kernel, linux-omap

On Thursday 02 May 2013 05:39 PM, Peter Ujfalusi wrote:
> Hi,
> 
> 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.
> 
Thanks Peter. All patches looks fine to my eyes. In the last patch wher
you are changing the error level is bit debatable but I agree with you.

So FWIW,
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>


> 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(-)
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 0/5] drivers: bus: omap_l3: Conversion to devm_*
@ 2013-05-02 12:09 Peter Ujfalusi
  2013-05-07 12:54 ` Santosh Shilimkar
  0 siblings, 1 reply; 14+ messages in thread
From: Peter Ujfalusi @ 2013-05-02 12:09 UTC (permalink / raw)
  To: Santosh Shilimkar, Tony Lindgren
  Cc: Olof Johansson, Arnd Bergmann, linux-kernel, linux-omap

Hi,

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.

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.8.2.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-03-04 10:51 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-04  9:01 [PATCH 0/5] drivers: bus: omap_l3: Conversion to devm_* Peter Ujfalusi
2014-03-04  9:01 ` [PATCH 1/5] drivers: bus: omap_l3: Convert to use devm_kzalloc Peter Ujfalusi
2014-03-04  9:07   ` Peter Ujfalusi
2014-03-04  9:01 ` [PATCH 2/5] drivers: bus: omap_l3: Convert to use devm_request_and_ioremap() Peter Ujfalusi
2014-03-04  9:12   ` Alexander Shiyan
2014-03-04  9:23     ` Alexander Shiyan
2014-03-04  9:42       ` Peter Ujfalusi
2014-03-04  9:42     ` Peter Ujfalusi
2014-03-04 10:50     ` Peter Ujfalusi
2014-03-04  9:01 ` [PATCH 3/5] drivers: bus: omap_l3: Convert to use devm_request_irq() Peter Ujfalusi
2014-03-04  9:01 ` [PATCH 4/5] drivers: bus: omap_l3: Remove the platform driver's remove function Peter Ujfalusi
2014-03-04  9:01 ` [PATCH 5/5] drivers: bus: omap_l3: Change pr_crit() to dev_err() when IRQ request fails Peter Ujfalusi
  -- strict thread matches above, loose matches on Subject: below --
2013-05-02 12:09 [PATCH 0/5] drivers: bus: omap_l3: Conversion to devm_* Peter Ujfalusi
2013-05-07 12:54 ` Santosh Shilimkar

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).