Skip to contentSkip to conversation

clocksource: em_sti: Convert to devm_* managed helpers

PATCH New Laurent Pinchart 5 participants 5 messages Jul 26, 2013 – Jul 30, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clocksource: em_sti: Convert to devm_* managed helpers

Replace kzalloc, clk_get, ioremap and request_irq by their managed counterparts to simplify error paths.

---
 drivers/clocksource/em_sti.c | 49 +++++++++++++-------------------------------
 1 file changed, 14 insertions(+), 35 deletions(-)
drivers/clocksource/em_sti.c +14 -35
index 4329a29..b9c81b7 100644
@@ -315,68 +315,47 @@ static int em_sti_probe(struct platform_device *pdev)
 {
 	struct em_sti_priv *p;
 	struct resource *res;
-	int irq, ret;
+	int irq;
 
-	p = kzalloc(sizeof(*p), GFP_KERNEL);
+	p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
 	if (p = NULL) {
 		dev_err(&pdev->dev, "failed to allocate driver data\n");
-		ret = -ENOMEM;
-		goto err0;
+		return -ENOMEM;
 	}
 
 	p->pdev = pdev;
 	platform_set_drvdata(pdev, p);
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "failed to get I/O memory\n");
-		ret = -EINVAL;
-		goto err0;
-	}
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(&pdev->dev, "failed to get irq\n");
-		ret = -EINVAL;
-		goto err0;
+		return -EINVAL;
 	}
 
 	/* map memory, let base point to the STI instance */
-	p->base = ioremap_nocache(res->start, resource_size(res));
-	if (p->base = NULL) {
-		dev_err(&pdev->dev, "failed to remap I/O memory\n");
-		ret = -ENXIO;
-		goto err0;
-	}
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	p->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(p->base))
+		return PTR_ERR(p->base);
 
 	/* get hold of clock */
-	p->clk = clk_get(&pdev->dev, "sclk");
+	p->clk = devm_clk_get(&pdev->dev, "sclk");
 	if (IS_ERR(p->clk)) {
 		dev_err(&pdev->dev, "cannot get clock\n");
-		ret = PTR_ERR(p->clk);
-		goto err1;
+		return PTR_ERR(p->clk);
 	}
 
-	if (request_irq(irq, em_sti_interrupt,
-			IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
-			dev_name(&pdev->dev), p)) {
+	if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
+			     IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
+			     dev_name(&pdev->dev), p)) {
 		dev_err(&pdev->dev, "failed to request low IRQ\n");
-		ret = -ENOENT;
-		goto err2;
+		return -ENOENT;
 	}
 
 	raw_spin_lock_init(&p->lock);
 	em_sti_register_clockevent(p);
 	em_sti_register_clocksource(p);
 	return 0;
-
-err2:
-	clk_put(p->clk);
-err1:
-	iounmap(p->base);
-err0:
-	kfree(p);
-	return ret;
 }
 
 static int em_sti_remove(struct platform_device *pdev)
Signature · 3 lines
Regards,

Laurent Pinchart
#1 lore raw

PATCH 1/1 clocksource: em_sti: Convert to devm_* managed helpers

[ CC John Stultz, Thomas Gleixner ]

Quoted 4 lines · Laurent Pinchart

Replace kzalloc, clk_get, ioremap and request_irq by their managed counterparts to simplify error paths.

Hi Laurent,

I was recently asked for shmobile clocksource patches to be reviewed by the clocksource maintainers. I believe that means John Stultz and Thomas Gleixner who I have CCed on this email accordingly.

I have also CCed linux-arm-kernel at lists.infradead.org as many moons ago I was asked for all patches that will go through my tree and on to arm-soc to be sent there.

Quoted 101 lines
---
 drivers/clocksource/em_sti.c | 49 +++++++++++++-------------------------------
 1 file changed, 14 insertions(+), 35 deletions(-)
drivers/clocksource/em_sti.c +14 -35
index 4329a29..b9c81b7 100644
@@ -315,68 +315,47 @@ static int em_sti_probe(struct platform_device *pdev)
 {
 	struct em_sti_priv *p;
 	struct resource *res;
-	int irq, ret;
+	int irq;
 
-	p = kzalloc(sizeof(*p), GFP_KERNEL);
+	p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
 	if (p == NULL) {
 		dev_err(&pdev->dev, "failed to allocate driver data\n");
-		ret = -ENOMEM;
-		goto err0;
+		return -ENOMEM;
 	}
 
 	p->pdev = pdev;
 	platform_set_drvdata(pdev, p);
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "failed to get I/O memory\n");
-		ret = -EINVAL;
-		goto err0;
-	}
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(&pdev->dev, "failed to get irq\n");
-		ret = -EINVAL;
-		goto err0;
+		return -EINVAL;
 	}
 
 	/* map memory, let base point to the STI instance */
