Skip to contentSkip to conversation

arm: omap: debug-leds: few changes

PATCH New Felipe Balbi 2 participants 7 messages Jul 24, 2012 – Sep 7, 2012

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

cover arm: omap: debug-leds: few changes

Hi Tony,

here are a few changes for the debug-leds driver. This series tries to get the driver closer to be moved away from arch/arm/plat-omap/ and under drivers/leds. There's only the dependency with <plat/fpga.h> now.

I tried moving the needed definitions into the C file, but there's another file which uses the same structure (arch/arm/mach-omap1/leds-h2p2-debug.c) so I left it for another series. Ideally, omap1 would be using the same debug-leds driver for that purpose and we could drop the dependency on <plat/fpga.h>.

BTW, patches were compile tested only due to the lack of an H4 board.

Felipe Balbi (5):
arm: omap: debug-leds: drop machine_is_* checks
arm: omap: debug-leds: move initialization to debug-leds
arm: omap: debug-leds: add section annotation to probe
arm: omap: debug-leds: add a remove method
arm: omap: debug-leds: switch to resource_size()

 arch/arm/plat-omap/debug-leds.c | 37 +++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 14 deletions(-)
Signature · 1 line
1.7.11
#1 lore raw

PATCH 1/5 arm: omap: debug-leds: drop machine_is_* checks

that platform_device is only registered by
board-h4.c, so there's no need to check which
machine is running as the driver won't bind
to anything.

---
 arch/arm/plat-omap/debug-leds.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
arch/arm/plat-omap/debug-leds.c +1 -7
index 39407cb..17cbef6 100644
@@ -304,12 +304,6 @@ static struct platform_driver led_driver = {
 
 static int __init fpga_init(void)
 {
-	if (machine_is_omap_h4()
-			|| machine_is_omap_h3()
-			|| machine_is_omap_h2()
-			|| machine_is_omap_perseus2()
-			)
-		return platform_driver_register(&led_driver);
-	return 0;
+	return platform_driver_register(&led_driver);
 }
 fs_initcall(fpga_init);
Signature · 1 line
1.7.11
#2 lore raw

PATCH 2/5 arm: omap: debug-leds: move initialization to debug-leds

In reply to Felipe Balbi

there's no problem in registering debug-leds on
module_init() as that's not critical to board
boot up.

---
 arch/arm/plat-omap/debug-leds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/plat-omap/debug-leds.c +1 -1
index 17cbef6..615d085 100644
@@ -306,4 +306,4 @@ static int __init fpga_init(void)
 {
 	return platform_driver_register(&led_driver);
 }
-fs_initcall(fpga_init);
+module_init(fpga_init);
Signature · 1 line
1.7.11
#3 lore raw

PATCH 3/5 arm: omap: debug-leds: add section annotation to probe

In reply to Felipe Balbi

put our probe function on __devinit section, so
it can be freed on some cases.

---
 arch/arm/plat-omap/debug-leds.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/plat-omap/debug-leds.c +2 -2
index 615d085..392daa8 100644
@@ -236,7 +236,7 @@ fpga_led_set(struct led_classdev *cdev, enum led_brightness value)
 	spin_unlock_irqrestore(&lock, flags);
 }
 
-static void __init newled_init(struct device *dev)
+static void __devinit newled_init(struct device *dev)
 {
 	unsigned	i;
 	struct dbg_led	*led;
@@ -254,7 +254,7 @@ static void __init newled_init(struct device *dev)
 
 /*-------------------------------------------------------------------------*/
 
-static int /* __init */ fpga_probe(struct platform_device *pdev)
+static int __devinit fpga_probe(struct platform_device *pdev)
 {
 	struct resource	*iomem;
 
Signature · 1 line
1.7.11
#4 lore raw

PATCH 4/5 arm: omap: debug-leds: add a remove method

In reply to Felipe Balbi

while at that, also convert to module_platform_driver

---
 arch/arm/plat-omap/debug-leds.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)
arch/arm/plat-omap/debug-leds.c +20 -5
index 392daa8..08fbb85 100644
@@ -251,6 +251,14 @@ static void __devinit newled_init(struct device *dev)
 	return;
 }
 
+static void __devexit newled_exit(void)
+{
+	unsigned	i;
+	struct dbg_led	*led;
+
+	for (i = 0, led = dbg_leds; i < ARRAY_SIZE(dbg_leds); i++, led++)
+		led_classdev_unregister(&led->cdev);
+}
 
 /*-------------------------------------------------------------------------*/
 
@@ -279,6 +287,16 @@ static int __devinit fpga_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static int __devexit fpga_remove(struct platform_device *pdev)
+{
+	if (new_led_api())
+		newled_exit();
+
+	iounmap(fpga);
+
+	return 0;
+}
+
 static int fpga_suspend_noirq(struct device *dev)
 {
 	__raw_writew(~0, &fpga->leds);
@@ -300,10 +318,7 @@ static struct platform_driver led_driver = {
 	.driver.name	= "omap_dbg_led",
 	.driver.pm	= &fpga_dev_pm_ops,
 	.probe		= fpga_probe,
+	.remove		= __devexit_p(fpga_remove),
 };
 
-static int __init fpga_init(void)
-{
-	return platform_driver_register(&led_driver);
-}
-module_init(fpga_init);
+module_platform_driver(led_driver);
Signature · 1 line
1.7.11
#5 lore raw

PATCH 5/5 arm: omap: debug-leds: switch to resource_size()

In reply to Felipe Balbi

instead of hardcoding the address space size, we
can calculate it using resource_size() helper.

---
 arch/arm/plat-omap/debug-leds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/plat-omap/debug-leds.c +1 -1
index 08fbb85..ebc0317 100644
@@ -272,7 +272,7 @@ static int __devinit fpga_probe(struct platform_device *pdev)
 	if (!iomem)
 		return -ENODEV;
 
-	fpga = ioremap(iomem->start, H2P2_DBG_FPGA_SIZE);
+	fpga = ioremap(iomem->start, resource_size(iomem));
 	__raw_writew(~0, &fpga->leds);
 
 #ifdef	CONFIG_LEDS
Signature · 1 line
1.7.11
#6 lore raw

cover arm: omap: debug-leds: few changes

In reply to Felipe Balbi
Quoted 20 lines · Felipe Balbi

Hi Tony,

here are a few changes for the debug-leds driver. This series tries to get the driver closer to be moved away from arch/arm/plat-omap/ and under drivers/leds. There's only the dependency with <plat/fpga.h> now.

I tried moving the needed definitions into the C file, but there's another file which uses the same structure (arch/arm/mach-omap1/leds-h2p2-debug.c) so I left it for another series. Ideally, omap1 would be using the same debug-leds driver for that purpose and we could drop the dependency on <plat/fpga.h>.

BTW, patches were compile tested only due to the lack of an H4 board.

Felipe Balbi (5):
arm: omap: debug-leds: drop machine_is_* checks
arm: omap: debug-leds: move initialization to debug-leds
arm: omap: debug-leds: add section annotation to probe
arm: omap: debug-leds: add a remove method
arm: omap: debug-leds: switch to resource_size()

Quoted 2 lines
 arch/arm/plat-omap/debug-leds.c | 37 +++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 14 deletions(-)

Sorry for forgetting this series.. Found it after shrinking my inbox to a more readable size :)

There are some good changes in linux-next that remove most of the debug-leds code. Maybe take a quick look what can be rebased on those to make it into a reald driver?

Regards,

Tony