Skip to contentSkip to conversation

dell-laptop: use dedicated sysfs file for ALS

PATCH In review Gabriele Mazzotta 3 participants 10 messages Jan 14, 2015 – Feb 18, 2015 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dell-laptop: use dedicated sysfs file for ALS

The ambient light sensor doesn't act like an input trigger, so it has to be kept separate. The sensor readings are used to determine whether the conditions to change the keyboard illumination are satisfied or not the moment an input trigger is used. Ambient light changes alone can't change the keyboard backlight illumination and don't restart the timer.

---
 .../ABI/testing/sysfs-platform-dell-laptop         |  11 +-
 drivers/platform/x86/dell-laptop.c                 | 152 ++++++++++++---------
 2 files changed, 97 insertions(+), 66 deletions(-)
Documentation/ABI/testing/sysfs-platform-dell-laptop +10 -1
index 7969443..8c6a0b8 100644
@@ -1,4 +1,4 @@
-What:		/sys/class/leds/dell::kbd_backlight/als_setting
+What:		/sys/class/leds/dell::kbd_backlight/als_enabled
 Date:		December 2014
 KernelVersion:	3.19
 Contact:	Gabriele Mazzotta <[email protected]>,
@@ -9,6 +9,15 @@ Description:
 		light sensor. Write 1 to this file to enable the auto
 		mode, 0 to disable it.
 
+What:		/sys/class/leds/dell::kbd_backlight/als_setting
+Date:		December 2014
+KernelVersion:	3.19
+Contact:	Gabriele Mazzotta <[email protected]>,
+		Pali Rohár <[email protected]>
+Description:
+		This file allows to specifiy the on/off threshold value,
+		as reported by the ambient light sensor.
+
 What:		/sys/class/leds/dell::kbd_backlight/start_triggers
 Date:		December 2014
 KernelVersion:	3.19
drivers/platform/x86/dell-laptop.c +87 -65

202 lines not on this page · raw message

Signature · 1 line
2.1.4
#1 lore raw

Hi,

I decided to remove "als" from input_triggers and created a dedicated sysfs file for it. Having it there was wrong and misleading. I also updated the documentation to reflect this change and fixed the wrong description of als_setting, now used for als_enabled.

Is returning -ENODEV only when writing to als_enabled the right thing to do or should it be returned also when reading als_enabled?

Thanks,
Gabriele

#2 lore raw
Quoted 6 lines · Gabriele Mazzotta

Hi,

I decided to remove "als" from input_triggers and created a dedicated sysfs file for it. Having it there was wrong and misleading. I also updated the documentation to reflect this change and fixed the wrong description of als_setting, now used for als_enabled.

Given this is a significant functional change, as opposed to a bug fix, I'm leaning toward reverting the original and adding back the corrected version to 3.20. I'm going to look at the total impact first - let me know if you have a strong argument one way or the other.

Quoted 3 lines

Is returning -ENODEV only when writing to als_enabled the right thing to do or should it be returned also when reading als_enabled?

Why would the als_enabled file exist if it would return ENODEV? If it shouldn't, then returning ENODEV in both cases would be the right thing to do as there is an error present.

Signature · 2 lines
Darren Hart
Intel Open Source Technology Center
#3 lore raw
Quoted 8 lines · On Sunday 18 January 2015 10:08:21 Darren Hart wrote:
Quoted 6 lines · Gabriele Mazzotta

Hi,

I decided to remove "als" from input_triggers and created a dedicated sysfs file for it. Having it there was wrong and misleading. I also updated the documentation to reflect this change and fixed the wrong description of als_setting, now used for als_enabled.

Quoted 4 lines

Given this is a significant functional change, as opposed to a bug fix, I'm leaning toward reverting the original and adding back the corrected version to 3.20. I'm going to look at the total impact first - let me know if you have a strong argument one way or the other.

I'm not against this decision.
If you do, please remember to also revert the commit that added the documentation.

Quoted 6 lines
Quoted 2 lines

Is returning -ENODEV only when writing to als_enabled the right thing to do or should it be returned also when reading als_enabled?

Why would the als_enabled file exist if it would return ENODEV? If it shouldn't, then returning ENODEV in both cases would be the right thing to do as there is an error present.

I'd say it makes sense not to create it when not neeeded. Creating the file conditionally probably requires more changes than what you'd like to see at this stage, so this would be another argument supporting the revert.

#4 lore raw
Quoted 9 lines · Gabriele Mazzotta
Quoted 8 lines · On Sunday 18 January 2015 10:08:21 Darren Hart wrote:
Quoted 6 lines · Gabriele Mazzotta

Hi,

I decided to remove "als" from input_triggers and created a dedicated sysfs file for it. Having it there was wrong and misleading. I also updated the documentation to reflect this change and fixed the wrong description of als_setting, now used for als_enabled.

Quoted 8 lines
Quoted 4 lines

Given this is a significant functional change, as opposed to a bug fix, I'm leaning toward reverting the original and adding back the corrected version to 3.20. I'm going to look at the total impact first - let me know if you have a strong argument one way or the other.

I'm not against this decision.
If you do, please remember to also revert the commit that added the documentation.

Then for my pull request to Linus this week, I'll be reverting:

02b2aaa platform: x86: dell-laptop: Add support for keyboard backlight 3161293 Documentation: Add entry for dell-laptop sysfs interface

Am I missing anything?

Signature · 2 lines
Darren Hart
Intel Open Source Technology Center
#5 lore raw
Quoted 19 lines · On Wednesday 21 January 2015 10:38:23 Darren Hart wrote:
Quoted 9 lines · Gabriele Mazzotta
Quoted 8 lines · On Sunday 18 January 2015 10:08:21 Darren Hart wrote:
Quoted 6 lines · Gabriele Mazzotta

Hi,

I decided to remove "als" from input_triggers and created a dedicated sysfs file for it. Having it there was wrong and misleading. I also updated the documentation to reflect this change and fixed the wrong description of als_setting, now used for als_enabled.

Quoted 8 lines
Quoted 4 lines

Given this is a significant functional change, as opposed to a bug fix, I'm leaning toward reverting the original and adding back the corrected version to 3.20. I'm going to look at the total impact first - let me know if you have a strong argument one way or the other.

I'm not against this decision.
If you do, please remember to also revert the commit that added the documentation.

Quoted 6 lines

Then for my pull request to Linus this week, I'll be reverting:

02b2aaa platform: x86: dell-laptop: Add support for keyboard backlight 3161293 Documentation: Add entry for dell-laptop sysfs interface

Am I missing anything?

No, that's all.

Thanks,
Gabriele

#6 lore raw
In reply to Gabriele Mazzotta
Quoted 9 lines · Gabriele Mazzotta

The ambient light sensor doesn't act like an input trigger, so it has to be kept separate. The sensor readings are used to determine whether the conditions to change the keyboard illumination are satisfied or not the moment an input trigger is used. Ambient light changes alone can't change the keyboard backlight illumination and don't restart the timer.

---

...

drivers/platform/x86/dell-laptop.c static ssize_t kbd_led_triggers_show(struct device *dev, · line 1640

Quoted 13 lines
drivers/platform/x86/dell-laptop.c +13 -0
+static ssize_t kbd_led_als_enabled_store(struct device *dev,
+					 struct device_attribute *attr,
+					 const char *buf, size_t count)
+{
+	struct kbd_state new_state;
+	struct kbd_state state;
+	bool triggers_enabled = false;
+	int enable;
+	int ret;
+
+	if (!kbd_als_supported) {
+		pr_warn("ALS mode is not supported\n");
+		return -ENODEV;

Will this sysfs file exist if !kbd_als_supported? If so, can we prevent that?

...

Generally speaking, there is a lot more change here than I would like for an RC5. I'm going to have to consider this one carefully. If we can't come up with a simpler fix for this RC series, we may have to revert the previous patch and target this for 3.20.

Signature · 2 lines
Darren Hart
Intel Open Source Technology Center
#7 lore raw
In reply to Gabriele Mazzotta
Quoted 9 lines · On Wednesday 14 January 2015 15:05:57 Gabriele Mazzotta wrote:

The ambient light sensor doesn't act like an input trigger, so it has to be kept separate. The sensor readings are used to determine whether the conditions to change the keyboard illumination are satisfied or not the moment an input trigger is used. Ambient light changes alone can't change the keyboard backlight illumination and don't restart the timer.

---

Gabriele, can you look and integrate this patch into full keyboard backlight support? Ideally send new full one...

Signature · 2 lines
Pali Rohár
[email protected]
#8 lore raw
Quoted 8 lines · On Tuesday 10 February 2015 10:36:21 Pali Rohár wrote:
Quoted 7 lines · On Wednesday 14 January 2015 15:05:57 Gabriele Mazzotta wrote:

The ambient light sensor doesn't act like an input trigger, so it has to be kept separate. The sensor readings are used to determine whether the conditions to change the keyboard illumination are satisfied or not the moment an input trigger is used. Ambient light changes alone can't change the keyboard backlight illumination and don't restart the timer.

Quoted 5 lines
Quoted 2 lines

---

Gabriele, can you look and integrate this patch into full keyboard backlight support? Ideally send new full one...

I will do that soon.

Darren, do you prefer one single patch or should I send Pali's patch and my changes in different patches (that can be later squashed) to make the review easier?

#9 lore raw
Quoted 2 lines · On Friday 13 February 2015 15:30:42 Gabriele Mazzotta wrote:
Quoted 1 line · On Tuesday 10 February 2015 10:36:21 Pali Rohár wrote:

On Wednesday 14 January 2015 15:05:57 Gabriele Mazzotta

Quoted 11 lines · wrote:
Quoted 11 lines
Quoted 10 lines

The ambient light sensor doesn't act like an input trigger, so it has to be kept separate. The sensor readings are used to determine whether the conditions to change the keyboard illumination are satisfied or not the moment an input trigger is used. Ambient light changes alone can't change the keyboard backlight illumination and don't restart the timer.

---

Quoted 8 lines
Quoted 2 lines

Gabriele, can you look and integrate this patch into full keyboard backlight support? Ideally send new full one...

I will do that soon.

Darren, do you prefer one single patch or should I send Pali's patch and my changes in different patches (that can be later squashed) to make the review easier?

Gabriele, I think you should send patch now. Just integrate all changes to one (this could be easy) and send it.

Signature · 2 lines
Pali Rohár
[email protected]