leds: core: Add support for poll()ing the sysfs brightness attr for changes.
Subsystems (2)
PATCH v2 1/4 leds: core: Add support for poll()ing the sysfs brightness attr for changes.
Add support for userspace using poll() for POLL_PRI on the sysfs brightness attr to watch for brightness changes.
This commit adds a led_notify_brightness_change helper function for waking up any poll() waiters; and calls this after any brightness changes (after any led_classdev->brightness_set[_blocking] calls have completed).
In some use-cases led hardware may autonomously change its brightness, e.g. the keyboard backlight used on some laptops is controlled by a hardwired (firmware handled) hotkey. led_notify_brightness_change is exported for use by drivers which can detect such autonomous changes.
This commit also updates the Documentation/ABI/testing/sysfs-class-led documentation to document that userspace may now poll on the brightness attribute.
---
Changes in v2:
-Wakeup / notify userspace on any brightness changes, not just on
autonomous changes done by the hw
--- Documentation/ABI/testing/sysfs-class-led | 8 ++++++-- drivers/leds/led-class.c | 9 +++++++++ drivers/leds/led-core.c | 16 +++++++++++++++- include/linux/leds.h | 12 ++++++++++++ 4 files changed, 42 insertions(+), 3 deletions(-)
Documentation/ABI/testing/sysfs-class-led +6 -2
@@ -1,12 +1,16 @@ What: /sys/class/leds/<led>/brightness -Date: March 2006 -KernelVersion: 2.6.17 +Date: March 2006 (poll October 2016) +KernelVersion: 2.6.17 (poll since 4.10) Contact: Richard Purdie <[email protected]> Description: Set the brightness of the LED. Most LEDs don't have hardware brightness support so will just be turned on for non-zero brightness settings. The value is between 0 and /sys/class/leds/<led>/max_brightness. + The file supports poll() to detect brightness changes, in + some cases the hardware / firmware may change the brightness + autonomously, poll() should be woken up in this case too, + but not all drivers may support this. What: /sys/class/leds/<led>/max_brightness Date: March 2006
drivers/leds/led-class.c +9 -0
@@ -203,6 +203,14 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)dev_warn (parent,"Led %s renamed to %s due to name collision" , led_cdev->name,dev_name (led_cdev->dev)); + led_cdev->brightness_kn =sysfs_get_dirent (led_cdev->dev->kobj.sd, +"brightness" ); +if (!led_cdev->brightness_kn) { +dev_err (led_cdev->dev,"Error getting brightness kernfs_node\n" ); +device_unregister (led_cdev->dev); +return -ENODEV ; + } +#ifdef CONFIG_LEDS_TRIGGERS init_rwsem (&led_cdev->trigger_lock);#endif
@@ -254,6 +262,7 @@ void led_classdev_unregister(struct led_classdev *led_cdev)flush_work (&led_cdev->set_brightness_work); +sysfs_put (led_cdev->brightness_kn);device_unregister (led_cdev->dev);down_write (&leds_list_lock);
drivers/leds/led-core.c +15 -1
@@ -33,16 +33,24 @@ static int __led_set_brightness(struct led_classdev *led_cdev, led_cdev->brightness_set (led_cdev, value); +led_notify_brightness_change (led_cdev); +return 0 ; }static int __led_set_brightness_blocking (struct led_classdev *led_cdev,enum led_brightness value) { +int ret; +if (!led_cdev->brightness_set_blocking)return -ENOTSUPP ; -return led_cdev->brightness_set_blocking (led_cdev, value); + ret = led_cdev->brightness_set_blocking (led_cdev, value); +if (ret >=0 ) +led_notify_brightness_change (led_cdev); + +return ret; }static void led_timer_function (unsigned long data)
@@ -308,6 +316,12 @@ int led_update_brightness(struct led_classdev *led_cdev) }EXPORT_SYMBOL_GPL (led_update_brightness); +void led_notify_brightness_change (struct led_classdev *led_cdev) +{ +sysfs_notify_dirent (led_cdev->brightness_kn); +} +EXPORT_SYMBOL_GPL (led_notify_brightness_change); +/* Caller must ensure led_cdev->led_access held */ void led_sysfs_disable (struct led_classdev *led_cdev) {
include/linux/leds.h +12 -0
@@ -13,6 +13,7 @@#define __LINUX_LEDS_H_INCLUDED#include <linux/device.h> +#include <linux/kernfs.h> #include <linux/list.h> #include <linux/mutex.h> #include <linux/rwsem.h>
@@ -94,6 +95,8 @@ struct led_classdev {struct work_struct set_brightness_work;int delayed_set_value; +struct kernfs_node *brightness_kn; +#ifdef CONFIG_LEDS_TRIGGERS /* Protects the trigger data below */ struct rw_semaphore trigger_lock;
@@ -193,6 +196,15 @@ extern int led_set_brightness_sync(struct led_classdev *led_cdev,extern int led_update_brightness (struct led_classdev *led_cdev);/** +* led_notify_brightness_change - Notify userspace of brightness changes +* @led_cdev: the LED to do the notify on +* +* Let any users waiting for POLL_PRI on the led's brightness sysfs +* atrribute know that the brightness has been changed. +*/ +extern void led_notify_brightness_change (struct led_classdev *led_cdev); + +/** * led_sysfs_disable - disable LED sysfs interface * @led_cdev: the LED to set *
Signature · 1 line
2.9.3
PATCH v2 2/4 platform: x86: dell-smbios: Add a generic dell-smbios notifier chain
There are several cases where events handled in one of the dell-* drivers need to be propagated to another dell-* driver.
This commits add 3 generic functions:dell_smbios_register_notifier()dell_smbios_unregister_notifier()dell_smbios_call_notifier()
It currently only defines 1 action:dell_smbios_kbd_backlight_brightness_changed
Which is intended to propagate kbd_backlight_brightness_changed wmi events from dell-wmi to dell-laptop (which contains the actual kbd backlight driver).
This is only somewhat dell smbios related, both dell-wmi and dell-laptop use smbios functions and I do not want to put the notifier head in either driver, as that will make the 2 drivers depend on each other.
---
Changes in v2:
-This is a new patch in v2 of this patch-set
--- drivers/platform/x86/dell-smbios.c | 20 ++++++++++++++++++++ drivers/platform/x86/dell-smbios.h | 11 +++++++++++ 2 files changed, 31 insertions(+)
drivers/platform/x86/dell-smbios.c +20 -0
@@ -105,6 +105,26 @@ struct calling_interface_token *dell_smbios_find_token(int tokenid) }EXPORT_SYMBOL_GPL (dell_smbios_find_token); +static ATOMIC_NOTIFIER_HEAD (dell_smbios_chain_head); + +int dell_smbios_register_notifier (struct notifier_block *nb) +{ +return atomic_notifier_chain_register (&dell_smbios_chain_head, nb); +} +EXPORT_SYMBOL_GPL (dell_smbios_register_notifier); + +int dell_smbios_unregister_notifier (struct notifier_block *nb) +{ +return atomic_notifier_chain_unregister (&dell_smbios_chain_head, nb); +} +EXPORT_SYMBOL_GPL (dell_smbios_unregister_notifier); + +void dell_smbios_call_notifier (unsigned long action,void *data) +{ +atomic_notifier_call_chain (&dell_smbios_chain_head, action, data); +} +EXPORT_SYMBOL_GPL (dell_smbios_call_notifier); +static void __init parse_da_table (const struct dmi_header *dm) {/* Final token is a terminator, so we don't want to copy it */
drivers/platform/x86/dell-smbios.h +11 -0
@@ -16,6 +16,8 @@#ifndef _DELL_SMBIOS_H_#define _DELL_SMBIOS_H_ +struct notifier_block ; +/* This structure will be modified by the firmware when we enter * system management mode, hence the volatiles */
@@ -43,4 +45,13 @@ void dell_smbios_release_buffer(void);void dell_smbios_send_request (int class,int select);struct calling_interface_token *dell_smbios_find_token (int tokenid); + +enum dell_smbios_notifier_actions { + dell_smbios_kbd_backlight_brightness_changed, +}; + +int dell_smbios_register_notifier (struct notifier_block *nb); +int dell_smbios_unregister_notifier (struct notifier_block *nb); +void dell_smbios_call_notifier (unsigned long action,void *data); +#endif
Signature · 1 line
2.9.3
PATCH v2 3/4 platform: x86: dell-*: Call led_notify_brightness_change on kbd brightness change
In reply to Hans de GoedeMake dell-wmi call led_notify_brightness_change on the kbd_led led_classdev registered by dell-laptop when the kbd backlight brightness changes.
--- drivers/platform/x86/dell-laptop.c | 28 +++++++++++++++++++++++++++- drivers/platform/x86/dell-wmi.c | 5 +++++ 2 files changed, 32 insertions(+), 1 deletion(-)
drivers/platform/x86/dell-laptop.c +27 -1
@@ -1942,6 +1942,8 @@ static struct led_classdev kbd_led = {static int __init kbd_led_init (struct device *dev) { +int ret; +kbd_init ();if (!kbd_led_present)return -ENODEV ;
@@ -1953,7 +1955,11 @@ static int __init kbd_led_init(struct device *dev)if (kbd_led.max_brightness) kbd_led.max_brightness--; } -return led_classdev_register (dev, &kbd_led); + ret =led_classdev_register (dev, &kbd_led); +if (ret) + kbd_led_present = false; + +return ret; } static void brightness_set_exit(struct led_classdev *led_cdev,
@@ -1970,6 +1976,23 @@ static void kbd_led_exit(void)led_classdev_unregister (&kbd_led); } +static int dell_laptop_notifier_call (struct notifier_block *nb, +unsigned long action,void *data) +{ +switch (action) { +case dell_smbios_kbd_backlight_brightness_changed: +if (kbd_led_present) +led_notify_brightness_change (&kbd_led); +break ; + } + +return NOTIFY_OK ; +} + +static struct notifier_block dell_laptop_notifier = { + .notifier_call = dell_laptop_notifier_call, +}; +static int __init dell_init (void ) {struct calling_interface_buffer *buffer;
@@ -2013,6 +2036,8 @@ static int __init dell_init(void)debugfs_create_file ("rfkill" ,0444 , dell_laptop_dir,NULL , &dell_debugfs_fops); +dell_smbios_register_notifier (&dell_laptop_notifier); +if (acpi_video_get_backlight_type () != acpi_backlight_vendor)return 0 ;
@@ -2064,6 +2089,7 @@ static int __init dell_init(void) static void __exit dell_exit(void) { +dell_smbios_unregister_notifier (&dell_laptop_notifier);debugfs_remove_recursive (dell_laptop_dir);if (quirks && quirks->touchpad_led)touchpad_led_exit ();
drivers/platform/x86/dell-wmi.c +5 -0
@@ -319,6 +319,11 @@ static void dell_wmi_process_key(int type, int code)if (type ==0x0000 && code ==0xe025 && !wmi_requires_smbios_request)return ; +if (type ==0x0011 && (code ==0x01e1 || code ==0x02ea || + code ==0x02eb || code ==0x02ec || code ==0x02f6 )) +dell_smbios_call_notifier ( + dell_smbios_kbd_backlight_brightness_changed,NULL ); +sparse_keymap_report_entry (dell_wmi_input_dev, key,1 , true); }
Signature · 1 line
2.9.3
PATCH v2 4/4 platform: x86: dell-*: Simplify dell-rbtn integration with dell-laptop [untested]
In reply to Hans de GoedeUse dell_smbios*notifier for dell-laptop to listen to dell-rbtn slider events, replace dell_rbtn_notifier_register() / dell_rbtn_notifier_unregister() with a single dell_rbtn_has_rfkill() used by dell-laptop to decide whether or not to use the i8042 filter and used by dell-rbtn to auto-remove its rfkill interface when called.
This results in a nice cleanup, downside is that the rfkill interface of dell-rbtn is not automatically re-enabled on rmmod dell-laptop, this now requires rmmod + insmod of dell-rbtn. But people who do not want dell-laptop for some reason will have it blacklisted anyways, so this is not an issue and there is a work-around.
---
Changes in v2:
-This is a new patch in v2 of my platform/x86/dell-* notifier set intended
to show how dell_smbios*notifier can be used to improve the dell-rbtn integration too
--- drivers/platform/x86/Kconfig | 1 + drivers/platform/x86/dell-laptop.c | 53 +++++++------------------------- drivers/platform/x86/dell-rbtn.c | 63 +++++++++----------------------------- drivers/platform/x86/dell-rbtn.h | 5 +-- drivers/platform/x86/dell-smbios.h | 1 + 5 files changed, 29 insertions(+), 94 deletions(-)
drivers/platform/x86/Kconfig +1 -0
@@ -158,6 +158,7 @@ config DELL_RBTN depends on ACPI depends on INPUT depends on RFKILL + depends on DELL_SMBIOS ---help--- Say Y here if you want to support Dell Airplane Mode Switch ACPI device on Dell laptops. Sometimes it has names: DELLABCE or DELRBTN.
drivers/platform/x86/dell-laptop.c +11 -42
84 lines not on this page · raw message
drivers/platform/x86/dell-rbtn.c +15 -48
110 lines not on this page · raw message
drivers/platform/x86/dell-rbtn.h +1 -4
@@ -16,9 +16,6 @@#ifndef _DELL_RBTN_H_#define _DELL_RBTN_H_ -struct notifier_block ; - -int dell_rbtn_notifier_register (struct notifier_block *nb); -int dell_rbtn_notifier_unregister (struct notifier_block *nb); +int dell_rbtn_has_rfkill (void );#endif
drivers/platform/x86/dell-smbios.h +1 -0
@@ -48,6 +48,7 @@ struct calling_interface_token *dell_smbios_find_token(int tokenid);enum dell_smbios_notifier_actions { dell_smbios_kbd_backlight_brightness_changed, + dell_smbios_rbtn_slider, };int dell_smbios_register_notifier (struct notifier_block *nb);
Signature · 1 line
2.9.3
Re: [PATCH v2 2/4] platform: x86: dell-smbios: Add a generic dell-smbios notifier chain
In reply to Hans de GoedeQuoted 76 lines · On Sunday 23 October 2016 21:46:50 Hans de Goede wrote:
There are several cases where events handled in one of the dell-* drivers need to be propagated to another dell-* driver.
This commits add 3 generic functions:
dell_smbios_register_notifier()dell_smbios_unregister_notifier()dell_smbios_call_notifier()It currently only defines 1 action:
dell_smbios_kbd_backlight_brightness_changedWhich is intended to propagate
kbd_backlight_brightness_changedwmi events from dell-wmi to dell-laptop (which contains the actual kbd backlight driver).This is only somewhat dell smbios related, both dell-wmi and dell-laptop use smbios functions and I do not want to put the notifier head in either driver, as that will make the 2 drivers depend on each other.
Signed-off-by Hans de Goede <[email protected]>---
Changes in v2:(quoted diff) +0
-2-This is a new patch in v2 of this patch-set --- drivers/platform/x86/dell-smbios.c | 20 ++++++++++++++++++++ drivers/platform/x86/dell-smbios.h | 11 +++++++++++ 2 files changed, 31 insertions(+)drivers/platform/x86/dell-smbios.c +20
-0@@ -105,6 +105,26 @@ struct calling_interface_token *dell_smbios_find_token(int tokenid) }EXPORT_SYMBOL_GPL (dell_smbios_find_token); +static ATOMIC_NOTIFIER_HEAD (dell_smbios_chain_head); + +int dell_smbios_register_notifier (struct notifier_block *nb) +{ +return atomic_notifier_chain_register (&dell_smbios_chain_head, nb); +} +EXPORT_SYMBOL_GPL (dell_smbios_register_notifier); + +int dell_smbios_unregister_notifier (struct notifier_block *nb) +{ +return atomic_notifier_chain_unregister (&dell_smbios_chain_head, nb); +} +EXPORT_SYMBOL_GPL (dell_smbios_unregister_notifier); + +void dell_smbios_call_notifier (unsigned long action,void *data) +{ +atomic_notifier_call_chain (&dell_smbios_chain_head, action, data); +} +EXPORT_SYMBOL_GPL (dell_smbios_call_notifier); +static void __init parse_da_table (const struct dmi_header *dm) {/* Final token is a terminator, so we don't want to copy it */ drivers/platform/x86/dell-smbios.h +2
-0@@ -16,6 +16,8 @@#ifndef _DELL_SMBIOS_H_#define _DELL_SMBIOS_H_ +struct notifier_block ; +/* This structure will be modified by the firmware when we enter * system management mode, hence the volatiles */ @@ -43,4 +45,13 @@ void dell_smbios_release_buffer(void);void dell_smbios_send_request (int class,int select);struct calling_interface_token *dell_smbios_find_token (int tokenid);
drivers/platform/x86/dell-smbios.h void dell_smbios_release_buffer(void); · line 57
Quoted 10 lines
drivers/platform/x86/dell-smbios.h +9
-0+ +enum dell_smbios_notifier_actions { + dell_smbios_kbd_backlight_brightness_changed, +}; + +int dell_smbios_register_notifier (struct notifier_block *nb); +int dell_smbios_unregister_notifier (struct notifier_block *nb); +void dell_smbios_call_notifier (unsigned long action,void *data); +#endif
That is better but technically speaking those notifiers do not have nothing common with dell-smbios :-( Driver dell-smbios.ko provides API for sending SMBIOS requests via SMM. Maybe move those functions into separate module (and built statically into kernel)? Just speculation, do not have something useful in my mind.
Signature · 2 lines
Pali Rohár [email protected]
Re: [PATCH v2 3/4] platform: x86: dell-*: Call led_notify_brightness_change on kbd brightness change
In reply to Hans de GoedeQuoted 6 lines · On Sunday 23 October 2016 21:46:51 Hans de Goede wrote:
drivers/platform/x86/dell-wmi.c +0
-0@@ -319,6 +319,11 @@ static void dell_wmi_process_key(int type, int code)if (type ==0x0000 && code ==0xe025 && !wmi_requires_smbios_request)
drivers/platform/x86/dell-wmi.c static void dell_wmi_process_key(int type, int code) · line 329
Quoted 10 lines
drivers/platform/x86/dell-wmi.c +5
-0return ; +if (type ==0x0011 && (code ==0x01e1 || code ==0x02ea || + code ==0x02eb || code ==0x02ec || code ==0x02f6 )) +dell_smbios_call_notifier ( + dell_smbios_kbd_backlight_brightness_changed,NULL ); +sparse_keymap_report_entry (dell_wmi_input_dev, key,1 , true); }
This part of patch is ugly. Some random numbers are checked and then notifier is called. We already have big table with explanation of those events... It is not possible to extend it with some flag or somehow other that value should be called via notifier?
Btw, personally I would use uppercase DELL_SMBIOS_KBD_... name from that enum, but I do not know what is correct coding style here for kernel.
Signature · 2 lines
Pali Rohár [email protected]
Re: [PATCH v2 2/4] platform: x86: dell-smbios: Add a generic dell-smbios notifier chain
In reply to Pali RohárHi,
Quoted 76 lines · Pali Rohár
Quoted 75 lines · On Sunday 23 October 2016 21:46:50 Hans de Goede wrote:
There are several cases where events handled in one of the dell-* drivers need to be propagated to another dell-* driver.
This commits add 3 generic functions:
dell_smbios_register_notifier()dell_smbios_unregister_notifier()dell_smbios_call_notifier()It currently only defines 1 action:
dell_smbios_kbd_backlight_brightness_changedWhich is intended to propagate
kbd_backlight_brightness_changedwmi events from dell-wmi to dell-laptop (which contains the actual kbd backlight driver).This is only somewhat dell smbios related, both dell-wmi and dell-laptop use smbios functions and I do not want to put the notifier head in either driver, as that will make the 2 drivers depend on each other.
Signed-off-by Hans de Goede <[email protected]>---
Changes in v2:(quoted diff) +0
-2-This is a new patch in v2 of this patch-set --- drivers/platform/x86/dell-smbios.c | 20 ++++++++++++++++++++ drivers/platform/x86/dell-smbios.h | 11 +++++++++++ 2 files changed, 31 insertions(+)drivers/platform/x86/dell-smbios.c +20
-0@@ -105,6 +105,26 @@ struct calling_interface_token *dell_smbios_find_token(int tokenid) }EXPORT_SYMBOL_GPL (dell_smbios_find_token); +static ATOMIC_NOTIFIER_HEAD (dell_smbios_chain_head); + +int dell_smbios_register_notifier (struct notifier_block *nb) +{ +return atomic_notifier_chain_register (&dell_smbios_chain_head, nb); +} +EXPORT_SYMBOL_GPL (dell_smbios_register_notifier); + +int dell_smbios_unregister_notifier (struct notifier_block *nb) +{ +return atomic_notifier_chain_unregister (&dell_smbios_chain_head, nb); +} +EXPORT_SYMBOL_GPL (dell_smbios_unregister_notifier); + +void dell_smbios_call_notifier (unsigned long action,void *data) +{ +atomic_notifier_call_chain (&dell_smbios_chain_head, action, data); +} +EXPORT_SYMBOL_GPL (dell_smbios_call_notifier); +static void __init parse_da_table (const struct dmi_header *dm) {/* Final token is a terminator, so we don't want to copy it */ drivers/platform/x86/dell-smbios.h +2
-0@@ -16,6 +16,8 @@#ifndef _DELL_SMBIOS_H_#define _DELL_SMBIOS_H_ +struct notifier_block ; +/* This structure will be modified by the firmware when we enter * system management mode, hence the volatiles */ @@ -43,4 +45,13 @@ void dell_smbios_release_buffer(void);void dell_smbios_send_request (int class,int select);
Quoted 14 lines
drivers/platform/x86/dell-smbios.h void dell_smbios_release_buffer(void); · line 57
Quoted 11 lines
drivers/platform/x86/dell-smbios.h +9
-0struct calling_interface_token *dell_smbios_find_token (int tokenid); + +enum dell_smbios_notifier_actions { + dell_smbios_kbd_backlight_brightness_changed, +}; + +int dell_smbios_register_notifier (struct notifier_block *nb); +int dell_smbios_unregister_notifier (struct notifier_block *nb); +void dell_smbios_call_notifier (unsigned long action,void *data); +#endif That is better but technically speaking those notifiers do not have nothing common with dell-smbios :-(
Well WMI events get enabled via a SMBIOS call, and dell-laptop uses SMBIOS exclusively, so it seems to fit. Basically this is a case of we have to put this somewhere and dell-smbios is the best fit IMHO.
Regards,
Hans
Re: [PATCH v2 2/4] platform: x86: dell-smbios: Add a generic dell-smbios notifier chain
Quoted 1 line · On Monday 24 October 2016 15:37:31 Hans de Goede wrote:
Well WMI events get enabled via a SMBIOS call,
This is truth only for few laptops and only for one WMI event. Everything else is automatically enabled, no call is needed to issue.
Quoted 1 line
and dell-laptop uses SMBIOS exclusively
IIRC dell-led.ko uses also dell-smbio.ko, so it is not exclusive for dell-laptop.
Quoted 2 lines
so it seems to fit. Basically this is a case of
we have to put this somewhere and dell-smbios is the best fit IMHO.
Agree, we need to put it somewhere...
Basically we need to solve problem how (currently) 3 kernel modules can communicate. Does not kernel support such "bus/event" mechanism for this?
Signature · 2 lines
Pali Rohár [email protected]
Re: [PATCH v2 3/4] platform: x86: dell-*: Call led_notify_brightness_change on kbd brightness change
In reply to Pali RohárHi,
Quoted 9 lines · Pali Rohár
Quoted 8 lines · On Sunday 23 October 2016 21:46:51 Hans de Goede wrote:
drivers/platform/x86/dell-wmi.c +0
-0@@ -319,6 +319,11 @@ static void dell_wmi_process_key(int type, int code)if (type ==0x0000 && code ==0xe025 && !wmi_requires_smbios_request)return ;
Quoted 13 lines
drivers/platform/x86/dell-wmi.c static void dell_wmi_process_key(int type, int code) · line 329
Quoted 8 lines
drivers/platform/x86/dell-wmi.c +5
-0+if (type ==0x0011 && (code ==0x01e1 || code ==0x02ea || + code ==0x02eb || code ==0x02ec || code ==0x02f6 )) +dell_smbios_call_notifier ( + dell_smbios_kbd_backlight_brightness_changed,NULL ); +sparse_keymap_report_entry (dell_wmi_input_dev, key,1 , true); }This part of patch is ugly. Some random numbers are checked and then notifier is called. We already have big table with explanation of those events... It is not possible to extend it with some flag or somehow other that value should be called via notifier?
Nope, sparse_keymaps are a well defined API for, well, keymaps! The problem really is this commit:
Which mixes status-events and key-press events in one sparse-keymap, which happens to work because so far all the status events are using { KE_IGNORE, 0x...., { KEY_RESERVED } }, but now we want to actually do something and that shows that the above commit really is a bad idea (at least for the 0x0011 type events, if we (partially) revert that, then the ugly if goes away and I can simply insert the dell_smbios_call_notifier() above the break in the original switch-case handling for 0x0011 type events.
So shall I revert the 0011 part of the mentioned commit?
That is actually what I had in an earlier (never posted) version of the patch-set.
Regards,
Hans
Re: [PATCH v2 2/4] platform: x86: dell-smbios: Add a generic dell-smbios notifier chain
In reply to Pali RohárHi,
Quoted 11 lines · Pali Rohár
Quoted 1 line · On Monday 24 October 2016 15:37:31 Hans de Goede wrote:
Well WMI events get enabled via a SMBIOS call,
This is truth only for few laptops and only for one WMI event. Everything else is automatically enabled, no call is needed to issue.
Quoted 1 line
and dell-laptop uses SMBIOS exclusively
IIRC dell-led.ko uses also dell-smbio.ko, so it is not exclusive for dell-laptop.
Quoted 8 lines
Quoted 2 lines
so it seems to fit. Basically this is a case of
we have to put this somewhere and dell-smbios is the best fit IMHO.Agree, we need to put it somewhere...
Basically we need to solve problem how (currently) 3 kernel modules can communicate. Does not kernel support such "bus/event" mechanism for this?
Yes it does, that is exactly what notifiers are for, but we need to declare the bus somewhere. I still believe dell-smbios is the best place.
Regards,
Hans
Re: [PATCH v2 3/4] platform: x86: dell-*: Call led_notify_brightness_change on kbd brightness change
In reply to Hans de GoedeQuoted 40 lines · On Monday 24 October 2016 15:43:50 Hans de Goede wrote:
Hi,
Quoted 9 lines · Pali Rohár
Quoted 8 lines · On Sunday 23 October 2016 21:46:51 Hans de Goede wrote:
drivers/platform/x86/dell-wmi.c +0
-0@@ -319,6 +319,11 @@ static void dell_wmi_process_key(int type, int code)if (type ==0x0000 && code ==0xe025 && !wmi_requires_smbios_request)return ;Quoted 13 lines
drivers/platform/x86/dell-wmi.c static void dell_wmi_process_key(int type, int code) · line 329
Quoted 8 lines
drivers/platform/x86/dell-wmi.c +5
-0+if (type ==0x0011 && (code ==0x01e1 || code ==0x02ea || + code ==0x02eb || code ==0x02ec || code ==0x02f6 )) +dell_smbios_call_notifier ( + dell_smbios_kbd_backlight_brightness_changed,NULL ); +sparse_keymap_report_entry (dell_wmi_input_dev, key,1 , true); }This part of patch is ugly. Some random numbers are checked and then notifier is called. We already have big table with explanation of those events... It is not possible to extend it with some flag or somehow other that value should be called via notifier?
Nope,
sparse_keymapsare a well defined API for, well, keymaps! The problem really is this commit:Which mixes status-events and key-press events in one sparse-keymap, which happens to work because so far all the status events are using {
KE_IGNORE, 0x...., {KEY_RESERVED} }, but now we want to actually do something and that shows that the above commit really is a bad idea (at least for the0x0011type events, if we (partially) revert that, then the ugly if goes away and I can simply insert thedell_smbios_call_notifier()above the break in the original switch-case handling for0x0011type events.
Quoted 1 line
So shall I revert the 0011 part of the mentioned commit?
Does not help us, because keyboard backlight change event is also in dell_wmi_keymap_type_0000 table.
Another idea: instead of struct key_entry create new structure which reflect information which comes from dell's WMI:
u16 type (key, event or ignore)
u16 code (wmi code)
union { key, event } (linux keycode or enum notifier event)
Signature · 2 lines
Pali Rohár [email protected]
Re: [PATCH v2 3/4] platform: x86: dell-*: Call led_notify_brightness_change on kbd brightness change
Hi,
Quoted 41 lines · Pali Rohár
Quoted 40 lines · On Monday 24 October 2016 15:43:50 Hans de Goede wrote:
Hi,
Quoted 9 lines · Pali Rohár
Quoted 8 lines · On Sunday 23 October 2016 21:46:51 Hans de Goede wrote:
drivers/platform/x86/dell-wmi.c +0
-0@@ -319,6 +319,11 @@ static void dell_wmi_process_key(int type, int code)if (type ==0x0000 && code ==0xe025 && !wmi_requires_smbios_request)return ;Quoted 13 lines
drivers/platform/x86/dell-wmi.c static void dell_wmi_process_key(int type, int code) · line 329
Quoted 8 lines
drivers/platform/x86/dell-wmi.c +5
-0+if (type ==0x0011 && (code ==0x01e1 || code ==0x02ea || + code ==0x02eb || code ==0x02ec || code ==0x02f6 )) +dell_smbios_call_notifier ( + dell_smbios_kbd_backlight_brightness_changed,NULL ); +sparse_keymap_report_entry (dell_wmi_input_dev, key,1 , true); }This part of patch is ugly. Some random numbers are checked and then notifier is called. We already have big table with explanation of those events... It is not possible to extend it with some flag or somehow other that value should be called via notifier?
Nope,
sparse_keymapsare a well defined API for, well, keymaps! The problem really is this commit:Which mixes status-events and key-press events in one sparse-keymap, which happens to work because so far all the status events are using {
KE_IGNORE, 0x...., {KEY_RESERVED} }, but now we want to actually do something and that shows that the above commit really is a bad idea (at least for the0x0011type events, if we (partially) revert that, then the ugly if goes away and I can simply insert thedell_smbios_call_notifier()above the break in the original switch-case handling for0x0011type events.
Quoted 4 lines
Quoted 1 line
So shall I revert the 0011 part of the mentioned commit?
Does not help us, because keyboard backlight change event is also in
dell_wmi_keymap_type_0000table.
Hmm, the 0000 table contains:
/* Key code is followed by keyboard illumination level */
{ KE_IGNORE, 0xe00c, { KEY_KBDILLUMTOGGLE } },We could use the same keycode in the 0011 table for kbd brightness events and then do:
if (event->keycode == KEY_KBDILLUMTOGGLE) dell_smbios_kbd_backlight_brightness_changed, NULL);
I will send an updated version using this.
Regards,
Hans
Re: [PATCH v2 3/4] platform: x86: dell-*: Call led_notify_brightness_change on kbd brightness change
Quoted 11 lines · On Monday 24 October 2016 15:57:41 Hans de Goede wrote:
Hmm, the 0000 table contains:
/* Key code is followed by keyboard illumination level */ { KE_IGNORE, 0xe00c, { KEY_KBDILLUMTOGGLE } },We could use the same keycode in the 0011 table for kbd brightness events and then do:
if (event->keycode == KEY_KBDILLUMTOGGLE) dell_smbios_kbd_backlight_brightness_changed, NULL);I will send an updated version using this.
Yea, that is great!
Signature · 2 lines
Pali Rohár [email protected]
Hi Hans,
Thanks for the update.
Could you please rebase your patches onto recent linux-leds.git, for-next branch?
Also it would be convenient to have sample application for polling brightness changes in tools/leds.
Thanks,
Jacek Anaszewski
Quoted 159 lines · Hans de Goede
Add support for userspace using
poll()forPOLL_PRIon the sysfs brightness attr to watch for brightness changes.This commit adds a
led_notify_brightness_changehelper function for waking up anypoll()waiters; and calls this after any brightness changes (after any led_classdev->brightness_set[_blocking] calls have completed).In some use-cases led hardware may autonomously change its brightness, e.g. the keyboard backlight used on some laptops is controlled by a hardwired (firmware handled) hotkey.
led_notify_brightness_changeis exported for use by drivers which can detect such autonomous changes.This commit also updates the
Documentation/ABI/testing/sysfs-class-leddocumentation to document that userspace may now poll on the brightness attribute.Signed-off-by Hans de Goede <[email protected]>---
Changes in v2:(quoted diff) +0
-2-Wakeup / notify userspace on any brightness changes, not just on autonomous changes done by the hw --- Documentation/ABI/testing/sysfs-class-led | 8 ++++++-- drivers/leds/led-class.c | 9 +++++++++ drivers/leds/led-core.c | 16 +++++++++++++++- include/linux/leds.h | 12 ++++++++++++ 4 files changed, 42 insertions(+), 3 deletions(-)Documentation/ABI/testing/sysfs-class-led +6
-2@@ -1,12 +1,16 @@ What: /sys/class/leds/<led>/brightness -Date: March 2006 -KernelVersion: 2.6.17 +Date: March 2006 (poll October 2016) +KernelVersion: 2.6.17 (poll since 4.10) Contact: Richard Purdie <[email protected]> Description: Set the brightness of the LED. Most LEDs don't have hardware brightness support so will just be turned on for non-zero brightness settings. The value is between 0 and /sys/class/leds/<led>/max_brightness. + The file supports poll() to detect brightness changes, in + some cases the hardware / firmware may change the brightness + autonomously, poll() should be woken up in this case too, + but not all drivers may support this. What: /sys/class/leds/<led>/max_brightness Date: March 2006drivers/leds/led-class.c +9
-0@@ -203,6 +203,14 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)dev_warn (parent,"Led %s renamed to %s due to name collision" , led_cdev->name,dev_name (led_cdev->dev)); + led_cdev->brightness_kn =sysfs_get_dirent (led_cdev->dev->kobj.sd, +"brightness" ); +if (!led_cdev->brightness_kn) { +dev_err (led_cdev->dev,"Error getting brightness kernfs_node\n" ); +device_unregister (led_cdev->dev); +return -ENODEV ; + } +#ifdef CONFIG_LEDS_TRIGGERS init_rwsem (&led_cdev->trigger_lock);#endif @@ -254,6 +262,7 @@ void led_classdev_unregister(struct led_classdev *led_cdev)flush_work (&led_cdev->set_brightness_work); +sysfs_put (led_cdev->brightness_kn);device_unregister (led_cdev->dev);down_write (&leds_list_lock);drivers/leds/led-core.c +15
-1@@ -33,16 +33,24 @@ static int __led_set_brightness(struct led_classdev *led_cdev, led_cdev->brightness_set (led_cdev, value); +led_notify_brightness_change (led_cdev); +return 0 ; }static int __led_set_brightness_blocking (struct led_classdev *led_cdev,enum led_brightness value) { +int ret; +if (!led_cdev->brightness_set_blocking)return -ENOTSUPP ; -return led_cdev->brightness_set_blocking (led_cdev, value); + ret = led_cdev->brightness_set_blocking (led_cdev, value); +if (ret >=0 ) +led_notify_brightness_change (led_cdev); + +return ret; }static void led_timer_function (unsigned long data)@@ -308,6 +316,12 @@ int led_update_brightness(struct led_classdev *led_cdev) }EXPORT_SYMBOL_GPL (led_update_brightness); +void led_notify_brightness_change (struct led_classdev *led_cdev) +{ +sysfs_notify_dirent (led_cdev->brightness_kn); +} +EXPORT_SYMBOL_GPL (led_notify_brightness_change); +/* Caller must ensure led_cdev->led_access held */ void led_sysfs_disable (struct led_classdev *led_cdev) {include/linux/leds.h +12
-0@@ -13,6 +13,7 @@#define __LINUX_LEDS_H_INCLUDED#include <linux/device.h> +#include <linux/kernfs.h> #include <linux/list.h> #include <linux/mutex.h> #include <linux/rwsem.h> @@ -94,6 +95,8 @@ struct led_classdev {struct work_struct set_brightness_work;int delayed_set_value; +struct kernfs_node *brightness_kn; +#ifdef CONFIG_LEDS_TRIGGERS /* Protects the trigger data below */ struct rw_semaphore trigger_lock;@@ -193,6 +196,15 @@ extern int led_set_brightness_sync(struct led_classdev *led_cdev,extern int led_update_brightness (struct led_classdev *led_cdev);/** +* led_notify_brightness_change - Notify userspace of brightness changes +* @led_cdev: the LED to do the notify on +* +* Let any users waiting for POLL_PRI on the led's brightness sysfs +* atrribute know that the brightness has been changed. +*/ +extern void led_notify_brightness_change (struct led_classdev *led_cdev); + +/** * led_sysfs_disable - disable LED sysfs interface * @led_cdev: the LED to set *
Hi,
Quoted 5 lines · Jacek Anaszewski
Hi Hans,
Thanks for the update.
Could you please rebase your patches onto recent linux-leds.git, for-next branch?
Done, I will send a v3 soon (today or tomorrow).
Quoted 2 lines
Also it would be convenient to have sample application for polling brightness changes in
tools/leds.
I'm sorry but I do not have time to create such a sample application.
Regards,
Hans
Quoted 164 lines
Thanks,
Jacek AnaszewskiQuoted 159 lines · Hans de Goede
Add support for userspace using
poll()forPOLL_PRIon the sysfs brightness attr to watch for brightness changes.This commit adds a
led_notify_brightness_changehelper function for waking up anypoll()waiters; and calls this after any brightness changes (after any led_classdev->brightness_set[_blocking] calls have completed).In some use-cases led hardware may autonomously change its brightness, e.g. the keyboard backlight used on some laptops is controlled by a hardwired (firmware handled) hotkey.
led_notify_brightness_changeis exported for use by drivers which can detect such autonomous changes.This commit also updates the
Documentation/ABI/testing/sysfs-class-leddocumentation to document that userspace may now poll on the brightness attribute.Signed-off-by Hans de Goede <[email protected]>---
Changes in v2:(quoted diff) +0
-2-Wakeup / notify userspace on any brightness changes, not just on autonomous changes done by the hw --- Documentation/ABI/testing/sysfs-class-led | 8 ++++++-- drivers/leds/led-class.c | 9 +++++++++ drivers/leds/led-core.c | 16 +++++++++++++++- include/linux/leds.h | 12 ++++++++++++ 4 files changed, 42 insertions(+), 3 deletions(-)Documentation/ABI/testing/sysfs-class-led +6
-2@@ -1,12 +1,16 @@ What: /sys/class/leds/<led>/brightness -Date: March 2006 -KernelVersion: 2.6.17 +Date: March 2006 (poll October 2016) +KernelVersion: 2.6.17 (poll since 4.10) Contact: Richard Purdie <[email protected]> Description: Set the brightness of the LED. Most LEDs don't have hardware brightness support so will just be turned on for non-zero brightness settings. The value is between 0 and /sys/class/leds/<led>/max_brightness. + The file supports poll() to detect brightness changes, in + some cases the hardware / firmware may change the brightness + autonomously, poll() should be woken up in this case too, + but not all drivers may support this. What: /sys/class/leds/<led>/max_brightness Date: March 2006drivers/leds/led-class.c +9
-0@@ -203,6 +203,14 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)dev_warn (parent,"Led %s renamed to %s due to name collision" , led_cdev->name,dev_name (led_cdev->dev)); + led_cdev->brightness_kn =sysfs_get_dirent (led_cdev->dev->kobj.sd, +"brightness" ); +if (!led_cdev->brightness_kn) { +dev_err (led_cdev->dev,"Error getting brightness kernfs_node\n" ); +device_unregister (led_cdev->dev); +return -ENODEV ; + } +#ifdef CONFIG_LEDS_TRIGGERS init_rwsem (&led_cdev->trigger_lock);#endif @@ -254,6 +262,7 @@ void led_classdev_unregister(struct led_classdev *led_cdev)flush_work (&led_cdev->set_brightness_work); +sysfs_put (led_cdev->brightness_kn);device_unregister (led_cdev->dev);down_write (&leds_list_lock);drivers/leds/led-core.c +15
-1@@ -33,16 +33,24 @@ static int __led_set_brightness(struct led_classdev *led_cdev, led_cdev->brightness_set (led_cdev, value); +led_notify_brightness_change (led_cdev); +return 0 ; }static int __led_set_brightness_blocking (struct led_classdev *led_cdev,enum led_brightness value) { +int ret; +if (!led_cdev->brightness_set_blocking)return -ENOTSUPP ; -return led_cdev->brightness_set_blocking (led_cdev, value); + ret = led_cdev->brightness_set_blocking (led_cdev, value); +if (ret >=0 ) +led_notify_brightness_change (led_cdev); + +return ret; }static void led_timer_function (unsigned long data)@@ -308,6 +316,12 @@ int led_update_brightness(struct led_classdev *led_cdev) }EXPORT_SYMBOL_GPL (led_update_brightness); +void led_notify_brightness_change (struct led_classdev *led_cdev) +{ +sysfs_notify_dirent (led_cdev->brightness_kn); +} +EXPORT_SYMBOL_GPL (led_notify_brightness_change); +/* Caller must ensure led_cdev->led_access held */ void led_sysfs_disable (struct led_classdev *led_cdev) {include/linux/leds.h +12
-0@@ -13,6 +13,7 @@#define __LINUX_LEDS_H_INCLUDED#include <linux/device.h> +#include <linux/kernfs.h> #include <linux/list.h> #include <linux/mutex.h> #include <linux/rwsem.h> @@ -94,6 +95,8 @@ struct led_classdev {struct work_struct set_brightness_work;int delayed_set_value; +struct kernfs_node *brightness_kn; +#ifdef CONFIG_LEDS_TRIGGERS /* Protects the trigger data below */ struct rw_semaphore trigger_lock;@@ -193,6 +196,15 @@ extern int led_set_brightness_sync(struct led_classdev *led_cdev,extern int led_update_brightness (struct led_classdev *led_cdev);/** +* led_notify_brightness_change - Notify userspace of brightness changes +* @led_cdev: the LED to do the notify on +* +* Let any users waiting for POLL_PRI on the led's brightness sysfs +* atrribute know that the brightness has been changed. +*/ +extern void led_notify_brightness_change (struct led_classdev *led_cdev); + +/** * led_sysfs_disable - disable LED sysfs interface * @led_cdev: the LED to set *
Hi,
Quoted 9 lines · Hans de Goede
Hi,
Quoted 5 lines · Jacek Anaszewski
Hi Hans,
Thanks for the update.
Could you please rebase your patches onto recent linux-leds.git, for-next branch?
Quoted 6 lines
Done, I will send a v3 soon (today or tomorrow).
Quoted 2 lines
Also it would be convenient to have sample application for polling brightness changes in
tools/leds.I'm sorry but I do not have time to create such a sample application.
You must have tested your solution somehow. Just polish the code a bit, add a Makefile and that's it. Compare tools/leds/uledmon.c - it doesn't need to be anything big.
If you're adding a feature that interacts with userspace, then I'd like to have a sample code that shows how to use it. Just for a reference.
Signature · 2 lines
Best regards, Jacek Anaszewski
Hi,
Quoted 12 lines · Jacek Anaszewski
Hi,
Quoted 9 lines · Hans de Goede
Hi,
Quoted 5 lines · Jacek Anaszewski
Hi Hans,
Thanks for the update.
Could you please rebase your patches onto recent linux-leds.git, for-next branch?
Quoted 8 lines
Quoted 6 lines
Done, I will send a v3 soon (today or tomorrow).
Quoted 2 lines
Also it would be convenient to have sample application for polling brightness changes in
tools/leds.I'm sorry but I do not have time to create such a sample application.
You must have tested your solution somehow.
Yes, as is made clear by the other patches in this set, I'm using it with keyboard backlight control led interfaces. Which in userspace are handled by upower which provides a dbus interface which is used by gnome-settings-daemon.
Quoted 3 lines
Just polish the code a bit,
add aMakefileand that's it. Comparetools/leds/uledmon.c- it doesn't need to be anything big.
upower uses gio which is really not suitable for this, so I would need to create something from scratch.
Regards,
Hans
Quoted 4 lines
If you're adding a feature that interacts with userspace, then I'd like to have a sample code that shows how to use it. Just for a reference.
Quoted 29 lines · Hans de Goede
Hi,
Quoted 12 lines · Jacek Anaszewski
Hi,
Quoted 9 lines · Hans de Goede
Hi,
Quoted 5 lines · Jacek Anaszewski
Hi Hans,
Thanks for the update.
Could you please rebase your patches onto recent linux-leds.git, for-next branch?Quoted 8 lines
Quoted 6 lines
Done, I will send a v3 soon (today or tomorrow).
Quoted 2 lines
Also it would be convenient to have sample application for polling brightness changes in
tools/leds.I'm sorry but I do not have time to create such a sample application.
You must have tested your solution somehow.
Yes, as is made clear by the other patches in this set, I'm using it with keyboard backlight control led interfaces. Which in userspace are handled by upower which provides a dbus interface which is used by gnome-settings-daemon.
Quoted 6 lines
Quoted 3 lines
Just polish the code a bit,
add aMakefileand that's it. Comparetools/leds/uledmon.c- it doesn't need to be anything big.upower uses gio which is really not suitable for this, so I would need to create something from scratch.
Okay, so I'll have to do it myself, when I'll find a moment.
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH v2 2/4] platform: x86: dell-smbios: Add a generic dell-smbios notifier chain
In reply to Hans de GoedeQuoted 19 lines · On Monday 24 October 2016 15:45:02 Hans de Goede wrote:
Hi,
Quoted 16 lines · Pali Rohár
Quoted 1 line · On Monday 24 October 2016 15:37:31 Hans de Goede wrote:
Well WMI events get enabled via a SMBIOS call,
This is truth only for few laptops and only for one WMI event. Everything else is automatically enabled, no call is needed to issue.
Quoted 1 line
and dell-laptop uses SMBIOS exclusively
IIRC dell-led.ko uses also dell-smbio.ko, so it is not exclusive for dell-laptop.
Quoted 2 lines
so it seems to fit. Basically this is a case of
we have to put this somewhere and dell-smbios is the best fit IMHO.Agree, we need to put it somewhere...
Quoted 7 lines
Quoted 3 lines
Basically we need to solve problem how (currently) 3 kernel modules can communicate. Does not kernel support such "bus/event" mechanism for this?
Yes it does, that is exactly what notifiers are for, but we need to declare the bus somewhere. I still believe dell-smbios is the best place.
But dell_smbios_register_notifier() name is totally confusing. It does not register any notifier for SMBIOS. Nor it have nothing common with SMBIOS API.
Also there is absolutely no need that dell-rbtn.ko needs to depends on dell-smbios.ko. dell-rbtn.ko is ACPI driver which does not use any of SMBIOS API.
Right now I'm not saying what is the best place for that notifier (as I still do not have ideal candidate). I'm just saying that notifier is not part of SMBIOS API and therefore dell-smbios.ko is not right place for it.
So currently we have these different APIs for dell notebook drivers:
* ACPI (used in dell-rbtn.ko and dell-smo8800.ko)
* WMI (used in dell-wmi.ko, dell-wmi-aio.ko, dell-led.ko)
* SMBIOS (used in dell-laptop.ko, dell-wmi.ko and dell-led.ko)
* some other platform code (used in dell-laptop.ko)
And now notifier is needed for drivers:
* dell-laptop.ko
* dell-wmi.ko
* dell-rbtn.ko
And if I look at above two sets, none of above drivers is good candidate for central notifier functions... Maybe we should really introduce new separate file where will central dell notifier live?
Signature · 2 lines
Pali Rohár [email protected]
Re: [PATCH v2 2/4] platform: x86: dell-smbios: Add a generic dell-smbios notifier chain
HI,
Quoted 47 lines · Pali Rohár
Quoted 19 lines · On Monday 24 October 2016 15:45:02 Hans de Goede wrote:
Hi,
Quoted 16 lines · Pali Rohár
Quoted 1 line · On Monday 24 October 2016 15:37:31 Hans de Goede wrote:
Well WMI events get enabled via a SMBIOS call,
This is truth only for few laptops and only for one WMI event. Everything else is automatically enabled, no call is needed to issue.
Quoted 1 line
and dell-laptop uses SMBIOS exclusively
IIRC dell-led.ko uses also dell-smbio.ko, so it is not exclusive for dell-laptop.
Quoted 2 lines
so it seems to fit. Basically this is a case of
we have to put this somewhere and dell-smbios is the best fit IMHO.Agree, we need to put it somewhere...
Quoted 7 lines
Quoted 3 lines
Basically we need to solve problem how (currently) 3 kernel modules can communicate. Does not kernel support such "bus/event" mechanism for this?
Yes it does, that is exactly what notifiers are for, but we need to declare the bus somewhere. I still believe dell-smbios is the best place.
But
dell_smbios_register_notifier()name is totally confusing. It does not register any notifier for SMBIOS. Nor it have nothing common with SMBIOS API.Also there is absolutely no need that dell-rbtn.ko needs to depends on dell-smbios.ko. dell-rbtn.ko is ACPI driver which does not use any of SMBIOS API.
Right now I'm not saying what is the best place for that notifier (as I still do not have ideal candidate). I'm just saying that notifier is not part of SMBIOS API and therefore dell-smbios.ko is not right place for it.
So currently we have these different APIs for dell notebook drivers:
* ACPI (used in dell-rbtn.ko and dell-smo8800.ko)
* WMI (used in dell-wmi.ko, dell-wmi-aio.ko, dell-led.ko)
* SMBIOS (used in dell-laptop.ko, dell-wmi.ko and dell-led.ko)
* some other platform code (used in dell-laptop.ko)
Quoted 8 lines
And now notifier is needed for drivers:
* dell-laptop.ko
* dell-wmi.ko
* dell-rbtn.koAnd if I look at above two sets, none of above drivers is good candidate for central notifier functions... Maybe we should really introduce new separate file where will central dell notifier live?
We could put this in a dell-common or some such. My main reason for going with dell-smbios is that dell-smbios is a "library" module, loading it does not do anything other then make symbols available for use by other modules. So using it to store the notifier is safe (no side effects even if e.g. only dell-rbtn gets loaded).
Given that we already have dell-smbios as dell library functions module, I think that adding a dell-common is a bit overkill.
I can rename the notifier, maybe use dell_laptop*notifier as names, since dell-laptop is the main consumer of the notifications ?
Regards,
Hans
Re: [PATCH v2 2/4] platform: x86: dell-smbios: Add a generic dell-smbios notifier chain
Quoted 59 lines · On Thursday 27 October 2016 14:45:20 Hans de Goede wrote:
HI,
Quoted 47 lines · Pali Rohár
Quoted 19 lines · On Monday 24 October 2016 15:45:02 Hans de Goede wrote:
Hi,
Quoted 16 lines · Pali Rohár
Quoted 1 line · On Monday 24 October 2016 15:37:31 Hans de Goede wrote:
Well WMI events get enabled via a SMBIOS call,
This is truth only for few laptops and only for one WMI event. Everything else is automatically enabled, no call is needed to issue.
Quoted 1 line
and dell-laptop uses SMBIOS exclusively
IIRC dell-led.ko uses also dell-smbio.ko, so it is not exclusive for dell-laptop.
Quoted 2 lines
so it seems to fit. Basically this is a case of
we have to put this somewhere and dell-smbios is the best fit IMHO.Agree, we need to put it somewhere...
Quoted 7 lines
Quoted 3 lines
Basically we need to solve problem how (currently) 3 kernel modules can communicate. Does not kernel support such "bus/event" mechanism for this?
Yes it does, that is exactly what notifiers are for, but we need to declare the bus somewhere. I still believe dell-smbios is the best place.
But
dell_smbios_register_notifier()name is totally confusing. It does not register any notifier for SMBIOS. Nor it have nothing common with SMBIOS API.Also there is absolutely no need that dell-rbtn.ko needs to depends on dell-smbios.ko. dell-rbtn.ko is ACPI driver which does not use any of SMBIOS API.
Right now I'm not saying what is the best place for that notifier (as I still do not have ideal candidate). I'm just saying that notifier is not part of SMBIOS API and therefore dell-smbios.ko is not right place for it.
So currently we have these different APIs for dell notebook drivers:
* ACPI (used in dell-rbtn.ko and dell-smo8800.ko)
* WMI (used in dell-wmi.ko, dell-wmi-aio.ko, dell-led.ko)
* SMBIOS (used in dell-laptop.ko, dell-wmi.ko and dell-led.ko)
* some other platform code (used in dell-laptop.ko)Quoted 8 lines
And now notifier is needed for drivers:
* dell-laptop.ko
* dell-wmi.ko
* dell-rbtn.koAnd if I look at above two sets, none of above drivers is good candidate for central notifier functions... Maybe we should really introduce new separate file where will central dell notifier live?
Quoted 5 lines
We could put this in a dell-common or some such. My main reason for going with dell-smbios is that dell-smbios is a "library" module, loading it does not do anything other then make symbols available for use by other modules. So using it to store the notifier is safe (no side effects even if e.g. only dell-rbtn gets loaded).
I understand your motivation.
Quoted 2 lines
Given that we already have dell-smbios as dell library functions module, I think that adding a dell-common is a bit overkill.
New module is probably really overkill... But cannot we link add those notifier functions statically? So it would not be new module.
Quoted 2 lines
I can rename the notifier, maybe use dell_laptop*notifier as names, since dell-laptop is the main consumer of the notifications ?
Yes, this is name is better!
Signature · 2 lines
Pali Rohár [email protected]
Re: [PATCH v2 2/4] platform: x86: dell-smbios: Add a generic dell-smbios notifier chain
Hi,
Quoted 66 lines · Pali Rohár
Quoted 59 lines · On Thursday 27 October 2016 14:45:20 Hans de Goede wrote:
HI,
Quoted 47 lines · Pali Rohár
Quoted 19 lines · On Monday 24 October 2016 15:45:02 Hans de Goede wrote:
Hi,
Quoted 16 lines · Pali Rohár
Quoted 1 line · On Monday 24 October 2016 15:37:31 Hans de Goede wrote:
Well WMI events get enabled via a SMBIOS call,
This is truth only for few laptops and only for one WMI event. Everything else is automatically enabled, no call is needed to issue.
Quoted 1 line
and dell-laptop uses SMBIOS exclusively
IIRC dell-led.ko uses also dell-smbio.ko, so it is not exclusive for dell-laptop.
Quoted 2 lines
so it seems to fit. Basically this is a case of
we have to put this somewhere and dell-smbios is the best fit IMHO.Agree, we need to put it somewhere...
Quoted 7 lines
Quoted 3 lines
Basically we need to solve problem how (currently) 3 kernel modules can communicate. Does not kernel support such "bus/event" mechanism for this?
Yes it does, that is exactly what notifiers are for, but we need to declare the bus somewhere. I still believe dell-smbios is the best place.
But
dell_smbios_register_notifier()name is totally confusing. It does not register any notifier for SMBIOS. Nor it have nothing common with SMBIOS API.Also there is absolutely no need that dell-rbtn.ko needs to depends on dell-smbios.ko. dell-rbtn.ko is ACPI driver which does not use any of SMBIOS API.
Right now I'm not saying what is the best place for that notifier (as I still do not have ideal candidate). I'm just saying that notifier is not part of SMBIOS API and therefore dell-smbios.ko is not right place for it.
So currently we have these different APIs for dell notebook drivers:
* ACPI (used in dell-rbtn.ko and dell-smo8800.ko)
* WMI (used in dell-wmi.ko, dell-wmi-aio.ko, dell-led.ko)
* SMBIOS (used in dell-laptop.ko, dell-wmi.ko and dell-led.ko)
* some other platform code (used in dell-laptop.ko)Quoted 8 lines
And now notifier is needed for drivers:
* dell-laptop.ko
* dell-wmi.ko
* dell-rbtn.koAnd if I look at above two sets, none of above drivers is good candidate for central notifier functions... Maybe we should really introduce new separate file where will central dell notifier live?
Quoted 5 lines
We could put this in a dell-common or some such. My main reason for going with dell-smbios is that dell-smbios is a "library" module, loading it does not do anything other then make symbols available for use by other modules. So using it to store the notifier is safe (no side effects even if e.g. only dell-rbtn gets loaded).
Quoted 7 lines
I understand your motivation.
Quoted 2 lines
Given that we already have dell-smbios as dell library functions module, I think that adding a dell-common is a bit overkill.
New module is probably really overkill... But cannot we link add those notifier functions statically? So it would not be new module.
No, we need to put the notifier_head somewhere, at which point making the actual notifier functions inline static is not really helpful.
Quoted 4 lines
Quoted 2 lines
I can rename the notifier, maybe use dell_laptop*notifier as names, since dell-laptop is the main consumer of the notifications ?
Yes, this is name is better!
Ok, I will change this for the next version.
Regards,
Hans
Re: [PATCH v2 2/4] platform: x86: dell-smbios: Add a generic dell-smbios notifier chain
Quoted 74 lines · On Thursday 27 October 2016 14:54:54 Hans de Goede wrote:
Hi,
Quoted 71 lines · Pali Rohár
Quoted 59 lines · On Thursday 27 October 2016 14:45:20 Hans de Goede wrote:
HI,
Quoted 47 lines · Pali Rohár
Quoted 19 lines · On Monday 24 October 2016 15:45:02 Hans de Goede wrote:
Hi,
Quoted 16 lines · Pali Rohár
Quoted 1 line · On Monday 24 October 2016 15:37:31 Hans de Goede wrote:
Well WMI events get enabled via a SMBIOS call,
This is truth only for few laptops and only for one WMI event. Everything else is automatically enabled, no call is needed to issue.
Quoted 1 line
and dell-laptop uses SMBIOS exclusively
IIRC dell-led.ko uses also dell-smbio.ko, so it is not exclusive for dell-laptop.
Quoted 2 lines
so it seems to fit. Basically this is a case of
we have to put this somewhere and dell-smbios is the best fit IMHO.Agree, we need to put it somewhere...
Quoted 7 lines
Quoted 3 lines
Basically we need to solve problem how (currently) 3 kernel modules can communicate. Does not kernel support such "bus/event" mechanism for this?
Yes it does, that is exactly what notifiers are for, but we need to declare the bus somewhere. I still believe dell-smbios is the best place.
But
dell_smbios_register_notifier()name is totally confusing. It does not register any notifier for SMBIOS. Nor it have nothing common with SMBIOS API.Also there is absolutely no need that dell-rbtn.ko needs to depends on dell-smbios.ko. dell-rbtn.ko is ACPI driver which does not use any of SMBIOS API.
Right now I'm not saying what is the best place for that notifier (as I still do not have ideal candidate). I'm just saying that notifier is not part of SMBIOS API and therefore dell-smbios.ko is not right place for it.
So currently we have these different APIs for dell notebook drivers:
* ACPI (used in dell-rbtn.ko and dell-smo8800.ko)
* WMI (used in dell-wmi.ko, dell-wmi-aio.ko, dell-led.ko)
* SMBIOS (used in dell-laptop.ko, dell-wmi.ko and dell-led.ko)
* some other platform code (used in dell-laptop.ko)Quoted 8 lines
And now notifier is needed for drivers:
* dell-laptop.ko
* dell-wmi.ko
* dell-rbtn.koAnd if I look at above two sets, none of above drivers is good candidate for central notifier functions... Maybe we should really introduce new separate file where will central dell notifier live?
Quoted 5 lines
We could put this in a dell-common or some such. My main reason for going with dell-smbios is that dell-smbios is a "library" module, loading it does not do anything other then make symbols available for use by other modules. So using it to store the notifier is safe (no side effects even if e.g. only dell-rbtn gets loaded).
I understand your motivation.
Quoted 2 lines
Given that we already have dell-smbios as dell library functions module, I think that adding a dell-common is a bit overkill.
Quoted 6 lines
Quoted 2 lines
New module is probably really overkill... But cannot we link add those notifier functions statically? So it would not be new module.
No, we need to put the
notifier_headsomewhere, at which point making the actual notifier functions inline static is not really helpful.
I mean object file which will not be tristate, but only Y/N and selected automatically when dell-laptop is Y or M. Not inline static functions.
Quoted 10 lines
Quoted 4 lines
Quoted 2 lines
I can rename the notifier, maybe use dell_laptop*notifier as names, since dell-laptop is the main consumer of the notifications ?
Yes, this is name is better!
Ok, I will change this for the next version.
Regards,
Hans
Signature · 2 lines
Pali Rohár [email protected]