Skip to contentSkip to conversation

clocksource: em_sti: convert to devm_platform_ioremap_resource

PATCH Superseded Yangtao Li 2 participants 6 messages Dec 15, 2019 – Dec 16, 2019 Clocksource, clockevent drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yangtao Li

author
#0 lore raw

PATCH 1/3 clocksource: em_sti: convert to devm_platform_ioremap_resource

Use devm_platform_ioremap_resource() to simplify code. BTW, do another small cleanup.

---
 drivers/clocksource/em_sti.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/clocksource/em_sti.c +2 -5
index 9039df4f90e2..ab190dffb1ed 100644
@@ -279,9 +279,7 @@ static void em_sti_register_clockevent(struct em_sti_priv *p)
 static int em_sti_probe(struct platform_device *pdev)
 {
 	struct em_sti_priv *p;
-	struct resource *res;
-	int irq;
-	int ret;
+	int irq, ret;
 
 	p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
 	if (p == NULL)
@@ -295,8 +293,7 @@ static int em_sti_probe(struct platform_device *pdev)
 		return irq;
 
 	/* map memory, let base point to the STI instance */
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	p->base = devm_ioremap_resource(&pdev->dev, res);
+	p->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(p->base))
 		return PTR_ERR(p->base);
 
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 2/3 clocksource: timer-ti-dm: convert to devm_platform_ioremap_resource

Use devm_platform_ioremap_resource() to simplify code.

---
 drivers/clocksource/timer-ti-dm.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/clocksource/timer-ti-dm.c +2 -8
index 5394d9dbdfbc..aa2ede266edf 100644
@@ -780,7 +780,7 @@ static int omap_dm_timer_probe(struct platform_device *pdev)
 {
 	unsigned long flags;
 	struct omap_dm_timer *timer;
-	struct resource *mem, *irq;
+	struct resource *irq;
 	struct device *dev = &pdev->dev;
 	const struct dmtimer_platform_data *pdata;
 	int ret;
@@ -802,18 +802,12 @@ static int omap_dm_timer_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (unlikely(!mem)) {
-		dev_err(dev, "%s: no memory resource.\n", __func__);
-		return -ENODEV;
-	}
-
 	timer = devm_kzalloc(dev, sizeof(*timer), GFP_KERNEL);
 	if (!timer)
 		return  -ENOMEM;
 
 	timer->fclk = ERR_PTR(-ENODEV);
-	timer->io_base = devm_ioremap_resource(dev, mem);
+	timer->io_base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(timer->io_base))
 		return PTR_ERR(timer->io_base);
 
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH 3/3 clocksource: timer-ti-dm: switch to platform_get_irq

In reply to Yangtao Li

platform_get_resource(pdev, IORESOURCE_IRQ) is not recommended for requesting IRQ's resources, as they can be not ready yet. Using platform_get_irq() instead is preferred for getting IRQ even if it was not retrieved earlier.

---
 drivers/clocksource/timer-ti-dm.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/clocksource/timer-ti-dm.c +3 -7
index aa2ede266edf..bd16efb2740b 100644
@@ -780,7 +780,6 @@ static int omap_dm_timer_probe(struct platform_device *pdev)
 {
 	unsigned long flags;
 	struct omap_dm_timer *timer;
-	struct resource *irq;
 	struct device *dev = &pdev->dev;
 	const struct dmtimer_platform_data *pdata;
 	int ret;
@@ -796,11 +795,9 @@ static int omap_dm_timer_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (unlikely(!irq)) {
-		dev_err(dev, "%s: no IRQ resource.\n", __func__);
-		return -ENODEV;
-	}
+	timer->irq = platform_get_irq(pdev, 0);
+	if (timer->irq < 0)
+		return timer->irq;
 
 	timer = devm_kzalloc(dev, sizeof(*timer), GFP_KERNEL);
 	if (!timer)
@@ -830,7 +827,6 @@ static int omap_dm_timer_probe(struct platform_device *pdev)
 	if (pdata)
 		timer->errata = pdata->timer_errata;
 
-	timer->irq = irq->start;
 	timer->pdev = pdev;
 
 	pm_runtime_enable(dev);
Signature · 1 line
2.17.1
#3 lore raw
In reply to Yangtao Li
Quoted 1 line · Yangtao Li

Use devm_platform_ioremap_resource() to simplify code.

Even if the change is obvious, elaborate a bit the changelog.

Quoted 1 line

BTW, do another small cleanup.

Keep one change per patch.

Quoted 31 lines
---
 drivers/clocksource/em_sti.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/clocksource/em_sti.c +2 -5
index 9039df4f90e2..ab190dffb1ed 100644
@@ -279,9 +279,7 @@ static void em_sti_register_clockevent(struct em_sti_priv *p)
 static int em_sti_probe(struct platform_device *pdev)
 {
 	struct em_sti_priv *p;
-	struct resource *res;
-	int irq;
-	int ret;
+	int irq, ret;
 
 	p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
 	if (p == NULL)
@@ -295,8 +293,7 @@ static int em_sti_probe(struct platform_device *pdev)
 		return irq;
 
 	/* map memory, let base point to the STI instance */
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	p->base = devm_ioremap_resource(&pdev->dev, res);
+	p->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(p->base))
 		return PTR_ERR(p->base);
 
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
author
#4 lore raw
Quoted 9 lines · Daniel Lezcano
Quoted 1 line · Yangtao Li

Use devm_platform_ioremap_resource() to simplify code.

Even if the change is obvious, elaborate a bit the changelog.

Quoted 1 line

BTW, do another small cleanup.

Keep one change per patch.

OK... My fault.

Any comments on the other two?

MBR,
Yangtao

Quoted 41 lines
Quoted 23 lines
---
 drivers/clocksource/em_sti.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/clocksource/em_sti.c +1 -3
index 9039df4f90e2..ab190dffb1ed 100644
@@ -279,9 +279,7 @@ static void em_sti_register_clockevent(struct em_sti_priv *p)
 static int em_sti_probe(struct platform_device *pdev)
 {
      struct em_sti_priv *p;
-     struct resource *res;
-     int irq;
-     int ret;
+     int irq, ret;
 
      p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
      if (p == NULL)

drivers/clocksource/em_sti.c static int em_sti_probe(struct platform_device *pdev) · line 299

Quoted 9 lines
drivers/clocksource/em_sti.c +1 -2
@@ -295,8 +293,7 @@ static int em_sti_probe(struct platform_device *pdev)
              return irq;
 
      /* map memory, let base point to the STI instance */
-     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-     p->base = devm_ioremap_resource(&pdev->dev, res);
+     p->base = devm_platform_ioremap_resource(pdev, 0);
      if (IS_ERR(p->base))
              return PTR_ERR(p->base);
 

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

#5 lore raw
Quoted 8 lines · Frank Lee
Quoted 6 lines · Daniel Lezcano
Quoted 1 line · Yangtao Li

Use devm_platform_ioremap_resource() to simplify code.

Even if the change is obvious, elaborate a bit the changelog.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

BTW, do another small cleanup.

Keep one change per patch.

OK... My fault.

Any comments on the other two?

They are fine for me.

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