-	p->base = ioremap_nocache(res->start, resource_size(res));
-	if (p->base == NULL) {
-		dev_err(&pdev->dev, "failed to remap I/O memory\n");
-		ret = -ENXIO;
-		goto err0;
-	}
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	p->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(p->base))
+		return PTR_ERR(p->base);
 
 	/* get hold of clock */
-	p->clk = clk_get(&pdev->dev, "sclk");
+	p->clk = devm_clk_get(&pdev->dev, "sclk");
 	if (IS_ERR(p->clk)) {
 		dev_err(&pdev->dev, "cannot get clock\n");
-		ret = PTR_ERR(p->clk);
-		goto err1;
+		return PTR_ERR(p->clk);
 	}
 
-	if (request_irq(irq, em_sti_interrupt,
-			IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
-			dev_name(&pdev->dev), p)) {
+	if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
+			     IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
+			     dev_name(&pdev->dev), p)) {
 		dev_err(&pdev->dev, "failed to request low IRQ\n");
-		ret = -ENOENT;
-		goto err2;
+		return -ENOENT;
 	}
 
 	raw_spin_lock_init(&p->lock);
 	em_sti_register_clockevent(p);
 	em_sti_register_clocksource(p);
 	return 0;
-
-err2:
-	clk_put(p->clk);
-err1:
-	iounmap(p->base);
-err0:
-	kfree(p);
-	return ret;
 }
 
 static int em_sti_remove(struct platform_device *pdev)
Signature · 8 lines
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

PATCH 1/1 clocksource: em_sti: Convert to devm_* managed helpers

Quoted 6 lines · Simon Horman

[ CC John Stultz, Thomas Gleixner ]

Quoted 3 lines · Laurent Pinchart

Replace kzalloc, clk_get, ioremap and request_irq by their managed counterparts to simplify error paths.

Quoted 6 lines
Quoted 1 line

Hi Laurent,

I was recently asked for shmobile clocksource patches to be reviewed by the clocksource maintainers. I believe that means John Stultz and Thomas Gleixner who I have CCed on this email accordingly.

Daniel Lezcano (cc'ed) is picking up maintainership of clocksource/clockevent code in drivers/clocksource, so please cc him in the future.

thanks
-john

#3 lore raw

PATCH 1/1 clocksource: em_sti: Convert to devm_* managed helpers

Hi Simon, John,

Quoted 12 lines · On Monday 29 July 2013 19:19:09 John Stultz wrote:
Quoted 11 lines · Simon Horman

[ CC John Stultz, Thomas Gleixner ]

Quoted 5 lines · Laurent Pinchart

Replace kzalloc, clk_get, ioremap and request_irq by their managed counterparts to simplify error paths.

Signed-off-by: Laurent Pinchart
<[email protected]>

Hi Laurent,

Quoted 7 lines
Quoted 3 lines

I was recently asked for shmobile clocksource patches to be reviewed by the clocksource maintainers. I believe that means John Stultz and Thomas Gleixner who I have CCed on this email accordingly.

Daniel Lezcano (cc'ed) is picking up maintainership of clocksource/clockevent code in drivers/clocksource, so please cc him in the future.

Sure, will do so (I suppose Daniel will show up in MAINTAINERS, otherwise I might forget).

Signature · 3 lines
Regards,

Laurent Pinchart
#4 lore raw

PATCH 1/1 clocksource: em_sti: Convert to devm_* managed helpers

Quoted 19 lines · Laurent Pinchart

Hi Simon, John,

Quoted 16 lines · On Monday 29 July 2013 19:19:09 John Stultz wrote:
Quoted 14 lines · Simon Horman

[ CC John Stultz, Thomas Gleixner ]

Quoted 5 lines · Laurent Pinchart

Replace kzalloc, clk_get, ioremap and request_irq by their managed counterparts to simplify error paths.

Signed-off-by: Laurent Pinchart
<[email protected]>

Hi Laurent,

I was recently asked for shmobile clocksource patches to be reviewed by the clocksource maintainers. I believe that means John Stultz and Thomas Gleixner who I have CCed on this email accordingly.

Quoted 6 lines
Quoted 3 lines

Daniel Lezcano (cc'ed) is picking up maintainership of clocksource/clockevent code in drivers/clocksource, so please cc him in the future.

Sure, will do so (I suppose Daniel will show up in MAINTAINERS, otherwise I might forget).

Yes it is the case [1].

Please could you resend the patch, I don't see it in my mailbox.

Thanks
-- Daniel

[1]
https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?h=timers/core&id=9222d247bcbaacc40fe15549158f9d67523c1ace

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog