Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1568564

[PATCH 4/4] Input: leds - force the LED status after .probe()

From Benjamin Tissoires <benjamin.tissoires@redhat.com>
Newsgroups linux.kernel
Subject [PATCH 4/4] Input: leds - force the LED status after .probe()
Date 2017-01-27 18:50 +0100
Message-ID <t4iFe-74B-69@gated-at.bofh.it> (permalink)
References <t4ilP-6Xe-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Once the host has set the initial setting of the LEDs after a new
USB keyboard gets connected, they appear to have a SET_IDLE command
sent which turns of the LEDs.
This means that the initial step of setting the LEDs on a keyboard is
just reset once .probe() finishes.
To be sure we set the LEDs, start a delayed task to try to resend
them after 1 sec.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
 drivers/input/input-leds.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/drivers/input/input-leds.c b/drivers/input/input-leds.c
index 766bf26..83d930f 100644
--- a/drivers/input/input-leds.c
+++ b/drivers/input/input-leds.c
@@ -46,6 +46,7 @@ struct input_led {
 
 struct input_leds {
 	struct input_handle handle;
+	struct delayed_work init_work;
 	unsigned int num_leds;
 	struct input_led leds[];
 };
@@ -83,6 +84,33 @@ static int input_leds_get_count(struct input_dev *dev)
 	return count;
 }
 
+#ifdef CONFIG_LEDS_TRIGGERS
+static void leds_init_work(struct work_struct *work)
+{
+	struct input_leds *leds = container_of(work, struct input_leds,
+					       init_work.work);
+	struct input_led *led;
+	unsigned int led_code;
+	int led_no = 0;
+
+	for_each_set_bit(led_code, leds->handle.dev->ledbit, LED_CNT) {
+		led = &leds->leds[led_no];
+
+		down_read(&led->cdev.trigger_lock);
+		if (led->cdev.trigger && led->cdev.trigger->activate) {
+			led_set_brightness(&led->cdev, LED_OFF);
+			led->cdev.trigger->activate(&led->cdev);
+		}
+		up_read(&led->cdev.trigger_lock);
+		led_no++;
+	}
+}
+#else  /* !CONFIG_LEDS_TRIGGERS */
+static void leds_init_work(struct work_struct *work)
+{
+}
+#endif
+
 static int input_leds_connect(struct input_handler *handler,
 			      struct input_dev *dev,
 			      const struct input_device_id *id)
@@ -108,6 +136,7 @@ static int input_leds_connect(struct input_handler *handler,
 	leds->handle.handler = handler;
 	leds->handle.name = "leds";
 	leds->handle.private = leds;
+	INIT_DELAYED_WORK(&leds->init_work, leds_init_work);
 
 	error = input_register_handle(&leds->handle);
 	if (error)
@@ -151,6 +180,8 @@ static int input_leds_connect(struct input_handler *handler,
 		led_no++;
 	}
 
+	schedule_delayed_work(&leds->init_work, msecs_to_jiffies(1000));
+
 	return 0;
 
 err_unregister_leds:
@@ -176,6 +207,8 @@ static void input_leds_disconnect(struct input_handle *handle)
 	struct input_leds *leds = handle->private;
 	int i;
 
+	cancel_delayed_work_sync(&leds->init_work);
+
 	for (i = 0; i < leds->num_leds; i++) {
 		struct input_led *led = &leds->leds[i];
 
-- 
2.9.3

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 0/4] TTY: fix Caps Lock LED Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2017-01-27 18:30 +0100
  [PATCH 3/4] tty/vt/keyboard: reset the LEDs state at each console change Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2017-01-27 18:30 +0100
    Re: [PATCH 3/4] tty/vt/keyboard: reset the LEDs state at each  console change Samuel Thibault <samuel.thibault@ens-lyon.org> - 2017-01-27 18:40 +0100
      Re: [PATCH 3/4] tty/vt/keyboard: reset the LEDs state at each  console change Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2017-01-27 19:30 +0100
  [PATCH 2/4] tty/vt/keyboard: Fix Caps Lock LED on major distributions Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2017-01-27 18:30 +0100
    Re: [PATCH 2/4] tty/vt/keyboard: Fix Caps Lock LED on major distributions Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-01-27 18:40 +0100
    Re: [PATCH 2/4] tty/vt/keyboard: Fix Caps Lock LED on major  distributions Samuel Thibault <samuel.thibault@ens-lyon.org> - 2017-01-27 18:40 +0100
  Re: [PATCH 0/4] TTY: fix Caps Lock LED Samuel Thibault <samuel.thibault@ens-lyon.org> - 2017-01-27 18:30 +0100
    Re: [PATCH 0/4] TTY: fix Caps Lock LED Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2017-01-27 19:40 +0100
      Re: [PATCH 0/4] TTY: fix Caps Lock LED Samuel Thibault <samuel.thibault@ens-lyon.org> - 2017-01-27 20:10 +0100
  Re: [PATCH 4/4] Input: leds - force the LED status after .probe() Samuel Thibault <samuel.thibault@ens-lyon.org> - 2017-01-27 18:40 +0100
    Re: [PATCH 4/4] Input: leds - force the LED status after .probe() Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2017-01-27 19:30 +0100
  [PATCH 4/4] Input: leds - force the LED status after .probe() Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2017-01-27 18:50 +0100

csiph-web