Move dell-led to drivers/platform/x86
Subsystems (3)
v3 cover Move dell-led to drivers/platform/x86
This patch series moves the dell-led driver from the LED subsystem to the x86 platform driver subsystem.
The original motivation behind this effort was to move all code using the dell-smbios module to the x86 platform driver subsystem. While I was investigating the possibilities to do that, it quickly emerged that dell-led can and in fact should be moved to the x86 platform driver subsystem in its entirety.
dell-led consists of two major parts:
- the part exposing a microphone mute LED interface, introduced in db6d8cc00773 ("dell-led: add mic mute led interface"); this interface is used by sound/pci/hda/dell_wmi_helper.c; while the original implementation used a WMI interface, it was changed to use dell-smbios in cf0d7ea33596 ("dell-led: use dell_smbios_find_token() for finding mic DMI tokens") and 0c41a08e131d ("dell-led: use dell_smbios_send_request() for performing SMBIOS calls"),
- the part handling an activity LED present in Dell Latitude 2100 netbooks, introduced in 72dcd8d08aca ("leds: Add Dell Business Class Netbook LED driver"); it binds to a specific WMI GUID and then registers a LED device which is controlled using WMI (i.e. it is essentially a WMI driver).
Patches 1 and 2 clean up the microphone mute LED interface to minimize the amount of code moved around.
Patch 3 updates a variable name in sound/pci/hda/dell_wmi_helper.c so that it better matches that variable's role.
Patch 4 moves the microphone mute LED interface to drivers/platform/x86/dell-laptop.c, effectively causing sound/pci/hda/dell_wmi_helper.c to depend on CONFIG_DELL_LAPTOP instead of CONFIG_LEDS_DELL_NETBOOKS.
Patch 5 reverts dell-led to the state it was in after its initial commit 72dcd8d08aca ("leds: Add Dell Business Class Netbook LED driver") by removing all remnants of the microphone mute LED handling code.
Patch 6 moves all that is left of dell-led (i.e. the activity LED part, as originally implemented), to a new module which is placed in drivers/platform/x86/dell-wmi-led.c.
Patch 7 fixes coding style issues in drivers/platform/x86/dell-wmi-led.c to make sure it gets a clean start in the x86 platform driver subsystem.
As all patches except patch 3 in this series affect the LED subsystem, the series is based on linux-leds/for-next.
Changes from v2:
- Add patch 7 fixing coding style issues (feedback from Joe and Andy taken into account).
- Add leading zero to constants in patch 4.
- Move dell-led.h include one line higher in patch 4.
Changes from v1:
- Squash patches 2-4 from v1 into a single patch (#2 in v2).
- Add patch 3.
- Fix subject pattern in patch 4.
- Slight commit message adjustments, including fixing a typo ("COFIG_LEDS_DELL_NETBOOKS") in patch 6.
- Remove the name of the module's source file from the header comment in drivers/platform/x86/dell-wmi-led.c to avoid the need to update it in the future.
drivers/leds/Kconfig | 9 --
drivers/leds/Makefile | 1 -
drivers/platform/x86/Kconfig | 8 ++
drivers/platform/x86/Makefile | 1 +
drivers/platform/x86/dell-laptop.c | 28 ++++
.../dell-led.c => platform/x86/dell-wmi-led.c} | 141 +++++----------------
include/linux/dell-led.h | 6 +-
sound/pci/hda/dell_wmi_helper.c | 30 ++---
8 files changed, 86 insertions(+), 138 deletions(-)
rename drivers/{leds/dell-led.c => platform/x86/dell-wmi-led.c} (56%)Signature · 1 line
2.11.1
PATCH v3 1/7 dell-led: remove GUID check from dell_micmute_led_set()
As dell_micmute_led_set() no longer uses the dell_wmi_perform_query() method, which was removed in commit 0c41a08e131d ("dell-led: use dell_smbios_send_request() for performing SMBIOS calls"), the DELL_APP_GUID check is redundant and thus can be safely removed.
--- drivers/leds/dell-led.c | 3 --- 1 file changed, 3 deletions(-)
drivers/leds/dell-led.c +0 -3
@@ -51,9 +51,6 @@ static int dell_micmute_led_set(int state)struct calling_interface_buffer *buffer;struct calling_interface_token *token; -if (!wmi_has_guid (DELL_APP_GUID )) -return -ENODEV ; -if (state ==0 ) token =dell_smbios_find_token (GLOBAL_MIC_MUTE_DISABLE );else if (state ==1 )
Signature · 6 lines
2.11.1 _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 2/7 ALSA: hda - use dell_micmute_led_set() instead of dell_app_wmi_led_set()
In reply to Michał KępieńThe dell_app_wmi_led_set() method introduced in commit db6d8cc00773 ("dell-led: add mic mute led interface") was implemented as an easily extensible entry point for other modules to set the state of various LEDs. However, almost three years later it is still only used to control the mic mute LED, so it will be replaced with direct calls to dell_micmute_led_set().
--- drivers/leds/dell-led.c | 20 ++------------------ include/linux/dell-led.h | 6 +----- sound/pci/hda/dell_wmi_helper.c | 12 ++++++------ 3 files changed, 9 insertions(+), 29 deletions(-)
drivers/leds/dell-led.c +2 -18
@@ -46,7 +46,7 @@ MODULE_ALIAS("wmi:" DELL_LED_BIOS_GUID);#define GLOBAL_MIC_MUTE_ENABLE 0x364#define GLOBAL_MIC_MUTE_DISABLE 0x365 -static int dell_micmute_led_set (int state) +int dell_micmute_led_set (int state) {struct calling_interface_buffer *buffer;struct calling_interface_token *token;
@@ -69,23 +69,7 @@ static int dell_micmute_led_set(int state)return state; } - -int dell_app_wmi_led_set (int whichled,int on) -{ -int state =0 ; - -switch (whichled) { -case DELL_LED_MICMUTE : - state =dell_micmute_led_set (on); -break ; -default : -pr_warn ("led type %x is not supported\n" , whichled); -break ; - } - -return state; -} -EXPORT_SYMBOL_GPL (dell_app_wmi_led_set); +EXPORT_SYMBOL_GPL (dell_micmute_led_set);struct bios_args {unsigned char length;
include/linux/dell-led.h +1 -5
@@ -1,10 +1,6 @@#ifndef __DELL_LED_H__#define __DELL_LED_H__ -enum { -DELL_LED_MICMUTE , -}; - -int dell_app_wmi_led_set (int whichled,int on); +int dell_micmute_led_set (int on);#endif
sound/pci/hda/dell_wmi_helper.c +6 -6
@@ -6,7 +6,7 @@#include <linux/dell-led.h> static int dell_led_value; -static int (*dell_led_set_func)(int ,int ); +static int (*dell_led_set_func)(int );static void (*dell_old_cap_hook)(struct hda_codec *,struct snd_kcontrol *,struct snd_ctl_elem_value *);
@@ -27,7 +27,7 @@ static void update_dell_wmi_micmute_led(struct hda_codec *codec,return ; dell_led_value = val;if (dell_led_set_func) -dell_led_set_func (DELL_LED_MICMUTE , dell_led_value); +dell_led_set_func (dell_led_value); } }
@@ -40,14 +40,14 @@ static void alc_fixup_dell_wmi(struct hda_codec *codec,if (action ==HDA_FIXUP_ACT_PROBE ) {if (!dell_led_set_func) - dell_led_set_func =symbol_request (dell_app_wmi_led_set); + dell_led_set_func =symbol_request (dell_micmute_led_set);if (!dell_led_set_func) { -codec_warn (codec,"Failed to find dell wmi symbol dell_app_wmi_led_set\n" ); +codec_warn (codec,"Failed to find dell wmi symbol dell_micmute_led_set\n" );return ; } removefunc = true; -if (dell_led_set_func (DELL_LED_MICMUTE , false) >=0 ) { +if (dell_led_set_func (false) >=0 ) { dell_led_value =0 ;if (spec->gen.num_adc_nids >1 && !spec->gen.dyn_adc_switch)codec_dbg (codec,"Skipping micmute LED control due to several ADCs" );
@@ -61,7 +61,7 @@ static void alc_fixup_dell_wmi(struct hda_codec *codec, }if (dell_led_set_func && (action ==HDA_FIXUP_ACT_FREE || removefunc)) { -symbol_put (dell_app_wmi_led_set); +symbol_put (dell_micmute_led_set); dell_led_set_func =NULL ; dell_old_cap_hook =NULL ; }
Signature · 6 lines
2.11.1 _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 3/7 ALSA: hda - rename dell_led_set_func to dell_micmute_led_set_func
In reply to Michał KępieńWith dell_app_wmi_led_set() replaced by dell_micmute_led_set(), rename the function pointer to the latter for consistency.
--- sound/pci/hda/dell_wmi_helper.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
sound/pci/hda/dell_wmi_helper.c +10 -10
@@ -6,7 +6,7 @@#include <linux/dell-led.h> static int dell_led_value; -static int (*dell_led_set_func)(int ); +static int (*dell_micmute_led_set_func)(int );static void (*dell_old_cap_hook)(struct hda_codec *,struct snd_kcontrol *,struct snd_ctl_elem_value *);
@@ -18,7 +18,7 @@ static void update_dell_wmi_micmute_led(struct hda_codec *codec,if (dell_old_cap_hook)dell_old_cap_hook (codec, kcontrol, ucontrol); -if (!ucontrol || !dell_led_set_func) +if (!ucontrol || !dell_micmute_led_set_func)return ;if (strcmp ("Capture Switch" , ucontrol->id.name) ==0 && ucontrol->id.index ==0 ) {/* TODO: How do I verify if it's a mono or stereo here? */
@@ -26,8 +26,8 @@ static void update_dell_wmi_micmute_led(struct hda_codec *codec,if (val == dell_led_value)return ; dell_led_value = val; -if (dell_led_set_func) -dell_led_set_func (dell_led_value); +if (dell_micmute_led_set_func) +dell_micmute_led_set_func (dell_led_value); } }
@@ -39,15 +39,15 @@ static void alc_fixup_dell_wmi(struct hda_codec *codec,bool removefunc = false;if (action ==HDA_FIXUP_ACT_PROBE ) { -if (!dell_led_set_func) - dell_led_set_func =symbol_request (dell_micmute_led_set); -if (!dell_led_set_func) { +if (!dell_micmute_led_set_func) + dell_micmute_led_set_func =symbol_request (dell_micmute_led_set); +if (!dell_micmute_led_set_func) {codec_warn (codec,"Failed to find dell wmi symbol dell_micmute_led_set\n" );return ; } removefunc = true; -if (dell_led_set_func (false) >=0 ) { +if (dell_micmute_led_set_func (false) >=0 ) { dell_led_value =0 ;if (spec->gen.num_adc_nids >1 && !spec->gen.dyn_adc_switch)codec_dbg (codec,"Skipping micmute LED control due to several ADCs" );
@@ -60,9 +60,9 @@ static void alc_fixup_dell_wmi(struct hda_codec *codec, } -if (dell_led_set_func && (action ==HDA_FIXUP_ACT_FREE || removefunc)) { +if (dell_micmute_led_set_func && (action ==HDA_FIXUP_ACT_FREE || removefunc)) {symbol_put (dell_micmute_led_set); - dell_led_set_func =NULL ; + dell_micmute_led_set_func =NULL ; dell_old_cap_hook =NULL ; } }
Signature · 6 lines
2.11.1 _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 4/7 platform/x86: dell-laptop: import dell_micmute_led_set() from drivers/leds/dell-led.c
In reply to Michał KępieńTo ensure all users of dell-smbios are in drivers/platform/x86, move the dell_micmute_led_set() method from drivers/leds/dell-led.c to drivers/platform/x86/dell-laptop.c.
--- drivers/leds/dell-led.c | 29 ----------------------------- drivers/platform/x86/dell-laptop.c | 28 ++++++++++++++++++++++++++++ sound/pci/hda/dell_wmi_helper.c | 6 +++--- 3 files changed, 31 insertions(+), 32 deletions(-)
drivers/leds/dell-led.c +0 -29
@@ -16,7 +16,6 @@#include <linux/slab.h> #include <linux/module.h> #include <linux/dmi.h> -#include <linux/dell-led.h> #include "../platform/x86/dell-smbios.h" MODULE_AUTHOR ("Louis Davis/Jim Dailey" );
@@ -43,34 +42,6 @@ MODULE_ALIAS("wmi:" DELL_LED_BIOS_GUID);#define CMD_LED_OFF 17#define CMD_LED_BLINK 18 -#define GLOBAL_MIC_MUTE_ENABLE 0x364 -#define GLOBAL_MIC_MUTE_DISABLE 0x365 - -int dell_micmute_led_set (int state) -{ -struct calling_interface_buffer *buffer; -struct calling_interface_token *token; - -if (state ==0 ) - token =dell_smbios_find_token (GLOBAL_MIC_MUTE_DISABLE ); -else if (state ==1 ) - token =dell_smbios_find_token (GLOBAL_MIC_MUTE_ENABLE ); -else -return -EINVAL ; - -if (!token) -return -ENODEV ; - - buffer =dell_smbios_get_buffer (); - buffer->input[0 ] = token->location; - buffer->input[1 ] = token->value; -dell_smbios_send_request (1 ,0 ); -dell_smbios_release_buffer (); - -return state; -} -EXPORT_SYMBOL_GPL (dell_micmute_led_set); -struct bios_args {unsigned char length;unsigned char result_code;
drivers/platform/x86/dell-laptop.c +28 -0
@@ -29,6 +29,7 @@#include <linux/mm.h> #include <linux/i8042.h> #include <linux/debugfs.h> +#include <linux/dell-led.h> #include <linux/seq_file.h> #include <acpi/video.h> #include "dell-rbtn.h"
@@ -42,6 +43,8 @@#define KBD_LED_AUTO_50_TOKEN 0x02EB#define KBD_LED_AUTO_75_TOKEN 0x02EC#define KBD_LED_AUTO_100_TOKEN 0x02F6 +#define GLOBAL_MIC_MUTE_ENABLE 0x0364 +#define GLOBAL_MIC_MUTE_DISABLE 0x0365struct quirk_entry {u8 touchpad_led;
@@ -1972,6 +1975,31 @@ static void kbd_led_exit(void)led_classdev_unregister (&kbd_led); } +int dell_micmute_led_set (int state) +{ +struct calling_interface_buffer *buffer; +struct calling_interface_token *token; + +if (state ==0 ) + token =dell_smbios_find_token (GLOBAL_MIC_MUTE_DISABLE ); +else if (state ==1 ) + token =dell_smbios_find_token (GLOBAL_MIC_MUTE_ENABLE ); +else +return -EINVAL ; + +if (!token) +return -ENODEV ; + + buffer =dell_smbios_get_buffer (); + buffer->input[0 ] = token->location; + buffer->input[1 ] = token->value; +dell_smbios_send_request (1 ,0 ); +dell_smbios_release_buffer (); + +return state; +} +EXPORT_SYMBOL_GPL (dell_micmute_led_set); +static int __init dell_init (void ) {struct calling_interface_buffer *buffer;
sound/pci/hda/dell_wmi_helper.c +3 -3
@@ -2,7 +2,7 @@* to be included from codec driver */ -#if IS_ENABLED (CONFIG_LEDS_DELL_NETBOOKS ) +#if IS_ENABLED (CONFIG_DELL_LAPTOP )#include <linux/dell-led.h> static int dell_led_value;
@@ -67,10 +67,10 @@ static void alc_fixup_dell_wmi(struct hda_codec *codec, } } -#else /* CONFIG_LEDS_DELL_NETBOOKS */ +#else /* CONFIG_DELL_LAPTOP */ static void alc_fixup_dell_wmi (struct hda_codec *codec,const struct hda_fixup *fix,int action) { } -#endif /* CONFIG_LEDS_DELL_NETBOOKS */ +#endif /* CONFIG_DELL_LAPTOP */
Signature · 1 line
2.11.1
PATCH v3 5/7 dell-led: remove code related to mic mute LED
In reply to Michał KępieńWith dell_micmute_led_set() moved to drivers/platform/x86/dell-laptop.c, all remnants of the mic mute LED handling code can be removed from drivers/leds/dell-led.c, restoring it back to the state it was in before commit db6d8cc00773 ("dell-led: add mic mute led interface").
--- drivers/leds/Kconfig | 1 - drivers/leds/dell-led.c | 25 +++++++------------------ 2 files changed, 7 insertions(+), 19 deletions(-)
drivers/leds/Kconfig +0 -1
@@ -467,7 +467,6 @@ config LEDS_DELL_NETBOOKS tristate "External LED on Dell Business Netbooks" depends on LEDS_CLASS depends on X86 && ACPI_WMI - depends on DELL_SMBIOS help This adds support for the Latitude 2100 and similar notebooks that have an external LED.
drivers/leds/dell-led.c +7 -18
@@ -15,15 +15,12 @@#include <linux/leds.h> #include <linux/slab.h> #include <linux/module.h> -#include <linux/dmi.h> -#include "../platform/x86/dell-smbios.h" MODULE_AUTHOR ("Louis Davis/Jim Dailey" );MODULE_DESCRIPTION ("Dell LED Control Driver" );MODULE_LICENSE ("GPL" );#define DELL_LED_BIOS_GUID "F6E4FE6E-909D-47cb-8BAB-C9F6F2F8D396" -#define DELL_APP_GUID "A80593CE-A997-11DA-B012-B622A1EF5492"MODULE_ALIAS ("wmi:" DELL_LED_BIOS_GUID );/* Error Result Codes: */
@@ -184,29 +181,21 @@ static int __init dell_led_init(void) {int error =0 ; -if (!wmi_has_guid (DELL_LED_BIOS_GUID ) && !wmi_has_guid (DELL_APP_GUID )) +if (!wmi_has_guid (DELL_LED_BIOS_GUID ))return -ENODEV ; -if (wmi_has_guid (DELL_LED_BIOS_GUID )) { - error =led_off (); -if (error !=0 ) -return -ENODEV ; - - error =led_classdev_register (NULL , &dell_led); - } + error =led_off (); +if (error !=0 ) +return -ENODEV ; -return error; +return led_classdev_register (NULL , &dell_led); } static void __exit dell_led_exit(void) { -int error =0 ; +led_classdev_unregister (&dell_led); -if (wmi_has_guid (DELL_LED_BIOS_GUID )) { - error =led_off (); -if (error ==0 ) -led_classdev_unregister (&dell_led); - } +led_off (); }module_init (dell_led_init);
Signature · 1 line
2.11.1
PATCH v3 6/7 dell-led: move driver to drivers/platform/x86/dell-wmi-led.c
In reply to Michał KępieńThe dell-led driver handles a specific WMI GUID present on some Dell laptops and as such it belongs in the x86 platform driver subsystem. Source code is moved along with the relevant Kconfig and Makefile entries, with some minor modifications:
- Kconfig option is renamed from CONFIG_LEDS_DELL_NETBOOKS to CONFIG_DELL_WMI_LED,
- the X86 Kconfig dependency is removed as the whole drivers/platform/x86 menu depends on it, so there is no need to duplicate it,
- the name of the module's source file is removed from the header comment to avoid the need to update it in the future.
---
drivers/leds/Kconfig | 8 --------
drivers/leds/Makefile | 1 -
drivers/platform/x86/Kconfig | 8 ++++++++
drivers/platform/x86/Makefile | 1 +
drivers/{leds/dell-led.c => platform/x86/dell-wmi-led.c} | 2 --
5 files changed, 9 insertions(+), 11 deletions(-)
rename drivers/{leds/dell-led.c => platform/x86/dell-wmi-led.c} (99%)drivers/leds/Kconfig +0 -8
@@ -463,14 +463,6 @@ config LEDS_ADP5520 To compile this driver as a module, choose M here: the module will be called leds-adp5520. -config LEDS_DELL_NETBOOKS - tristate "External LED on Dell Business Netbooks" - depends on LEDS_CLASS - depends on X86 && ACPI_WMI - help - This adds support for the Latitude 2100 and similar - notebooks that have an external LED. - config LEDS_MC13783 tristate "LED Support for MC13XXX PMIC" depends on LEDS_CLASS
drivers/leds/Makefile +0 -1
@@ -52,7 +52,6 @@ obj-$(CONFIG_LEDS_REGULATOR) += leds-regulator.o obj-$(CONFIG_LEDS_INTEL_SS4200) += leds-ss4200.o obj-$(CONFIG_LEDS_LT3593) += leds-lt3593.o obj-$(CONFIG_LEDS_ADP5520) += leds-adp5520.o -obj-$(CONFIG_LEDS_DELL_NETBOOKS) += dell-led.o obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o obj-$(CONFIG_LEDS_NS2) += leds-ns2.o obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o
drivers/platform/x86/Kconfig +8 -0
@@ -143,6 +143,14 @@ config DELL_WMI_AIO To compile this driver as a module, choose M here: the module will be called dell-wmi-aio. +config DELL_WMI_LED + tristate "External LED on Dell Business Netbooks" + depends on LEDS_CLASS + depends on ACPI_WMI + help + This adds support for the Latitude 2100 and similar + notebooks that have an external LED. + config DELL_SMO8800 tristate "Dell Latitude freefall driver (ACPI SMO88XX)" depends on ACPI
drivers/platform/x86/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_DELL_SMBIOS) += dell-smbios.o obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o obj-$(CONFIG_DELL_WMI) += dell-wmi.o obj-$(CONFIG_DELL_WMI_AIO) += dell-wmi-aio.o +obj-$(CONFIG_DELL_WMI_LED) += dell-wmi-led.o obj-$(CONFIG_DELL_SMO8800) += dell-smo8800.o obj-$(CONFIG_DELL_RBTN) += dell-rbtn.o obj-$(CONFIG_ACER_WMI) += acer-wmi.o
drivers/platform/x86/dell-wmi-led.c renamed from drivers/leds/dell-led.c +0 -2
@@ -1,6 +1,4 @@/* -* dell_led.c - Dell LED Driver -* * Copyright (C) 2010 Dell Inc. * Louis Davis <[email protected]> * Jim Dailey <[email protected]>
Signature · 1 line
2.11.1
PATCH v3 7/7 platform/x86: dell-wmi-led: fix coding style issues
In reply to Michał KępieńFix coding style issues in dell-wmi-led to make sure the module gets a clean start in the x86 platform driver subsystem.
--- drivers/platform/x86/dell-wmi-led.c | 66 +++++++++++++++---------------------- 1 file changed, 26 insertions(+), 40 deletions(-)
drivers/platform/x86/dell-wmi-led.c +26 -40
@@ -46,37 +46,29 @@ struct bios_args {unsigned char off_time; }; -static int dell_led_perform_fn (u8 length, -u8 result_code, -u8 device_id, -u8 command, -u8 on_time, -u8 off_time) +static int dell_led_perform_fn (u8 length,u8 result_code,u8 device_id, +u8 command,u8 on_time,u8 off_time) { -struct bios_args *bios_return; -u8 return_code; -union acpi_object *obj;struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER ,NULL }; +struct bios_args *bios_return;struct acpi_buffer input; +union acpi_object *obj;acpi_status status; +u8 return_code; -struct bios_args args; - args.length = length; - args.result_code = result_code; - args.device_id = device_id; - args.command = command; - args.on_time = on_time; - args.off_time = off_time; +struct bios_args args = { + .length = length, + .result_code = result_code, + .device_id = device_id, + .command = command, + .on_time = on_time, + .off_time = off_time + }; input.length =sizeof (struct bios_args ); input.pointer = &args; - status =wmi_evaluate_method (DELL_LED_BIOS_GUID , -1 , -1 , - &input, - &output); - + status =wmi_evaluate_method (DELL_LED_BIOS_GUID ,1 ,1 , &input, &output);if (ACPI_FAILURE (status))return status;
@@ -84,7 +76,7 @@ static int dell_led_perform_fn(u8 length,if (!obj)return -EINVAL ; -else if (obj->type !=ACPI_TYPE_BUFFER ) { +if (obj->type !=ACPI_TYPE_BUFFER ) {kfree (obj);return -EINVAL ; }
@@ -117,8 +109,7 @@ static int led_off(void) 0); /* not used */ } -static int led_blink (unsigned char on_eighths, -unsigned char off_eighths) +static int led_blink (unsigned char on_eighths,unsigned char off_eighths) { return dell_led_perform_fn(5, /* Length of command */ INTERFACE_ERROR, /* Init to INTERFACE_ERROR */
@@ -129,7 +120,7 @@ static int led_blink(unsigned char on_eighths, }static void dell_led_set (struct led_classdev *led_cdev, -enum led_brightness value) +enum led_brightness value) {if (value ==LED_OFF )led_off ();
@@ -138,27 +129,22 @@ static void dell_led_set(struct led_classdev *led_cdev, }static int dell_led_blink (struct led_classdev *led_cdev, -unsigned long *delay_on, -unsigned long *delay_off) +unsigned long *delay_on,unsigned long *delay_off) {unsigned long on_eighths;unsigned long off_eighths; -/* The Dell LED delay is based on 125ms intervals. -Need to round up to next interval. */ +/* +* The Dell LED delay is based on 125ms intervals. +* Need to round up to next interval. +*/ - on_eighths = (*delay_on +124 ) /125 ; -if (0 == on_eighths) - on_eighths =1 ; -if (on_eighths >255 ) - on_eighths =255 ; + on_eighths =DIV_ROUND_UP (*delay_on,125 ); + on_eighths = clamp_t(unsigned long, on_eighths, 1, 255); *delay_on = on_eighths *125 ; - off_eighths = (*delay_off +124 ) /125 ; -if (0 == off_eighths) - off_eighths =1 ; -if (off_eighths >255 ) - off_eighths =255 ; + off_eighths =DIV_ROUND_UP (*delay_off,125 ); + off_eighths = clamp_t(unsigned long, off_eighths, 1, 255); *delay_off = off_eighths *125 ;led_blink (on_eighths, off_eighths);
Signature · 1 line
2.11.1
Hi Michał,
Thanks for collecting relevant credits.
I've applied the patchset to the for-4.12 branch of linux-leds.git.
Best regards,
Jacek Anaszewski
Quoted 85 lines · Michał Kępień
This patch series moves the dell-led driver from the LED subsystem to the x86 platform driver subsystem.
The original motivation behind this effort was to move all code using the dell-smbios module to the x86 platform driver subsystem. While I was investigating the possibilities to do that, it quickly emerged that dell-led can and in fact should be moved to the x86 platform driver subsystem in its entirety.
dell-led consists of two major parts:
- the part exposing a microphone mute LED interface, introduced in
db6d8cc00773("dell-led: add mic mute led interface"); this interface is used bysound/pci/hda/dell_wmi_helper.c; while the original implementation used a WMI interface, it was changed to use dell-smbios incf0d7ea33596("dell-led: usedell_smbios_find_token()for finding mic DMI tokens") and0c41a08e131d("dell-led: usedell_smbios_send_request()for performing SMBIOS calls"),- the part handling an activity LED present in Dell Latitude 2100 netbooks, introduced in
72dcd8d08aca("leds: Add Dell Business Class Netbook LED driver"); it binds to a specific WMI GUID and then registers a LED device which is controlled using WMI (i.e. it is essentially a WMI driver).Patches 1 and 2 clean up the microphone mute LED interface to minimize the amount of code moved around.
Patch 3 updates a variable name in
sound/pci/hda/dell_wmi_helper.cso that it better matches that variable's role.Patch 4 moves the microphone mute LED interface to
drivers/platform/x86/dell-laptop.c, effectively causingsound/pci/hda/dell_wmi_helper.cto depend onCONFIG_DELL_LAPTOPinstead ofCONFIG_LEDS_DELL_NETBOOKS.Patch 5 reverts dell-led to the state it was in after its initial commit
72dcd8d08aca("leds: Add Dell Business Class Netbook LED driver") by removing all remnants of the microphone mute LED handling code.Patch 6 moves all that is left of dell-led (i.e. the activity LED part, as originally implemented), to a new module which is placed in
drivers/platform/x86/dell-wmi-led.c.Patch 7 fixes coding style issues in
drivers/platform/x86/dell-wmi-led.cto make sure it gets a clean start in the x86 platform driver subsystem.As all patches except patch 3 in this series affect the LED subsystem, the series is based on linux-leds/for-next.
Changes from v2:
- Add patch 7 fixing coding style issues (feedback from Joe and Andy taken into account).
- Add leading zero to constants in patch 4.
- Move
dell-led.hinclude one line higher in patch 4.Changes from v1:
- Squash patches 2-4 from v1 into a single patch (#2 in v2).
- Add patch 3.
- Fix subject pattern in patch 4.
- Slight commit message adjustments, including fixing a typo ("
COFIG_LEDS_DELL_NETBOOKS") in patch 6.- Remove the name of the module's source file from the header comment in
drivers/platform/x86/dell-wmi-led.cto avoid the need to update it in the future.drivers/leds/Kconfig | 9 -- drivers/leds/Makefile | 1 - drivers/platform/x86/Kconfig | 8 ++ drivers/platform/x86/Makefile | 1 + drivers/platform/x86/dell-laptop.c | 28 ++++ .../dell-led.c => platform/x86/dell-wmi-led.c} | 141 +++++---------------- include/linux/dell-led.h | 6 +- sound/pci/hda/dell_wmi_helper.c | 30 ++--- 8 files changed, 86 insertions(+), 138 deletions(-) rename drivers/{leds/dell-led.c => platform/x86/dell-wmi-led.c} (56%)