From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jslaby@suse.com>,
Samuel Thibault <samuel.thibault@ens-lyon.org>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] Input: leds - force the LED status after .probe()
Date: Fri, 27 Jan 2017 18:13:18 +0100 [thread overview]
Message-ID: <20170127171318.2596-5-benjamin.tissoires@redhat.com> (raw)
In-Reply-To: <20170127171318.2596-1-benjamin.tissoires@redhat.com>
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
next prev parent reply other threads:[~2017-01-27 17:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-27 17:13 [PATCH 0/4] TTY: fix Caps Lock LED Benjamin Tissoires
2017-01-27 17:13 ` [PATCH 1/4] tty/vt/keyboard: use defined macros for masks Benjamin Tissoires
2017-01-27 17:18 ` Samuel Thibault
2017-01-27 17:13 ` [PATCH 2/4] tty/vt/keyboard: Fix Caps Lock LED on major distributions Benjamin Tissoires
2017-01-27 17:25 ` Samuel Thibault
2017-01-27 17:29 ` Dmitry Torokhov
2017-01-27 17:13 ` [PATCH 3/4] tty/vt/keyboard: reset the LEDs state at each console change Benjamin Tissoires
2017-01-27 17:31 ` Samuel Thibault
2017-01-27 18:18 ` Benjamin Tissoires
2017-01-27 17:13 ` Benjamin Tissoires [this message]
2017-01-27 17:34 ` [PATCH 4/4] Input: leds - force the LED status after .probe() Samuel Thibault
2017-01-27 18:19 ` Benjamin Tissoires
2017-01-27 17:23 ` [PATCH 0/4] TTY: fix Caps Lock LED Samuel Thibault
2017-01-27 18:34 ` Benjamin Tissoires
2017-01-27 18:47 ` Samuel Thibault
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170127171318.2596-5-benjamin.tissoires@redhat.com \
--to=benjamin.tissoires@redhat.com \
--cc=dmitry.torokhov@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=samuel.thibault@ens-lyon.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome