From: Samuel Thibault <samuel.thibault@ens-lyon.org> To: Dmitry Torokhov <dmitry.torokhov@gmail.com> Cc: "Pavel Machek" <pavel@ucw.cz>, "Pali Rohár" <pali.rohar@gmail.com>, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, rpurdie@rpsys.net, "Greg Kroah-Hartman" <gregkh@linuxfoundation.org> Subject: Re: [PATCH 1/3] Input: export LEDs as class devices in sysfs Date: Tue, 9 Jun 2015 15:19:55 +0200 [thread overview] Message-ID: <20150609131955.GA3045@type> (raw) In-Reply-To: <1433799790-31873-2-git-send-email-dmitry.torokhov@gmail.com> Hello, Dmitry Torokhov, le Mon 08 Jun 2015 14:43:08 -0700, a écrit : > 1. Instead of making LED class devices part of the input device they are > implemented as an input handler (and thus are completely separate from > input core). That's nicer indeed. Not defining triggers per LED however does not permit to e.g. switch two leds of a keyboard independently of what produces input events. I'm personally fine with it, I just wanted to mention it since this example of usage was cited at some point in the thread. > + [LED_NUML] = { "num-lock", VT_TRIGGER("kbd-numlock") }, > + [LED_CAPSL] = { "caps-lock", VT_TRIGGER("kbd-capslock") }, > + [LED_SCROLLL] = { "scroll-lock", VT_TRIGGER("kbd-scrollock") }, I'd tend to think we'd want to harmonize the user-visible LED names and kbd trigger names, i.e. use "numlock", "capslock" and "scrollock" in both case (or something else, but the same for LED and trigger). In my patch I simply used the corresponding LED or kbd macro names, but there is probably no strong reason to this, while there is probably a good reason to choose coherent and nice user-visible names. > +static enum led_brightness input_leds_brightness_get(struct led_classdev *cdev) > +{ > + struct input_led *led = container_of(cdev, struct input_led, cdev); > + struct input_dev *input = led->handle->dev; > + > + return test_bit(led->code, input->ledbit) ? LED_FULL : LED_OFF; This always returns LED_FULL, whatever the current state of the LED, is that really what we want? Userspace will be surprised to read 255 from sysfs whatever it writes to it (with actual proper effect on the LED). Simply not defining input_leds_brightness_get and letting the LED core manage the value does get a proper "brightness" sysfs file behavior, is there a reason not to do that? > + int led_no = 0; ... > + for_each_set_bit(led_code, dev->ledbit, LED_CNT) { > + struct input_led *led = &leds->leds[led_no]; When reading this I wondered what value led_no was, perhaps the initialization to 0 should be moved to right before the for_each_set_bit loop, to make the code clearer. Samuel
WARNING: multiple messages have this Message-ID (diff)
From: Samuel Thibault <samuel.thibault@ens-lyon.org> To: Dmitry Torokhov <dmitry.torokhov@gmail.com> Cc: "Pavel Machek" <pavel@ucw.cz>, "Pali Rohár" <pali.rohar@gmail.com>, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, rpurdie@rpsys.net, "Greg Kroah-Hartman" <gregkh@linuxfoundation.org> Subject: Re: [PATCH 1/3] Input: export LEDs as class devices in sysfs Date: Tue, 9 Jun 2015 15:19:55 +0200 [thread overview] Message-ID: <20150609131955.GA3045@type> (raw) In-Reply-To: <1433799790-31873-2-git-send-email-dmitry.torokhov@gmail.com> Hello, Dmitry Torokhov, le Mon 08 Jun 2015 14:43:08 -0700, a écrit : > 1. Instead of making LED class devices part of the input device they are > implemented as an input handler (and thus are completely separate from > input core). That's nicer indeed. Not defining triggers per LED however does not permit to e.g. switch two leds of a keyboard independently of what produces input events. I'm personally fine with it, I just wanted to mention it since this example of usage was cited at some point in the thread. > + [LED_NUML] = { "num-lock", VT_TRIGGER("kbd-numlock") }, > + [LED_CAPSL] = { "caps-lock", VT_TRIGGER("kbd-capslock") }, > + [LED_SCROLLL] = { "scroll-lock", VT_TRIGGER("kbd-scrollock") }, I'd tend to think we'd want to harmonize the user-visible LED names and kbd trigger names, i.e. use "numlock", "capslock" and "scrollock" in both case (or something else, but the same for LED and trigger). In my patch I simply used the corresponding LED or kbd macro names, but there is probably no strong reason to this, while there is probably a good reason to choose coherent and nice user-visible names. > +static enum led_brightness input_leds_brightness_get(struct led_classdev *cdev) > +{ > + struct input_led *led = container_of(cdev, struct input_led, cdev); > + struct input_dev *input = led->handle->dev; > + > + return test_bit(led->code, input->ledbit) ? LED_FULL : LED_OFF; This always returns LED_FULL, whatever the current state of the LED, is that really what we want? Userspace will be surprised to read 255 from sysfs whatever it writes to it (with actual proper effect on the LED). Simply not defining input_leds_brightness_get and letting the LED core manage the value does get a proper "brightness" sysfs file behavior, is there a reason not to do that? > + int led_no = 0; ... > + for_each_set_bit(led_code, dev->ledbit, LED_CNT) { > + struct input_led *led = &leds->leds[led_no]; When reading this I wondered what value led_no was, perhaps the initialization to 0 should be moved to right before the for_each_set_bit loop, to make the code clearer. Samuel -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-06-09 13:21 UTC|newest] Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-06-08 21:43 [PATCH 0/3] Switch input leds over to standard LED class devices Dmitry Torokhov 2015-06-08 21:43 ` [PATCH 1/3] Input: export LEDs as class devices in sysfs Dmitry Torokhov 2015-06-09 13:19 ` Samuel Thibault [this message] 2015-06-09 13:19 ` Samuel Thibault 2015-06-09 13:27 ` Samuel Thibault 2015-06-09 13:27 ` Samuel Thibault 2015-06-09 16:50 ` Dmitry Torokhov 2015-06-09 16:50 ` Dmitry Torokhov 2015-06-09 17:16 ` Samuel Thibault 2015-06-09 17:16 ` Samuel Thibault 2015-06-09 16:49 ` Dmitry Torokhov 2015-06-09 16:49 ` Dmitry Torokhov 2015-06-09 17:22 ` Samuel Thibault 2015-06-09 17:22 ` Samuel Thibault 2015-06-09 17:32 ` Dmitry Torokhov 2015-06-09 17:32 ` Dmitry Torokhov 2015-06-10 6:34 ` Pavel Machek 2015-06-10 6:34 ` Pavel Machek 2015-06-09 17:42 ` [PATCH v2 " Dmitry Torokhov 2015-06-10 0:32 ` Samuel Thibault 2015-06-10 1:24 ` Dmitry Torokhov 2015-06-11 17:51 ` Pavel Machek 2015-06-15 10:03 ` Pavel Machek 2015-06-15 10:51 ` Pali Rohár 2015-07-21 11:14 ` Vlastimil Babka 2015-07-21 17:01 ` Dmitry Torokhov 2015-07-21 21:08 ` Pavel Machek 2015-07-22 13:12 ` Vlastimil Babka 2015-07-22 18:55 ` Jiri Kosina 2015-07-23 5:19 ` Vlastimil Babka 2015-07-23 5:42 ` Jiri Kosina 2015-07-22 14:41 ` Vlastimil Babka 2015-07-22 19:49 ` Jiri Kosina 2015-07-22 21:47 ` Pavel Machek 2015-07-22 21:50 ` Jiri Kosina 2015-07-22 21:49 ` Dmitry Torokhov 2015-07-22 22:01 ` Jiri Kosina 2015-06-08 21:43 ` [PATCH 2/3] tty/vt/keyboard: define LED triggers for VT LED states Dmitry Torokhov 2015-06-08 21:43 ` [PATCH 3/3] tty/vt/keyboard: define LED triggers for VT keyboard lock states Dmitry Torokhov 2015-06-08 22:58 ` [PATCH 0/3] Switch input leds over to standard LED class devices Bastien Nocera 2015-06-08 23:16 ` Dmitry Torokhov 2015-06-09 10:54 ` Pavel Machek 2015-06-09 11:12 ` Pavel Machek 2015-06-09 11:22 ` Pali Rohár 2015-06-09 11:22 ` Pali Rohár 2015-06-09 11:28 ` Pavel Machek 2015-06-09 11:28 ` Pavel Machek 2015-06-09 12:22 ` Samuel Thibault 2015-06-09 12:22 ` Samuel Thibault 2015-06-09 11:26 ` Pavel Machek 2015-06-09 16:40 ` Dmitry Torokhov 2015-06-09 12:20 ` Samuel Thibault 2015-06-09 12:20 ` Samuel Thibault 2015-06-09 16:18 ` Pavel Machek 2015-06-09 16:32 ` Dmitry Torokhov 2015-06-09 16:37 ` Dmitry Torokhov 2015-06-09 13:42 ` Samuel Thibault 2015-06-09 13:42 ` Samuel Thibault 2015-06-09 13:50 ` Pali Rohár 2015-06-09 13:50 ` Pali Rohár 2015-06-09 14:05 ` Samuel Thibault [not found] ` <20090205113908.GA14224@const.inria.fr> 2015-06-09 14:17 ` caps lock led does not show up Samuel Thibault 2015-06-09 14:17 ` Samuel Thibault 2015-06-09 16:03 ` Bug#514464: " Anton Zinoviev 2015-06-09 16:03 ` Anton Zinoviev 2015-06-11 8:08 ` Samuel Thibault 2015-06-11 8:08 ` Samuel Thibault 2015-06-11 14:28 ` Samuel Thibault 2015-06-11 14:28 ` Samuel Thibault 2015-06-11 15:37 ` Samuel Thibault 2015-06-25 15:41 ` Samuel Thibault 2015-07-02 16:39 ` Anton Zinoviev 2015-07-02 16:50 ` Samuel Thibault 2015-08-31 8:33 ` 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=20150609131955.GA3045@type \ --to=samuel.thibault@ens-lyon.org \ --cc=dmitry.torokhov@gmail.com \ --cc=gregkh@linuxfoundation.org \ --cc=linux-input@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=pali.rohar@gmail.com \ --cc=pavel@ucw.cz \ --cc=rpurdie@rpsys.net \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.