All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/29] platform/x86: ideapad-laptop: cleanup, keyboard backlight and "always on USB charging" control support, reenable touchpad control
@ 2021-02-03 21:54 Barnabás Pőcze
  2021-02-03 21:54 ` [PATCH v3 01/29] platform/x86: ideapad-laptop: remove unnecessary dev_set_drvdata() call Barnabás Pőcze
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Barnabás Pőcze @ 2021-02-03 21:54 UTC (permalink / raw)
  To: platform-driver-x86, Hans de Goede, Mark Gross, Ike Panhc,
	Andy Shevchenko

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/20210113182016.166049-1-pobrn@protonmail.com/
 - v1: https://lore.kernel.org/platform-driver-x86/20201216013857.360987-1-pobrn@protonmail.com/

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(-)

-- 
2.30.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 01/29] platform/x86: ideapad-laptop: remove unnecessary dev_set_drvdata() call
  2021-02-03 21:54 [PATCH v3 00/29] platform/x86: ideapad-laptop: cleanup, keyboard backlight and "always on USB charging" control support, reenable touchpad control Barnabás Pőcze
@ 2021-02-03 21:54 ` Barnabás Pőcze
  2021-02-03 21:54 ` [PATCH v3 02/29] platform/x86: ideapad-laptop: remove unnecessary NULL checks Barnabás Pőcze
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Barnabás Pőcze @ 2021-02-03 21:54 UTC (permalink / raw)
  To: platform-driver-x86, Hans de Goede, Mark Gross, Ike Panhc,
	Andy Shevchenko

The driver core already sets the driver specific data on
bind failure or removal. Thus the call is unnecessary.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index cc42af2a0a98..18c71e28ebc8 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -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;
 }
-- 
2.30.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 02/29] platform/x86: ideapad-laptop: remove unnecessary NULL checks
  2021-02-03 21:54 [PATCH v3 00/29] platform/x86: ideapad-laptop: cleanup, keyboard backlight and "always on USB charging" control support, reenable touchpad control Barnabás Pőcze
  2021-02-03 21:54 ` [PATCH v3 01/29] platform/x86: ideapad-laptop: remove unnecessary dev_set_drvdata() call Barnabás Pőcze
@ 2021-02-03 21:54 ` Barnabás Pőcze
  2021-02-03 21:54 ` [PATCH v3 03/29] platform/x86: ideapad-laptop: use appropriately typed variable to store the return value of ACPI methods Barnabás Pőcze
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Barnabás Pőcze @ 2021-02-03 21:54 UTC (permalink / raw)
  To: platform-driver-x86, Hans de Goede, Mark Gross, Ike Panhc,
	Andy Shevchenko

The 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.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>

diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 18c71e28ebc8..415d362a642a 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -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);
-- 
2.30.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 03/29] platform/x86: ideapad-laptop: use appropriately typed variable to store the return value of ACPI methods
  2021-02-03 21:54 [PATCH v3 00/29] platform/x86: ideapad-laptop: cleanup, keyboard backlight and "always on USB charging" control support, reenable touchpad control Barnabás Pőcze
  2021-02-03 21:54 ` [PATCH v3 01/29] platform/x86: ideapad-laptop: remove unnecessary dev_set_drvdata() call Barnabás Pőcze
  2021-02-03 21:54 ` [PATCH v3 02/29] platform/x86: ideapad-laptop: remove unnecessary NULL checks Barnabás Pőcze
@ 2021-02-03 21:54 ` Barnabás Pőcze
  2021-02-03 21:54 ` [PATCH v3 04/29] platform/x86: ideapad-laptop: sort includes lexicographically Barnabás Pőcze
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Barnabás Pőcze @ 2021-02-03 21:54 UTC (permalink / raw)
  To: platform-driver-x86, Hans de Goede, Mark Gross, Ike Panhc,
	Andy Shevchenko

Use 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.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 415d362a642a..6c1ed5153a37 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -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;
-- 
2.30.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 04/29] platform/x86: ideapad-laptop: sort includes lexicographically
  2021-02-03 21:54 [PATCH v3 00/29] platform/x86: ideapad-laptop: cleanup, keyboard backlight and "always on USB charging" control support, reenable touchpad control Barnabás Pőcze
                   ` (2 preceding siblings ...)
  2021-02-03 21:54 ` [PATCH v3 03/29] platform/x86: ideapad-laptop: use appropriately typed variable to store the return value of ACPI methods Barnabás Pőcze
@ 2021-02-03 21:54 ` Barnabás Pőcze
  2021-02-03 21:54 ` [PATCH v3 05/29] platform/x86: ideapad-laptop: add missing call to submodule destructor Barnabás Pőcze
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Barnabás Pőcze @ 2021-02-03 21:54 UTC (permalink / raw)
  To: platform-driver-x86, Hans de Goede, Mark Gross, Ike Panhc,
	Andy Shevchenko

Managing includes is easier when they are
sorted, so sort them lexicographically.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 6c1ed5153a37..e3016c18e88e 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -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)
-- 
2.30.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 05/29] platform/x86: ideapad-laptop: add missing call to submodule destructor
  2021-02-03 21:54 [PATCH v3 00/29] platform/x86: ideapad-laptop: cleanup, keyboard backlight and "always on USB charging" control support, reenable touchpad control Barnabás Pőcze
                   ` (3 preceding siblings ...)
  2021-02-03 21:54 ` [PATCH v3 04/29] platform/x86: ideapad-laptop: sort includes lexicographically Barnabás Pőcze
@ 2021-02-03 21:54 ` Barnabás Pőcze
  2021-02-03 21:54 ` [PATCH v3 06/29] platform/x86: ideapad-laptop: use sysfs_emit() Barnabás Pőcze
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Barnabás Pőcze @ 2021-02-03 21:54 UTC (permalink / raw)
  To: platform-driver-x86, Hans de Goede, Mark Gross, Ike Panhc,
	Andy Shevchenko

ideapad_dytc_profile_exit() is not called in ideapad_acpi_add()
in the error path. Add the missing call.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>

diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index e3016c18e88e..7ee5ac662f80 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -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);
-- 
2.30.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 06/29] platform/x86: ideapad-laptop: use sysfs_emit()
  2021-02-03 21:54 [PATCH v3 00/29] platform/x86: ideapad-laptop: cleanup, keyboard backlight and "always on USB charging" control support, reenable touchpad control Barnabás Pőcze
                   ` (4 preceding siblings ...)
  2021-02-03 21:54 ` [PATCH v3 05/29] platform/x86: ideapad-laptop: add missing call to submodule destructor Barnabás Pőcze
@ 2021-02-03 21:54 ` Barnabás Pőcze
  2021-02-03 21:55 ` [PATCH v3 07/29] platform/x86: ideapad-laptop: use device_{add,remove}_group Barnabás Pőcze
  2021-02-04  9:23 ` [PATCH v3 00/29] platform/x86: ideapad-laptop: cleanup, keyboard backlight and "always on USB charging" control support, reenable touchpad control Hans de Goede
  7 siblings, 0 replies; 9+ messages in thread
From: Barnabás Pőcze @ 2021-02-03 21:54 UTC (permalink / raw)
  To: platform-driver-x86, Hans de Goede, Mark Gross, Ike Panhc,
	Andy Shevchenko

sysfs_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.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 7ee5ac662f80..1a91588399f5 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -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,
-- 
2.30.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 07/29] platform/x86: ideapad-laptop: use device_{add,remove}_group
  2021-02-03 21:54 [PATCH v3 00/29] platform/x86: ideapad-laptop: cleanup, keyboard backlight and "always on USB charging" control support, reenable touchpad control Barnabás Pőcze
                   ` (5 preceding siblings ...)
  2021-02-03 21:54 ` [PATCH v3 06/29] platform/x86: ideapad-laptop: use sysfs_emit() Barnabás Pőcze
@ 2021-02-03 21:55 ` Barnabás Pőcze
  2021-02-04  9:23 ` [PATCH v3 00/29] platform/x86: ideapad-laptop: cleanup, keyboard backlight and "always on USB charging" control support, reenable touchpad control Hans de Goede
  7 siblings, 0 replies; 9+ messages in thread
From: Barnabás Pőcze @ 2021-02-03 21:55 UTC (permalink / raw)
  To: platform-driver-x86, Hans de Goede, Mark Gross, Ike Panhc,
	Andy Shevchenko

Use device_{add,remove}_group instead of sysfs_{add,remove}_group.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>

diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 1a91588399f5..2153688012c3 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -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);
 }
 
 /*
-- 
2.30.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 00/29] platform/x86: ideapad-laptop: cleanup, keyboard backlight and "always on USB charging" control support, reenable touchpad control
  2021-02-03 21:54 [PATCH v3 00/29] platform/x86: ideapad-laptop: cleanup, keyboard backlight and "always on USB charging" control support, reenable touchpad control Barnabás Pőcze
                   ` (6 preceding siblings ...)
  2021-02-03 21:55 ` [PATCH v3 07/29] platform/x86: ideapad-laptop: use device_{add,remove}_group Barnabás Pőcze
@ 2021-02-04  9:23 ` Hans de Goede
  7 siblings, 0 replies; 9+ messages in thread
From: Hans de Goede @ 2021-02-04  9:23 UTC (permalink / raw)
  To: Barnabás Pőcze, platform-driver-x86, Mark Gross,
	Ike Panhc, Andy Shevchenko

Hi,

On 2/3/21 10:54 PM, Barnabás Pőcze wrote:
> 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.

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



>  
> History:
>  - v2: https://lore.kernel.org/platform-driver-x86/20210113182016.166049-1-pobrn@protonmail.com/
>  - v1: https://lore.kernel.org/platform-driver-x86/20201216013857.360987-1-pobrn@protonmail.com/
> 
> 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(-)
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-02-04  9:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 21:54 [PATCH v3 00/29] platform/x86: ideapad-laptop: cleanup, keyboard backlight and "always on USB charging" control support, reenable touchpad control Barnabás Pőcze
2021-02-03 21:54 ` [PATCH v3 01/29] platform/x86: ideapad-laptop: remove unnecessary dev_set_drvdata() call Barnabás Pőcze
2021-02-03 21:54 ` [PATCH v3 02/29] platform/x86: ideapad-laptop: remove unnecessary NULL checks Barnabás Pőcze
2021-02-03 21:54 ` [PATCH v3 03/29] platform/x86: ideapad-laptop: use appropriately typed variable to store the return value of ACPI methods Barnabás Pőcze
2021-02-03 21:54 ` [PATCH v3 04/29] platform/x86: ideapad-laptop: sort includes lexicographically Barnabás Pőcze
2021-02-03 21:54 ` [PATCH v3 05/29] platform/x86: ideapad-laptop: add missing call to submodule destructor Barnabás Pőcze
2021-02-03 21:54 ` [PATCH v3 06/29] platform/x86: ideapad-laptop: use sysfs_emit() Barnabás Pőcze
2021-02-03 21:55 ` [PATCH v3 07/29] platform/x86: ideapad-laptop: use device_{add,remove}_group Barnabás Pőcze
2021-02-04  9:23 ` [PATCH v3 00/29] platform/x86: ideapad-laptop: cleanup, keyboard backlight and "always on USB charging" control support, reenable touchpad control Hans de Goede

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.