Skip to contentSkip to conversation

LED key trigger support

PATCH In review Kyungmin Park 2 participants 3 messages Feb 25, 2009 – Feb 27, 2009

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

PATCH 1/1 LED key trigger support

When key button is pressed or released, it turns on or off LED.

It's depends on input notifier support patch.

---

drivers/leds/Kconfig +7 -0
index 1b2a491..256f883 100644
@@ -248,4 +248,11 @@ config LEDS_TRIGGER_DEFAULT_ON
 	  This allows LEDs to be initialised in the ON state.
 	  If unsure, say Y.
 
+config LEDS_TRIGGER_KEY
+	tristate "LED Key input Trigger"
+	depends on LEDS_TRIGGERS
+	help
+	  This allows LEDs to be controlled by key input.
+	  If unsure, say Y.
+
 endif # NEW_LEDS
drivers/leds/Makefile +1 -0
index 89526ad..f31417d 100644
@@ -34,3 +34,4 @@ obj-$(CONFIG_LEDS_TRIGGER_IDE_DISK)	+= ledtrig-ide-disk.o
 obj-$(CONFIG_LEDS_TRIGGER_HEARTBEAT)	+= ledtrig-heartbeat.o
 obj-$(CONFIG_LEDS_TRIGGER_BACKLIGHT)	+= ledtrig-backlight.o
 obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON)	+= ledtrig-default-on.o
+obj-$(CONFIG_LEDS_TRIGGER_KEY)		+= ledtrig-key.o
drivers/leds/ledtrig-key.c new file +93 -0

93 lines not on this page · raw message

#1 lore raw

Hi Kyungmin,

drivers/leds/ledtrig-key.c line 30

Quoted 8 lines
drivers/leds/ledtrig-key.c new file +8 -0
+
+static int key_notifier_callback(struct notifier_block *nb,
+                               unsigned long event, void *data)
+{
+       struct key_trigger_notifier *kn = container_of(nb,
+                                       struct key_trigger_notifier, notifier);
+       struct led_classdev *led = kn->led;
+       unsigned int *key_value = (unsigned int *) data;

No need of casting from void *.

Quoted 4 lines

+
+       /* In case of touchscreen, just skip it */
+       if (*key_value == BTN_TOUCH)
+               return 0;

I think this filtering is already done by notification patch.

Quoted 4 lines
drivers/leds/ledtrig-key.c new file +4 -0
+
+       led_set_brightness(led, event);
+       return 0;
+

drivers/leds/ledtrig-key.c line 48

Quoted 10 lines
drivers/leds/ledtrig-key.c new file +10 -0
+}
+
+static void key_led_activate(struct led_classdev *led)
+{
+       struct key_trigger_notifier *kn;
+       int ret;
+
+       kn = kzalloc(sizeof(struct key_trigger_notifier), GFP_KERNEL);
+       if (!kn) {
+               dev_err(led->dev, "unable to allocatate key trigger\n");

s/allocatate/allocate

Signature · 7 lines
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
Quoted 13 lines · Trilok Soni

Hi Kyungmin,

drivers/leds/ledtrig-key.c line 30

Quoted 8 lines
drivers/leds/ledtrig-key.c new file +8 -0
+
+static int key_notifier_callback(struct notifier_block *nb,
+                               unsigned long event, void *data)
+{
+       struct key_trigger_notifier *kn = container_of(nb,
+                                       struct key_trigger_notifier, notifier);
+       struct led_classdev *led = kn->led;
+       unsigned int *key_value = (unsigned int *) data;

No need of casting from void *.

Quoted 6 lines
Quoted 4 lines

+
+       /* In case of touchscreen, just skip it */
+       if (*key_value == BTN_TOUCH)
+               return 0;

I think this filtering is already done by notification patch.

No, touchscreen also use input_report_key function so it passed BTN_TOUCH value. I don't want to key led blink at touchscreen.

Quoted 17 lines
Quoted 5 lines
drivers/leds/ledtrig-key.c new file +4 -0
+
+       led_set_brightness(led, event);
+       return 0;
+

drivers/leds/ledtrig-key.c line 48

Quoted 10 lines
drivers/leds/ledtrig-key.c new file +10 -0
+}
+
+static void key_led_activate(struct led_classdev *led)
+{
+       struct key_trigger_notifier *kn;
+       int ret;
+
+       kn = kzalloc(sizeof(struct key_trigger_notifier), GFP_KERNEL);
+       if (!kn) {
+               dev_err(led->dev, "unable to allocatate key trigger\n");

s/allocatate/allocate

Sorry for typo, I will fix it.

Thank you,
Kyungmin Park
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html