add led driver for Bachmann's ot200
PATCH v2 1/1 add led driver for Bachmann's ot200
From a7fecf3426ef98fdd19e9d2610665b9d1ce358a0 Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <[email protected] <mailto:[email protected]>>
Date: Mon, 9 Jan 2012 10:09:50 +0100
Subject: [PATCH v2] add led driver for Bachmann's ot200
This patch adds support for leds on Bachmann's ot200 visualisation device. The device has three leds on the back panel (led_err, led_init and led_run) and can handle up to seven leds on the front panel.
The driver was written by Linutronix on behalf of
Bachmann electronic GmbH.
Changes in v2:
- *incorporated* feedback from Andrew Morton and Lars-Peter Clausen
--- drivers/leds/Kconfig | 7 ++ drivers/leds/Makefile | 1 + drivers/leds/leds-ot200.c | 177 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 185 insertions(+), 0 deletions(-) create mode 100644 drivers/leds/leds-ot200.c
drivers/leds/Kconfig +7 -0
@@ -387,6 +387,13 @@ config LEDS_RENESAS_TPU pin function. The latter to support brightness control. Brightness control is supported but hardware blinking is not. +config LEDS_OT200 + tristate "LED support for the Bachmann OT200" + depends on LEDS_CLASS + help + This option enables support for the LEDs on the Bachmann OT200. + Say Y to enable LEDs on the Bachmann OT200. + config LEDS_TRIGGERS bool "LED Trigger support" depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
@@ -43,6 +43,7 @@ obj-$(CONFIG_LEDS_NS2) += leds-ns2.o obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o obj-$(CONFIG_LEDS_ASIC3) += leds-asic3.o obj-$(CONFIG_LEDS_RENESAS_TPU) += leds-renesas-tpu.o +obj-$(CONFIG_LEDS_OT200) += leds-ot200.o # LED SPI Drivers obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
drivers/leds/leds-ot200.c new file +177 -0
177 lines not on this page · raw message
Signature · 1 line
1.7.5.4
Quoted 10 lines · Christian Gmeiner
From
a7fecf3426ef98fdd19e9d2610665b9d1ce358a0Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <[email protected] <mailto:[email protected]>>
Date: Mon, 9 Jan 2012 10:09:50 +0100
Subject: [PATCH v2] add led driver for Bachmann's ot200This patch adds support for leds on Bachmann's ot200 visualisation device. The device has three leds on the back panel (
led_err,led_initandled_run) and can handle up to seven leds on the front panel.
Quoted 6 lines
The driver was written by Linutronix on behalf of
Bachmann electronic GmbH.Changes in v2:
- *incorporated* feedback from Andrew Morton and Lars-Peter Clausen
looks good to me except some minor style issues and the <mailto:...> tags.
Quoted 14 lines
Signed-off-by Sebastian Andrzej Siewior <[email protected]<mailto:[email protected]>>
Signed-off-by Christian Gmeiner <[email protected]<mailto:[email protected]>>
---
[...]drivers/leds/leds-ot200.c new file +1
-0@@ -0,0 +1,177 @@ +
drivers/leds/leds-ot200.c line 127
Quoted 10 lines
drivers/leds/leds-ot200.c new file +10
-0+static int __devinit ot200_led_probe (struct platform_device *pdev) +{ +int i; +int ret; + +for (i =0 ; i <ARRAY_SIZE (leds); i++) { + + leds[i].cdev.name = leds[i].name; + leds[i].cdev.default_trigger =NULL ; + leds[i].cdev.blink_set =NULL ;
No need to initialize to NULL.
drivers/leds/leds-ot200.c line 134
Quoted 7 lines
drivers/leds/leds-ot200.c new file +7
-0+ leds[i].cdev.brightness_set = ot200_led_brightness_set; + + ret =led_classdev_register (&pdev->dev, &leds[i].cdev); +if (ret <0 ) + goto err; + +dev_set_drvdata (leds[i].cdev.dev, &leds[i]);
Neither this ...
drivers/leds/leds-ot200.c line 137
Quoted 3 lines
drivers/leds/leds-ot200.c new file +3
-0+ } + +platform_set_drvdata (pdev, leds);
nor this is ever used.
drivers/leds/leds-ot200.c line 142
Quoted 5 lines
drivers/leds/leds-ot200.c new file +5
-0+ +outb (0x0 ,0x49 );/* turn off all front leds */ +outb (0x2 ,0x5a );/* turn on init led */ + leds_front =0 ; + leds_back =BIT (1 );
Maybe initialize leds_front and leds_back first and pass it to outb.
Quoted 10 lines
drivers/leds/leds-ot200.c new file +10
-0+ +return 0 ; + +err: +for (i = i -1 ; i >=0 ; i--) +led_classdev_unregister (&leds[i].cdev); + +return ret; +} +
Hi,
2012/1/9 Lars-Peter Clausen <[email protected]>:
Quoted 11 lines · Christian Gmeiner
Quoted 10 lines
From
a7fecf3426ef98fdd19e9d2610665b9d1ce358a0Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <[email protected] <mailto:[email protected]>>
Date: Mon, 9 Jan 2012 10:09:50 +0100
Subject: [PATCH v2] add led driver for Bachmann's ot200This patch adds support for leds on Bachmann's ot200 visualisation device. The device has three leds on the back panel (
led_err,led_initandled_run) and can handle up to seven leds on the front panel.
Quoted 9 lines
Quoted 6 lines
The driver was written by Linutronix on behalf of
Bachmann electronic GmbH.Changes in v2:
- *incorporated* feedback from Andrew Morton and Lars-Peter Clausenlooks good to me except some minor style issues and the <mailto:...> tags.
I have switch to an other mail client now...
Quoted 19 lines
Quoted 19 lines
Signed-off-by Sebastian Andrzej Siewior <[email protected]<mailto:[email protected]>>
Signed-off-by Christian Gmeiner <[email protected]<mailto:[email protected]>>
---
[...]drivers/leds/leds-ot200.c new file +5
-0@@ -0,0 +1,177 @@ + +static int __devinit ot200_led_probe (struct platform_device *pdev) +{ + int i; + int ret;
Quoted 8 lines
drivers/leds/leds-ot200.c line 127
Quoted 6 lines
drivers/leds/leds-ot200.c new file +6
-0+ + for (i = 0; i < ARRAY_SIZE(leds); i++) { + + leds[i].cdev.name = leds[i].name; + leds[i].cdev.default_trigger = NULL; + leds[i].cdev.blink_set = NULL;No need to initialize to NULL.
okay
Quoted 11 lines
drivers/leds/leds-ot200.c line 134
Quoted 8 lines
+ leds[i].cdev.brightness_set =
ot200_led_brightness_set;drivers/leds/leds-ot200.c new file +6
-0+ + ret = led_classdev_register(&pdev->dev, &leds[i].cdev); + if (ret < 0) + goto err; + + dev_set_drvdata(leds[i].cdev.dev, &leds[i]);Neither this ...
Quoted 5 lines
Quoted 3 lines
+ }
+
+ platform_set_drvdata(pdev, leds);nor this is ever used.
you are right
Quoted 9 lines
Quoted 6 lines
+
+ outb(0x0,0x49); /* turn off all front leds */
+ outb(0x2,0x5a); /* turn on init led */
+ leds_front = 0;
+ leds_back = BIT(1);Maybe initialize
leds_frontandleds_backfirst and pass it to outb.
Quoted 10 lines
drivers/leds/leds-ot200.c line 152
Quoted 10 lines
drivers/leds/leds-ot200.c new file +10
-0+ + return 0; + +err: + for (i = i - 1; i >= 0; i--) + led_classdev_unregister(&leds[i].cdev); + + return ret; +} +
Hope v3 will make it :)
thanks
--
Christian Gmeiner, MSc