platform/x86: ideapad-laptop: cleanup, keyboard backlight and "always on USB charging" control support, reenable touchpad control
v3 cover platform/x86: ideapad-laptop: cleanup, keyboard backlight and "always on USB charging" control support, reenable touchpad control
Changes in v3:
- rebase on eabe533904cbcb6c7df530fd807cf2a3c3567d35
("platform/x86: ideapad-laptop: DYTC Platform profile support"), which is referred to as "DYTC patch" in this changelog
- {02} *new patch*
- {03} minor formatting changes
- {05} *new patch*
- {07} *new patch*
- {08} *new patch*
- {09} minor formatting change
- {10} use while loop
- {11} restore log message severity
- {12} *new patch*
- {13} reorder variable definitions,
apply to DYTC patch
- {14} mention ABI breakage
- {15} mention ABI breakage,
use !! to convert to int and "%d" in sysfs_emit(), convert 'camera_power' attribute to boolean-like
- {17} reorder varible definitions,
apply to DYTC patch
- {18} minor formatting changes,
add log messages
- {19} minor formatting change
- {20} move && to end of line
- {21} no longer return -ENODATA due to {02},
explicit alignment instead of tabs in output
- {22} no longer return -ENODATA due to {02}
- {24} reorder device attribute callbacks,
remove some empty lines,
apply to DYTC patch
- {26} use !! to map to range [0, 1],
add log messages
- {27} move documentation change to this patch
- {28} add "Fixes" tag
- {29} add "Fixes" tag
I hope I addressed all concerns adequately, if not, do not hesistate to remind me.
History:
- v2: https://lore.kernel.org/platform-driver-x86/[email protected]/
- v1: https://lore.kernel.org/platform-driver-x86/[email protected]/
Barnabás Pőcze (29):
platform/x86: ideapad-laptop: remove unnecessary dev_set_drvdata()
call
platform/x86: ideapad-laptop: remove unnecessary NULL checks platform/x86: ideapad-laptop: use appropriately typed variable to
store the return value of ACPI methods
platform/x86: ideapad-laptop: sort includes lexicographically platform/x86: ideapad-laptop: add missing call to submodule destructor platform/x86: ideapad-laptop: use sysfs_emit() platform/x86: ideapad-laptop: use device_{add,remove}_group platform/x86: ideapad-laptop: use kobj_to_dev() platform/x86: ideapad-laptop: use for_each_set_bit() helper to
simplify event processing
platform/x86: ideapad-laptop: use msecs_to_jiffies() helper instead of
hand-crafted formula
platform/x86: ideapad-laptop: use dev_{err,warn} or appropriate
variant to display log messages
platform/x86: ideapad-laptop: check return value of
debugfs_create_dir() for errors
platform/x86: ideapad-laptop: convert ACPI helpers to return -EIO in
case of failure
platform/x86: ideapad-laptop: always propagate error codes from device
attributes' show() callback
platform/x86: ideapad-laptop: misc. device attribute changes platform/x86: ideapad-laptop: group and separate (un)related constants
into enums
platform/x86: ideapad-laptop: rework and create new ACPI helpers platform/x86: ideapad-laptop: rework is_visible() logic platform/x86: ideapad-laptop: check for Fn-lock support in HALS platform/x86: ideapad-laptop: check for touchpad support in _CFG platform/x86: ideapad-laptop: change 'status' debugfs file format platform/x86: ideapad-laptop: change 'cfg' debugfs file format Revert "platform/x86: ideapad-laptop: Switch touchpad attribute to be
RO"
platform/x86: ideapad-laptop: fix checkpatch warnings, more consistent
style
platform/x86: ideapad-laptop: send notification about touchpad state
change to sysfs
platform/x86: ideapad-laptop: add keyboard backlight control support platform/x86: ideapad-laptop: add "always on USB charging" control
support
Documentation/ABI: sysfs-platform-ideapad-laptop: update device
attribute paths
Documentation/ABI: sysfs-platform-ideapad-laptop: conservation_mode
attribute
.../ABI/testing/sysfs-platform-ideapad-laptop | 26 +- drivers/platform/x86/ideapad-laptop.c | 1284 ++++++++++------- 2 files changed, 810 insertions(+), 500 deletions(-)
Signature · 1 line
2.30.0
PATCH v3 1/29 platform/x86: ideapad-laptop: remove unnecessary dev_set_drvdata() call
The driver core already sets the driver specific data on bind failure or removal. Thus the call is unnecessary.
drivers/platform/x86/ideapad-laptop.c +0 -1
@@ -1369,7 +1369,6 @@ static int ideapad_acpi_remove(struct platform_device *pdev)ideapad_input_exit (priv);ideapad_debugfs_exit (priv);ideapad_sysfs_exit (priv); -dev_set_drvdata (&pdev->dev,NULL );return 0 ; }
Signature · 1 line
2.30.0
PATCH v3 2/29 platform/x86: ideapad-laptop: remove unnecessary NULL checks
In reply to Barnabás PőczeThe checks that are removed test pointers which should not be NULL. If they are NULL, that indicates a bug in a different part of the kernel. Instead of silently bailing out, let it fail loudly.
drivers/platform/x86/ideapad-laptop.c +31 -47
@@ -264,9 +264,6 @@ static int debugfs_status_show(struct seq_file *s, void *data)struct ideapad_private *priv = s->private;unsigned long value; -if (!priv) -return -EINVAL ; -if (!read_ec_data (priv->adev->handle,VPCCMD_R_BL_MAX , &value))seq_printf (s,"Backlight max:\t%lu\n" , value);if (!read_ec_data (priv->adev->handle,VPCCMD_R_BL , &value))
@@ -311,39 +308,36 @@ static int debugfs_cfg_show(struct seq_file *s, void *data) {struct ideapad_private *priv = s->private; -if (!priv) { -seq_printf (s,"cfg: N/A\n" ); - }else { -seq_printf (s,"cfg: 0x%.8lX\n\nCapability: " , - priv->cfg); -if (test_bit (CFG_BT_BIT , &priv->cfg)) -seq_printf (s,"Bluetooth " ); -if (test_bit (CFG_3G_BIT , &priv->cfg)) -seq_printf (s,"3G " ); -if (test_bit (CFG_WIFI_BIT , &priv->cfg)) -seq_printf (s,"Wireless " ); -if (test_bit (CFG_CAMERA_BIT , &priv->cfg)) -seq_printf (s,"Camera " ); -seq_printf (s,"\nGraphic: " ); -switch ((priv->cfg)&0x700 ) { -case 0x100 : -seq_printf (s,"Intel" ); -break ; -case 0x200 : -seq_printf (s,"ATI" ); -break ; -case 0x300 : -seq_printf (s,"Nvidia" ); -break ; -case 0x400 : -seq_printf (s,"Intel and ATI" ); -break ; -case 0x500 : -seq_printf (s,"Intel and Nvidia" ); -break ; - } -seq_printf (s,"\n" ); +seq_printf (s,"cfg: 0x%.8lX\n\nCapability: " , + priv->cfg); +if (test_bit (CFG_BT_BIT , &priv->cfg)) +seq_printf (s,"Bluetooth " ); +if (test_bit (CFG_3G_BIT , &priv->cfg)) +seq_printf (s,"3G " ); +if (test_bit (CFG_WIFI_BIT , &priv->cfg)) +seq_printf (s,"Wireless " ); +if (test_bit (CFG_CAMERA_BIT , &priv->cfg)) +seq_printf (s,"Camera " ); +seq_printf (s,"\nGraphic: " ); +switch ((priv->cfg)&0x700 ) { +case 0x100 : +seq_printf (s,"Intel" ); +break ; +case 0x200 : +seq_printf (s,"ATI" ); +break ; +case 0x300 : +seq_printf (s,"Nvidia" ); +break ; +case 0x400 : +seq_printf (s,"Intel and ATI" ); +break ; +case 0x500 : +seq_printf (s,"Intel and Nvidia" ); +break ; } +seq_printf (s,"\n" ); +return 0 ; }DEFINE_SHOW_ATTRIBUTE (debugfs_cfg);
@@ -1050,9 +1044,6 @@ static int ideapad_backlight_get_brightness(struct backlight_device *blightdev)struct ideapad_private *priv =bl_get_data (blightdev);unsigned long now; -if (!priv) -return -EINVAL ; -if (read_ec_data (priv->adev->handle,VPCCMD_R_BL , &now))return -EIO ;return now;
@@ -1062,9 +1053,6 @@ static int ideapad_backlight_update_status(struct backlight_device *blightdev) {struct ideapad_private *priv =bl_get_data (blightdev); -if (!priv) -return -EINVAL ; -if (write_ec_cmd (priv->adev->handle,VPCCMD_W_BL , blightdev->props.brightness))return -EIO ;
@@ -1374,13 +1362,9 @@ static int ideapad_acpi_remove(struct platform_device *pdev) }#ifdef CONFIG_PM_SLEEP -static int ideapad_acpi_resume (struct device *device) +static int ideapad_acpi_resume (struct device *dev) { -struct ideapad_private *priv; - -if (!device) -return -EINVAL ; - priv =dev_get_drvdata (device); +struct ideapad_private *priv =dev_get_drvdata (dev);ideapad_sync_rfk_state (priv);ideapad_sync_touchpad_state (priv);
Signature · 1 line
2.30.0
PATCH v3 3/29 platform/x86: ideapad-laptop: use appropriately typed variable to store the return value of ACPI methods
In reply to Barnabás PőczeUse a variable with type acpi_status to store the return value of ACPI methods instead of a plain int. And use ACPI_{SUCCESS,FAILURE} macros where possible instead of direct comparison.
drivers/platform/x86/ideapad-laptop.c +13 -7
@@ -1247,6 +1247,7 @@ static int ideapad_acpi_add(struct platform_device *pdev)int cfg;struct ideapad_private *priv;struct acpi_device *adev; +acpi_status status; ret =acpi_bus_get_device (ACPI_HANDLE (&pdev->dev), &adev);if (ret)
@@ -1303,22 +1304,27 @@ static int ideapad_acpi_add(struct platform_device *pdev)if (ret && ret != -ENODEV ) goto backlight_failed; } - ret =acpi_install_notify_handler (adev->handle, -ACPI_DEVICE_NOTIFY , ideapad_acpi_notify, priv); -if (ret) + status =acpi_install_notify_handler (adev->handle, +ACPI_DEVICE_NOTIFY , + ideapad_acpi_notify, priv); +if (ACPI_FAILURE (status)) { + ret = -EIO ; goto notification_failed; + }#if IS_ENABLED (CONFIG_ACPI_WMI )for (i =0 ; i <ARRAY_SIZE (ideapad_wmi_fnesc_events); i++) { - ret =wmi_install_notify_handler (ideapad_wmi_fnesc_events[i], - ideapad_wmi_notify, priv); -if (ret ==AE_OK ) { + status =wmi_install_notify_handler (ideapad_wmi_fnesc_events[i], + ideapad_wmi_notify, priv); +if (ACPI_SUCCESS (status)) { priv->fnesc_guid = ideapad_wmi_fnesc_events[i];break ; } } -if (ret !=AE_OK && ret !=AE_NOT_EXIST ) +if (ACPI_FAILURE (status) && status !=AE_NOT_EXIST ) { + ret = -EIO ; goto notification_failed_wmi; + }#endif return 0 ;
Signature · 1 line
2.30.0
PATCH v3 4/29 platform/x86: ideapad-laptop: sort includes lexicographically
In reply to Barnabás PőczeManaging includes is easier when they are
sorted, so sort them lexicographically.
drivers/platform/x86/ideapad-laptop.c +13 -12
@@ -8,23 +8,24 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/acpi.h> +#include <linux/backlight.h> +#include <linux/debugfs.h> +#include <linux/device.h> +#include <linux/dmi.h> +#include <linux/fb.h> +#include <linux/i8042.h> +#include <linux/init.h> +#include <linux/input.h> +#include <linux/input/sparse-keymap.h> #include <linux/kernel.h> #include <linux/module.h> -#include <linux/init.h> -#include <linux/types.h> -#include <linux/acpi.h> -#include <linux/rfkill.h> #include <linux/platform_device.h> #include <linux/platform_profile.h> -#include <linux/input.h> -#include <linux/input/sparse-keymap.h> -#include <linux/backlight.h> -#include <linux/fb.h> -#include <linux/debugfs.h> +#include <linux/rfkill.h> #include <linux/seq_file.h> -#include <linux/i8042.h> -#include <linux/dmi.h> -#include <linux/device.h> +#include <linux/types.h> +#include <acpi/video.h> #define IDEAPAD_RFKILL_DEV_NUM (3)
Signature · 1 line
2.30.0
PATCH v3 5/29 platform/x86: ideapad-laptop: add missing call to submodule destructor
In reply to Barnabás Pőczeideapad_dytc_profile_exit() is not called in ideapad_acpi_add() in the error path. Add the missing call.
drivers/platform/x86/ideapad-laptop.c +1 -0
@@ -1337,6 +1337,7 @@ static int ideapad_acpi_add(struct platform_device *pdev) notification_failed:ideapad_backlight_exit (priv); backlight_failed: +ideapad_dytc_profile_exit (priv);for (i =0 ; i <IDEAPAD_RFKILL_DEV_NUM ; i++)ideapad_unregister_rfkill (priv, i);ideapad_input_exit (priv);
Signature · 1 line
2.30.0
PATCH v3 6/29 platform/x86: ideapad-laptop: use sysfs_emit()
In reply to Barnabás Pőczesysfs_emit() has been introduced to make it less ambiguous which function is preferred when writing to the output buffer in a device attribute's show() callback. Convert the ideapad-laptop module to utilize this new helper function.
drivers/platform/x86/ideapad-laptop.c +11 -10
@@ -24,6 +24,7 @@#include <linux/platform_profile.h> #include <linux/rfkill.h> #include <linux/seq_file.h> +#include <linux/sysfs.h> #include <linux/types.h> #include <acpi/video.h>
@@ -371,8 +372,8 @@ static ssize_t show_ideapad_cam(struct device *dev,struct ideapad_private *priv =dev_get_drvdata (dev);if (read_ec_data (priv->adev->handle,VPCCMD_R_CAMERA , &result)) -return sprintf (buf,"-1\n" ); -return sprintf (buf,"%lu\n" , result); +return sysfs_emit (buf,"-1\n" ); +return sysfs_emit (buf,"%lu\n" , result); } static ssize_t store_ideapad_cam(struct device *dev,
@@ -402,8 +403,8 @@ static ssize_t show_ideapad_fan(struct device *dev,struct ideapad_private *priv =dev_get_drvdata (dev);if (read_ec_data (priv->adev->handle,VPCCMD_R_FAN , &result)) -return sprintf (buf,"-1\n" ); -return sprintf (buf,"%lu\n" , result); +return sysfs_emit (buf,"-1\n" ); +return sysfs_emit (buf,"%lu\n" , result); } static ssize_t store_ideapad_fan(struct device *dev,
@@ -435,8 +436,8 @@ static ssize_t touchpad_show(struct device *dev,unsigned long result;if (read_ec_data (priv->adev->handle,VPCCMD_R_TOUCHPAD , &result)) -return sprintf (buf,"-1\n" ); -return sprintf (buf,"%lu\n" , result); +return sysfs_emit (buf,"-1\n" ); +return sysfs_emit (buf,"%lu\n" , result); }/* Switch to RO for now: It might be revisited in the future */
@@ -468,8 +469,8 @@ static ssize_t conservation_mode_show(struct device *dev,unsigned long result;if (method_gbmd (priv->adev->handle, &result)) -return sprintf (buf,"-1\n" ); -return sprintf (buf,"%u\n" ,test_bit (BM_CONSERVATION_BIT , &result)); +return sysfs_emit (buf,"-1\n" ); +return sysfs_emit (buf,"%u\n" ,test_bit (BM_CONSERVATION_BIT , &result)); } static ssize_t conservation_mode_store(struct device *dev,
@@ -504,10 +505,10 @@ static ssize_t fn_lock_show(struct device *dev,int fail =read_method_int (priv->adev->handle,"HALS" , &hals);if (fail) -return sprintf (buf,"-1\n" ); +return sysfs_emit (buf,"-1\n" ); result = hals; -return sprintf (buf,"%u\n" ,test_bit (HA_FNLOCK_BIT , &result)); +return sysfs_emit (buf,"%u\n" ,test_bit (HA_FNLOCK_BIT , &result)); } static ssize_t fn_lock_store(struct device *dev,
Signature · 1 line
2.30.0
PATCH v3 7/29 platform/x86: ideapad-laptop: use device_{add,remove}_group
In reply to Barnabás PőczeUse device_{add,remove}_group instead of sysfs_{add,remove}_group.
drivers/platform/x86/ideapad-laptop.c +4 -4
@@ -924,14 +924,14 @@ static void ideapad_unregister_rfkill(struct ideapad_private *priv, int dev)*/ static int ideapad_sysfs_init (struct ideapad_private *priv) { -return sysfs_create_group (&priv->platform_device->dev.kobj, - &ideapad_attribute_group); +return device_add_group (&priv->platform_device->dev, + &ideapad_attribute_group); }static void ideapad_sysfs_exit (struct ideapad_private *priv) { -sysfs_remove_group (&priv->platform_device->dev.kobj, - &ideapad_attribute_group); +device_remove_group (&priv->platform_device->dev, + &ideapad_attribute_group); }/*
Signature · 1 line
2.30.0
Hi,
Quoted 37 lines · Barnabás Pőcze
Changes in v3:
- rebase oneabe533904cbcb6c7df530fd807cf2a3c3567d35
("platform/x86: ideapad-laptop: DYTC Platform profile support"), which is referred to as "DYTC patch" in this changelog
- {02} *new patch*
- {03} minor formatting changes
- {05} *new patch*
- {07} *new patch*
- {08} *new patch*
- {09} minor formatting change
- {10} use while loop
- {11} restore log message severity
- {12} *new patch*
- {13} reorder variable definitions,
apply to DYTC patch
- {14} mention ABI breakage
- {15} mention ABI breakage,
use!!to convert tointand "%d" insysfs_emit(), convert 'camera_power' attribute to boolean-like
- {17} reorder varible definitions,
apply to DYTC patch
- {18} minor formatting changes,
add log messages
- {19} minor formatting change
- {20} move&&to end of line
- {21} no longer return-ENODATAdue to {02},
explicit alignment instead of tabs in output
- {22} no longer return-ENODATAdue to {02}
- {24} reorder device attribute callbacks,
remove some empty lines,
apply to DYTC patch
- {26} use!!to map to range [0, 1],
add log messages
- {27} move documentation change to this patch
- {28} add "Fixes" tag
- {29} add "Fixes" tag
Quoted 1 line
I hope I addressed all concerns adequately, if not, do not hesistate to remind me.
Thank you for your patch-series, I've applied the series to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Question, given all the work you have done have you considered adding yourself to the MAINTAINERS file as a co-maintainer or reviewer of the ideapad-laptop code ?
I certainly would welcome a co-maintainers / reviewer for this.
Note this will show up in my review-hans branch once I've pushed my local branch there, which might take a while.
Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.
Regards,
Hans
Quoted 55 lines
History:
- v2: https://lore.kernel.org/platform-driver-x86/[email protected]/
- v1: https://lore.kernel.org/platform-driver-x86/[email protected]/Barnabás Pőcze (29):
platform/x86: ideapad-laptop: remove unnecessarydev_set_drvdata()
call
platform/x86: ideapad-laptop: remove unnecessary NULL checks platform/x86: ideapad-laptop: use appropriately typed variable to
store the return value of ACPI methods
platform/x86: ideapad-laptop: sort includes lexicographically platform/x86: ideapad-laptop: add missing call to submodule destructor platform/x86: ideapad-laptop: usesysfs_emit()platform/x86: ideapad-laptop: use device_{add,remove}_group platform/x86: ideapad-laptop: usekobj_to_dev()platform/x86: ideapad-laptop: usefor_each_set_bit()helper to
simplify event processing
platform/x86: ideapad-laptop: usemsecs_to_jiffies()helper instead of
hand-crafted formula
platform/x86: ideapad-laptop: use dev_{err,warn} or appropriate
variant to display log messages
platform/x86: ideapad-laptop: check return value of
debugfs_create_dir()for errors
platform/x86: ideapad-laptop: convert ACPI helpers to return-EIOin
case of failure
platform/x86: ideapad-laptop: always propagate error codes from device
attributes'show()callback
platform/x86: ideapad-laptop: misc. device attribute changes platform/x86: ideapad-laptop: group and separate (un)related constants
into enums
platform/x86: ideapad-laptop: rework and create new ACPI helpers platform/x86: ideapad-laptop: reworkis_visible()logic platform/x86: ideapad-laptop: check for Fn-lock support in HALS platform/x86: ideapad-laptop: check for touchpad support in_CFGplatform/x86: ideapad-laptop: change 'status' debugfs file format platform/x86: ideapad-laptop: change 'cfg' debugfs file format Revert "platform/x86: ideapad-laptop: Switch touchpad attribute to beRO"platform/x86: ideapad-laptop: fix checkpatch warnings, more consistent
style
platform/x86: ideapad-laptop: send notification about touchpad state
change to sysfs
platform/x86: ideapad-laptop: add keyboard backlight control support platform/x86: ideapad-laptop: add "always on USB charging" control
support
Documentation/ABI: sysfs-platform-ideapad-laptop: update device
attribute paths
Documentation/ABI: sysfs-platform-ideapad-laptop:conservation_mode
attribute.../ABI/testing/sysfs-platform-ideapad-laptop | 26 +- drivers/platform/x86/ideapad-laptop.c | 1284 ++++++++++------- 2 files changed, 810 insertions(+), 500 deletions(-)