The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v1 00/10] platform/x86: classmate-laptop: Bind to platform devices instead of ACPI ones
@ 2026-05-07 19:58 Rafael J. Wysocki
  2026-05-07 20:00 ` [PATCH v1 01/10] platform/x86: classmate-laptop: Address memory leaks on driver removal Rafael J. Wysocki
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-05-07 19:58 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
	Thadeu Lima de Souza Cascardo

Hi All,

This series is part of a larger effort to switch over all drivers using
the struct acpi_driver interface to the more common struct platform_driver
interface and eliminate the former.  The background is explained in
Documentation/driver-api/acpi/acpi-drivers.rst and in the changelog of
the patch that introduced the above document:

https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/

The bottom line is that the kernel would be better off without struct
acpi_driver and so it is better to get rid of it.

This series carries out driver conversion of 5 subdrivers in the platform x86
classmate-laptop driver.

The first 5 patches in the series are preliminary.

Patch [01/10] updates remove callbacks of 2 subdrivers in classmate-laptop
to free memory allocated during initialization as appropriate.

Patch [02/10] modifies 2 subdrivers in classmate-laptop so that their probe
rollback code ordering is the same as the removal one.

Patches [03-04/10] change the type of the first argument in 2 helper functions
in classmate-laptop and rename them.

Patch [05/10] updates classmate-laptop subdrivers to install their own ACPI
notify handlers instead of using the .notify() callback in struct acpi_driver.

The remaining patches convert the classmate-laptop subdrivers to platform
drivers, one at a time.

Patch [06/10] converts the accel-v4 subdriver in classmate-laptop to using
struct platform_driver for device binding.

Patch [07/10] converts the accel subdriver in classmate-laptop to using
struct platform_driver for device binding.

Patch [08/10] converts the tablet subdriver in classmate-laptop to using
struct platform_driver for device binding.

Patch [09/10] converts the ipml subdriver in classmate-laptop to using
struct platform_driver for device binding.

Patch [10/10] converts the keys subdriver in classmate-laptop to using
struct platform_driver for device binding.

Thanks!




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

* [PATCH v1 01/10] platform/x86: classmate-laptop: Address memory leaks on driver removal
  2026-05-07 19:58 [PATCH v1 00/10] platform/x86: classmate-laptop: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
@ 2026-05-07 20:00 ` Rafael J. Wysocki
  2026-05-07 20:01 ` [PATCH v1 02/10] platform/x86: classmate-laptop: Unify probe rollback and remove code Rafael J. Wysocki
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-05-07 20:00 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
	Thadeu Lima de Souza Cascardo

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

Update cmpc_accel_remove_v4() and cmpc_accel_remove() to free memory
allocated in cmpc_accel_add_v4() and cmpc_accel_add(), respectively.

Fixes: 529aa8cb0a59 ("classmate-laptop: add support for Classmate PC ACPI devices")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/platform/x86/classmate-laptop.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
index e6eed3d65580..218834ddddc3 100644
--- a/drivers/platform/x86/classmate-laptop.c
+++ b/drivers/platform/x86/classmate-laptop.c
@@ -441,9 +441,13 @@ static int cmpc_accel_add_v4(struct acpi_device *acpi)
 
 static void cmpc_accel_remove_v4(struct acpi_device *acpi)
 {
+	struct input_dev *inputdev = dev_get_drvdata(&acpi->dev);
+	struct cmpc_accel *accel = dev_get_drvdata(&inputdev->dev);
+
 	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4);
 	device_remove_file(&acpi->dev, &cmpc_accel_g_select_attr_v4);
 	cmpc_remove_acpi_notify_device(acpi);
+	kfree(accel);
 }
 
 static SIMPLE_DEV_PM_OPS(cmpc_accel_pm, cmpc_accel_suspend_v4,
@@ -680,8 +684,12 @@ static int cmpc_accel_add(struct acpi_device *acpi)
 
 static void cmpc_accel_remove(struct acpi_device *acpi)
 {
+	struct input_dev *inputdev = dev_get_drvdata(&acpi->dev);
+	struct cmpc_accel *accel = dev_get_drvdata(&inputdev->dev);
+
 	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr);
 	cmpc_remove_acpi_notify_device(acpi);
+	kfree(accel);
 }
 
 static const struct acpi_device_id cmpc_accel_device_ids[] = {




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

* [PATCH v1 02/10] platform/x86: classmate-laptop: Unify probe rollback and remove code
  2026-05-07 19:58 [PATCH v1 00/10] platform/x86: classmate-laptop: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
  2026-05-07 20:00 ` [PATCH v1 01/10] platform/x86: classmate-laptop: Address memory leaks on driver removal Rafael J. Wysocki
@ 2026-05-07 20:01 ` Rafael J. Wysocki
  2026-05-07 20:03 ` [PATCH v1 03/10] platform/x86: classmate-laptop: Pass struct device pointer to helpers Rafael J. Wysocki
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-05-07 20:01 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
	Thadeu Lima de Souza Cascardo

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

To facilitate subsequent modifications, change code ordering in
cmpc_accel_add_v4(), cmpc_accel_add(), and  cmpc_accel_remove_v4()
so that the ordering of the probe rollback code is the same as the
ordering of the corresponding removal code.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/platform/x86/classmate-laptop.c | 36 +++++++++++++------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
index 218834ddddc3..bc5df682d194 100644
--- a/drivers/platform/x86/classmate-laptop.c
+++ b/drivers/platform/x86/classmate-laptop.c
@@ -406,6 +406,13 @@ static int cmpc_accel_add_v4(struct acpi_device *acpi)
 
 	accel->inputdev_state = CMPC_ACCEL_DEV_STATE_CLOSED;
 
+	error = cmpc_add_acpi_notify_device(acpi, "cmpc_accel_v4",
+					    cmpc_accel_idev_init_v4);
+	if (error)
+		goto failed_input;
+
+	inputdev = dev_get_drvdata(&acpi->dev);
+
 	accel->sensitivity = CMPC_ACCEL_SENSITIVITY_DEFAULT;
 	cmpc_accel_set_sensitivity_v4(acpi->handle, accel->sensitivity);
 
@@ -420,21 +427,15 @@ static int cmpc_accel_add_v4(struct acpi_device *acpi)
 	if (error)
 		goto failed_g_select;
 
-	error = cmpc_add_acpi_notify_device(acpi, "cmpc_accel_v4",
-					    cmpc_accel_idev_init_v4);
-	if (error)
-		goto failed_input;
-
-	inputdev = dev_get_drvdata(&acpi->dev);
 	dev_set_drvdata(&inputdev->dev, accel);
 
 	return 0;
 
-failed_input:
-	device_remove_file(&acpi->dev, &cmpc_accel_g_select_attr_v4);
 failed_g_select:
 	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4);
 failed_sensitivity:
+	cmpc_remove_acpi_notify_device(acpi);
+failed_input:
 	kfree(accel);
 	return error;
 }
@@ -444,8 +445,8 @@ static void cmpc_accel_remove_v4(struct acpi_device *acpi)
 	struct input_dev *inputdev = dev_get_drvdata(&acpi->dev);
 	struct cmpc_accel *accel = dev_get_drvdata(&inputdev->dev);
 
-	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4);
 	device_remove_file(&acpi->dev, &cmpc_accel_g_select_attr_v4);
+	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4);
 	cmpc_remove_acpi_notify_device(acpi);
 	kfree(accel);
 }
@@ -658,6 +659,13 @@ static int cmpc_accel_add(struct acpi_device *acpi)
 	if (!accel)
 		return -ENOMEM;
 
+	error = cmpc_add_acpi_notify_device(acpi, "cmpc_accel",
+					    cmpc_accel_idev_init);
+	if (error)
+		goto failed_input;
+
+	inputdev = dev_get_drvdata(&acpi->dev);
+
 	accel->sensitivity = CMPC_ACCEL_SENSITIVITY_DEFAULT;
 	cmpc_accel_set_sensitivity(acpi->handle, accel->sensitivity);
 
@@ -665,19 +673,13 @@ static int cmpc_accel_add(struct acpi_device *acpi)
 	if (error)
 		goto failed_file;
 
-	error = cmpc_add_acpi_notify_device(acpi, "cmpc_accel",
-					    cmpc_accel_idev_init);
-	if (error)
-		goto failed_input;
-
-	inputdev = dev_get_drvdata(&acpi->dev);
 	dev_set_drvdata(&inputdev->dev, accel);
 
 	return 0;
 
-failed_input:
-	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr);
 failed_file:
+	cmpc_remove_acpi_notify_device(acpi);
+failed_input:
 	kfree(accel);
 	return error;
 }




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

* [PATCH v1 03/10] platform/x86: classmate-laptop: Pass struct device pointer to helpers
  2026-05-07 19:58 [PATCH v1 00/10] platform/x86: classmate-laptop: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
  2026-05-07 20:00 ` [PATCH v1 01/10] platform/x86: classmate-laptop: Address memory leaks on driver removal Rafael J. Wysocki
  2026-05-07 20:01 ` [PATCH v1 02/10] platform/x86: classmate-laptop: Unify probe rollback and remove code Rafael J. Wysocki
@ 2026-05-07 20:03 ` Rafael J. Wysocki
  2026-05-07 20:04 ` [PATCH v1 04/10] platform/x86: classmate-laptop: Rename two helper functions Rafael J. Wysocki
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-05-07 20:03 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
	Thadeu Lima de Souza Cascardo

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

To facilitate subsequent conversion of the driver to using struct
platform_driver instead of struct acpi_driver, modify two helper
functions in it, cmpc_add_acpi_notify_device() and
cmpc_remove_acpi_notify_device(), to take a struct device pointer
argument instead of a struct acpi_device pointer argument and update
their callers accordingly.

While at it, change the return type of cmpc_remove_acpi_notify_device()
to void because its return value is never checked.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/platform/x86/classmate-laptop.c | 32 ++++++++++++-------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
index bc5df682d194..7784712bfabd 100644
--- a/drivers/platform/x86/classmate-laptop.c
+++ b/drivers/platform/x86/classmate-laptop.c
@@ -38,7 +38,7 @@ struct cmpc_accel {
 
 typedef void (*input_device_init)(struct input_dev *dev);
 
-static int cmpc_add_acpi_notify_device(struct acpi_device *acpi, char *name,
+static int cmpc_add_acpi_notify_device(struct device *dev, char *name,
 				       input_device_init idev_init)
 {
 	struct input_dev *inputdev;
@@ -48,22 +48,20 @@ static int cmpc_add_acpi_notify_device(struct acpi_device *acpi, char *name,
 	if (!inputdev)
 		return -ENOMEM;
 	inputdev->name = name;
-	inputdev->dev.parent = &acpi->dev;
+	inputdev->dev.parent = dev;
 	idev_init(inputdev);
 	error = input_register_device(inputdev);
 	if (error) {
 		input_free_device(inputdev);
 		return error;
 	}
-	dev_set_drvdata(&acpi->dev, inputdev);
+	dev_set_drvdata(dev, inputdev);
 	return 0;
 }
 
-static int cmpc_remove_acpi_notify_device(struct acpi_device *acpi)
+static void cmpc_remove_acpi_notify_device(struct device *dev)
 {
-	struct input_dev *inputdev = dev_get_drvdata(&acpi->dev);
-	input_unregister_device(inputdev);
-	return 0;
+	input_unregister_device(dev_get_drvdata(dev));
 }
 
 /*
@@ -406,7 +404,7 @@ static int cmpc_accel_add_v4(struct acpi_device *acpi)
 
 	accel->inputdev_state = CMPC_ACCEL_DEV_STATE_CLOSED;
 
-	error = cmpc_add_acpi_notify_device(acpi, "cmpc_accel_v4",
+	error = cmpc_add_acpi_notify_device(&acpi->dev, "cmpc_accel_v4",
 					    cmpc_accel_idev_init_v4);
 	if (error)
 		goto failed_input;
@@ -434,7 +432,7 @@ static int cmpc_accel_add_v4(struct acpi_device *acpi)
 failed_g_select:
 	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4);
 failed_sensitivity:
-	cmpc_remove_acpi_notify_device(acpi);
+	cmpc_remove_acpi_notify_device(&acpi->dev);
 failed_input:
 	kfree(accel);
 	return error;
@@ -447,7 +445,7 @@ static void cmpc_accel_remove_v4(struct acpi_device *acpi)
 
 	device_remove_file(&acpi->dev, &cmpc_accel_g_select_attr_v4);
 	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4);
-	cmpc_remove_acpi_notify_device(acpi);
+	cmpc_remove_acpi_notify_device(&acpi->dev);
 	kfree(accel);
 }
 
@@ -659,7 +657,7 @@ static int cmpc_accel_add(struct acpi_device *acpi)
 	if (!accel)
 		return -ENOMEM;
 
-	error = cmpc_add_acpi_notify_device(acpi, "cmpc_accel",
+	error = cmpc_add_acpi_notify_device(&acpi->dev, "cmpc_accel",
 					    cmpc_accel_idev_init);
 	if (error)
 		goto failed_input;
@@ -678,7 +676,7 @@ static int cmpc_accel_add(struct acpi_device *acpi)
 	return 0;
 
 failed_file:
-	cmpc_remove_acpi_notify_device(acpi);
+	cmpc_remove_acpi_notify_device(&acpi->dev);
 failed_input:
 	kfree(accel);
 	return error;
@@ -690,7 +688,7 @@ static void cmpc_accel_remove(struct acpi_device *acpi)
 	struct cmpc_accel *accel = dev_get_drvdata(&inputdev->dev);
 
 	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr);
-	cmpc_remove_acpi_notify_device(acpi);
+	cmpc_remove_acpi_notify_device(&acpi->dev);
 	kfree(accel);
 }
 
@@ -762,13 +760,13 @@ static void cmpc_tablet_idev_init(struct input_dev *inputdev)
 
 static int cmpc_tablet_add(struct acpi_device *acpi)
 {
-	return cmpc_add_acpi_notify_device(acpi, "cmpc_tablet",
+	return cmpc_add_acpi_notify_device(&acpi->dev, "cmpc_tablet",
 					   cmpc_tablet_idev_init);
 }
 
 static void cmpc_tablet_remove(struct acpi_device *acpi)
 {
-	cmpc_remove_acpi_notify_device(acpi);
+	cmpc_remove_acpi_notify_device(&acpi->dev);
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -1086,13 +1084,13 @@ static void cmpc_keys_idev_init(struct input_dev *inputdev)
 
 static int cmpc_keys_add(struct acpi_device *acpi)
 {
-	return cmpc_add_acpi_notify_device(acpi, "cmpc_keys",
+	return cmpc_add_acpi_notify_device(&acpi->dev, "cmpc_keys",
 					   cmpc_keys_idev_init);
 }
 
 static void cmpc_keys_remove(struct acpi_device *acpi)
 {
-	cmpc_remove_acpi_notify_device(acpi);
+	cmpc_remove_acpi_notify_device(&acpi->dev);
 }
 
 static const struct acpi_device_id cmpc_keys_device_ids[] = {




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

* [PATCH v1 04/10] platform/x86: classmate-laptop: Rename two helper functions
  2026-05-07 19:58 [PATCH v1 00/10] platform/x86: classmate-laptop: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
                   ` (2 preceding siblings ...)
  2026-05-07 20:03 ` [PATCH v1 03/10] platform/x86: classmate-laptop: Pass struct device pointer to helpers Rafael J. Wysocki
@ 2026-05-07 20:04 ` Rafael J. Wysocki
  2026-05-07 20:07 ` [PATCH v1 05/10] platform/x86: classmate-laptop: Register ACPI notify handlers directly Rafael J. Wysocki
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-05-07 20:04 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
	Thadeu Lima de Souza Cascardo

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

Since cmpc_add_acpi_notify_device() and cmpc_remove_acpi_notify_device()
have been modified to take a plain struct device pointer as the first
argument, then have nothing to do with ACPI in principle, so rename
them to cmpc_add_notify_device() and cmpc_remove_notify_device(),
respectively, and consolidate white space around the call sites of
the former.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/platform/x86/classmate-laptop.c | 30 +++++++++++--------------
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
index 7784712bfabd..bb575ae2bc89 100644
--- a/drivers/platform/x86/classmate-laptop.c
+++ b/drivers/platform/x86/classmate-laptop.c
@@ -38,8 +38,8 @@ struct cmpc_accel {
 
 typedef void (*input_device_init)(struct input_dev *dev);
 
-static int cmpc_add_acpi_notify_device(struct device *dev, char *name,
-				       input_device_init idev_init)
+static int cmpc_add_notify_device(struct device *dev, char *name,
+				  input_device_init idev_init)
 {
 	struct input_dev *inputdev;
 	int error;
@@ -59,7 +59,7 @@ static int cmpc_add_acpi_notify_device(struct device *dev, char *name,
 	return 0;
 }
 
-static void cmpc_remove_acpi_notify_device(struct device *dev)
+static void cmpc_remove_notify_device(struct device *dev)
 {
 	input_unregister_device(dev_get_drvdata(dev));
 }
@@ -404,8 +404,7 @@ static int cmpc_accel_add_v4(struct acpi_device *acpi)
 
 	accel->inputdev_state = CMPC_ACCEL_DEV_STATE_CLOSED;
 
-	error = cmpc_add_acpi_notify_device(&acpi->dev, "cmpc_accel_v4",
-					    cmpc_accel_idev_init_v4);
+	error = cmpc_add_notify_device(&acpi->dev, "cmpc_accel_v4", cmpc_accel_idev_init_v4);
 	if (error)
 		goto failed_input;
 
@@ -432,7 +431,7 @@ static int cmpc_accel_add_v4(struct acpi_device *acpi)
 failed_g_select:
 	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4);
 failed_sensitivity:
-	cmpc_remove_acpi_notify_device(&acpi->dev);
+	cmpc_remove_notify_device(&acpi->dev);
 failed_input:
 	kfree(accel);
 	return error;
@@ -445,7 +444,7 @@ static void cmpc_accel_remove_v4(struct acpi_device *acpi)
 
 	device_remove_file(&acpi->dev, &cmpc_accel_g_select_attr_v4);
 	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4);
-	cmpc_remove_acpi_notify_device(&acpi->dev);
+	cmpc_remove_notify_device(&acpi->dev);
 	kfree(accel);
 }
 
@@ -657,8 +656,7 @@ static int cmpc_accel_add(struct acpi_device *acpi)
 	if (!accel)
 		return -ENOMEM;
 
-	error = cmpc_add_acpi_notify_device(&acpi->dev, "cmpc_accel",
-					    cmpc_accel_idev_init);
+	error = cmpc_add_notify_device(&acpi->dev, "cmpc_accel", cmpc_accel_idev_init);
 	if (error)
 		goto failed_input;
 
@@ -676,7 +674,7 @@ static int cmpc_accel_add(struct acpi_device *acpi)
 	return 0;
 
 failed_file:
-	cmpc_remove_acpi_notify_device(&acpi->dev);
+	cmpc_remove_notify_device(&acpi->dev);
 failed_input:
 	kfree(accel);
 	return error;
@@ -688,7 +686,7 @@ static void cmpc_accel_remove(struct acpi_device *acpi)
 	struct cmpc_accel *accel = dev_get_drvdata(&inputdev->dev);
 
 	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr);
-	cmpc_remove_acpi_notify_device(&acpi->dev);
+	cmpc_remove_notify_device(&acpi->dev);
 	kfree(accel);
 }
 
@@ -760,13 +758,12 @@ static void cmpc_tablet_idev_init(struct input_dev *inputdev)
 
 static int cmpc_tablet_add(struct acpi_device *acpi)
 {
-	return cmpc_add_acpi_notify_device(&acpi->dev, "cmpc_tablet",
-					   cmpc_tablet_idev_init);
+	return cmpc_add_notify_device(&acpi->dev, "cmpc_tablet", cmpc_tablet_idev_init);
 }
 
 static void cmpc_tablet_remove(struct acpi_device *acpi)
 {
-	cmpc_remove_acpi_notify_device(&acpi->dev);
+	cmpc_remove_notify_device(&acpi->dev);
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -1084,13 +1081,12 @@ static void cmpc_keys_idev_init(struct input_dev *inputdev)
 
 static int cmpc_keys_add(struct acpi_device *acpi)
 {
-	return cmpc_add_acpi_notify_device(&acpi->dev, "cmpc_keys",
-					   cmpc_keys_idev_init);
+	return cmpc_add_notify_device(&acpi->dev, "cmpc_keys", cmpc_keys_idev_init);
 }
 
 static void cmpc_keys_remove(struct acpi_device *acpi)
 {
-	cmpc_remove_acpi_notify_device(&acpi->dev);
+	cmpc_remove_notify_device(&acpi->dev);
 }
 
 static const struct acpi_device_id cmpc_keys_device_ids[] = {




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

* [PATCH v1 05/10] platform/x86: classmate-laptop: Register ACPI notify handlers directly
  2026-05-07 19:58 [PATCH v1 00/10] platform/x86: classmate-laptop: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
                   ` (3 preceding siblings ...)
  2026-05-07 20:04 ` [PATCH v1 04/10] platform/x86: classmate-laptop: Rename two helper functions Rafael J. Wysocki
@ 2026-05-07 20:07 ` Rafael J. Wysocki
  2026-05-07 20:10 ` [PATCH v1 06/10] platform/x86: classmate-laptop: Convert v4 accel driver to a platform one Rafael J. Wysocki
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-05-07 20:07 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
	Thadeu Lima de Souza Cascardo

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

To facilitate subsequent conversions of classmate-laptop driver
subdrivers to using struct platform_driver instead of struct
acpi_driver, make them install their ACPI notify handlers directly
instead of using .notify() callbacks in struct acpi_driver.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/platform/x86/classmate-laptop.c | 66 +++++++++++++++++++++----
 1 file changed, 56 insertions(+), 10 deletions(-)

diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
index bb575ae2bc89..938014c0e613 100644
--- a/drivers/platform/x86/classmate-laptop.c
+++ b/drivers/platform/x86/classmate-laptop.c
@@ -177,8 +177,10 @@ static acpi_status cmpc_get_accel_v4(acpi_handle handle,
 	return status;
 }
 
-static void cmpc_accel_handler_v4(struct acpi_device *dev, u32 event)
+static void cmpc_accel_handler_v4(acpi_handle handle, u32 event, void *data)
 {
+	struct acpi_device *dev = data;
+
 	if (event == 0x81) {
 		int16_t x, y, z;
 		acpi_status status;
@@ -424,10 +426,17 @@ static int cmpc_accel_add_v4(struct acpi_device *acpi)
 	if (error)
 		goto failed_g_select;
 
+	error = acpi_dev_install_notify_handler(acpi, ACPI_DEVICE_NOTIFY,
+						cmpc_accel_handler_v4, acpi);
+	if (error)
+		goto failed_notify_handler;
+
 	dev_set_drvdata(&inputdev->dev, accel);
 
 	return 0;
 
+failed_notify_handler:
+	device_remove_file(&acpi->dev, &cmpc_accel_g_select_attr_v4);
 failed_g_select:
 	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4);
 failed_sensitivity:
@@ -442,6 +451,8 @@ static void cmpc_accel_remove_v4(struct acpi_device *acpi)
 	struct input_dev *inputdev = dev_get_drvdata(&acpi->dev);
 	struct cmpc_accel *accel = dev_get_drvdata(&inputdev->dev);
 
+	acpi_dev_remove_notify_handler(acpi, ACPI_DEVICE_NOTIFY,
+				       cmpc_accel_handler_v4);
 	device_remove_file(&acpi->dev, &cmpc_accel_g_select_attr_v4);
 	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4);
 	cmpc_remove_notify_device(&acpi->dev);
@@ -463,7 +474,6 @@ static struct acpi_driver cmpc_accel_acpi_driver_v4 = {
 	.ops = {
 		.add = cmpc_accel_add_v4,
 		.remove = cmpc_accel_remove_v4,
-		.notify = cmpc_accel_handler_v4,
 	},
 	.drv.pm = &cmpc_accel_pm,
 };
@@ -545,8 +555,10 @@ static acpi_status cmpc_get_accel(acpi_handle handle,
 	return status;
 }
 
-static void cmpc_accel_handler(struct acpi_device *dev, u32 event)
+static void cmpc_accel_handler(acpi_handle handle, u32 event, void *data)
 {
+	struct acpi_device *dev = data;
+
 	if (event == 0x81) {
 		unsigned char x, y, z;
 		acpi_status status;
@@ -669,10 +681,17 @@ static int cmpc_accel_add(struct acpi_device *acpi)
 	if (error)
 		goto failed_file;
 
+	error = acpi_dev_install_notify_handler(acpi, ACPI_DEVICE_NOTIFY,
+						cmpc_accel_handler, acpi);
+	if (error)
+		goto failed_notify_handler;
+
 	dev_set_drvdata(&inputdev->dev, accel);
 
 	return 0;
 
+failed_notify_handler:
+	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr);
 failed_file:
 	cmpc_remove_notify_device(&acpi->dev);
 failed_input:
@@ -685,6 +704,8 @@ static void cmpc_accel_remove(struct acpi_device *acpi)
 	struct input_dev *inputdev = dev_get_drvdata(&acpi->dev);
 	struct cmpc_accel *accel = dev_get_drvdata(&inputdev->dev);
 
+	acpi_dev_remove_notify_handler(acpi, ACPI_DEVICE_NOTIFY,
+				       cmpc_accel_handler);
 	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr);
 	cmpc_remove_notify_device(&acpi->dev);
 	kfree(accel);
@@ -702,7 +723,6 @@ static struct acpi_driver cmpc_accel_acpi_driver = {
 	.ops = {
 		.add = cmpc_accel_add,
 		.remove = cmpc_accel_remove,
-		.notify = cmpc_accel_handler,
 	}
 };
 
@@ -728,8 +748,9 @@ static acpi_status cmpc_get_tablet(acpi_handle handle,
 	return status;
 }
 
-static void cmpc_tablet_handler(struct acpi_device *dev, u32 event)
+static void cmpc_tablet_handler(acpi_handle handle, u32 event, void *data)
 {
+	struct acpi_device *dev = data;
 	unsigned long long val = 0;
 	struct input_dev *inputdev = dev_get_drvdata(&dev->dev);
 
@@ -758,11 +779,24 @@ static void cmpc_tablet_idev_init(struct input_dev *inputdev)
 
 static int cmpc_tablet_add(struct acpi_device *acpi)
 {
-	return cmpc_add_notify_device(&acpi->dev, "cmpc_tablet", cmpc_tablet_idev_init);
+	int error;
+
+	error = cmpc_add_notify_device(&acpi->dev, "cmpc_tablet", cmpc_tablet_idev_init);
+	if (error)
+		return error;
+
+	error = acpi_dev_install_notify_handler(acpi, ACPI_DEVICE_NOTIFY,
+						cmpc_tablet_handler, acpi);
+	if (error)
+		cmpc_remove_notify_device(&acpi->dev);
+
+	return error;
 }
 
 static void cmpc_tablet_remove(struct acpi_device *acpi)
 {
+	acpi_dev_remove_notify_handler(acpi, ACPI_DEVICE_NOTIFY,
+				       cmpc_tablet_handler);
 	cmpc_remove_notify_device(&acpi->dev);
 }
 
@@ -794,7 +828,6 @@ static struct acpi_driver cmpc_tablet_acpi_driver = {
 	.ops = {
 		.add = cmpc_tablet_add,
 		.remove = cmpc_tablet_remove,
-		.notify = cmpc_tablet_handler,
 	},
 	.drv.pm = &cmpc_tablet_pm,
 };
@@ -1058,8 +1091,9 @@ static int cmpc_keys_codes[] = {
 	KEY_MAX
 };
 
-static void cmpc_keys_handler(struct acpi_device *dev, u32 event)
+static void cmpc_keys_handler(acpi_handle handle, u32 event, void *data)
 {
+	struct acpi_device *dev = data;
 	struct input_dev *inputdev;
 	int code = KEY_MAX;
 
@@ -1081,11 +1115,24 @@ static void cmpc_keys_idev_init(struct input_dev *inputdev)
 
 static int cmpc_keys_add(struct acpi_device *acpi)
 {
-	return cmpc_add_notify_device(&acpi->dev, "cmpc_keys", cmpc_keys_idev_init);
+	int error;
+
+	error = cmpc_add_notify_device(&acpi->dev, "cmpc_keys", cmpc_keys_idev_init);
+	if (error)
+		return error;
+
+	error = acpi_dev_install_notify_handler(acpi, ACPI_DEVICE_NOTIFY,
+						cmpc_keys_handler, acpi);
+	if (error)
+		cmpc_remove_notify_device(&acpi->dev);
+
+	return error;
 }
 
 static void cmpc_keys_remove(struct acpi_device *acpi)
 {
+	acpi_dev_remove_notify_handler(acpi, ACPI_DEVICE_NOTIFY,
+				       cmpc_keys_handler);
 	cmpc_remove_notify_device(&acpi->dev);
 }
 
@@ -1101,7 +1148,6 @@ static struct acpi_driver cmpc_keys_acpi_driver = {
 	.ops = {
 		.add = cmpc_keys_add,
 		.remove = cmpc_keys_remove,
-		.notify = cmpc_keys_handler,
 	}
 };
 




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

* [PATCH v1 06/10] platform/x86: classmate-laptop: Convert v4 accel driver to a platform one
  2026-05-07 19:58 [PATCH v1 00/10] platform/x86: classmate-laptop: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
                   ` (4 preceding siblings ...)
  2026-05-07 20:07 ` [PATCH v1 05/10] platform/x86: classmate-laptop: Register ACPI notify handlers directly Rafael J. Wysocki
@ 2026-05-07 20:10 ` Rafael J. Wysocki
  2026-05-07 20:10 ` [PATCH v1 07/10] platform/x86: classmate-laptop: Convert " Rafael J. Wysocki
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-05-07 20:10 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
	Thadeu Lima de Souza Cascardo

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

In all cases in which a struct acpi_driver is used for binding a driver
to an ACPI device object, a corresponding platform device is created by
the ACPI core and that device is regarded as a proper representation of
underlying hardware.  Accordingly, a struct platform_driver should be
used by driver code to bind to that device.  There are multiple reasons
why drivers should not bind directly to ACPI device objects [1].

Overall, it is better to bind drivers to platform devices than to their
ACPI companions, so convert cmpc_accel_acpi_driver_v4 in the platform
x86 classmate-laptop driver from an ACPI driver to a platform one.

After this change, the input device registered by the driver will
appear under the platform device used for driver binding, but the sysfs
attributes added by the driver under the ACPI companion of that device
will stay there in case there are utilities in user space expecting
them to be present there.

While this is not expected to alter functionality, it changes sysfs
layout and so it will be visible to user space.

Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/platform/x86/classmate-laptop.c | 74 +++++++++++++------------
 1 file changed, 38 insertions(+), 36 deletions(-)

diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
index 938014c0e613..a19082267f41 100644
--- a/drivers/platform/x86/classmate-laptop.c
+++ b/drivers/platform/x86/classmate-laptop.c
@@ -13,6 +13,7 @@
 #include <linux/input.h>
 #include <linux/rfkill.h>
 #include <linux/sysfs.h>
+#include <linux/platform_device.h>
 
 struct cmpc_accel {
 	int sensitivity;
@@ -179,15 +180,15 @@ static acpi_status cmpc_get_accel_v4(acpi_handle handle,
 
 static void cmpc_accel_handler_v4(acpi_handle handle, u32 event, void *data)
 {
-	struct acpi_device *dev = data;
+	struct device *dev = data;
 
 	if (event == 0x81) {
 		int16_t x, y, z;
 		acpi_status status;
 
-		status = cmpc_get_accel_v4(dev->handle, &x, &y, &z);
+		status = cmpc_get_accel_v4(ACPI_HANDLE(dev), &x, &y, &z);
 		if (ACPI_SUCCESS(status)) {
-			struct input_dev *inputdev = dev_get_drvdata(&dev->dev);
+			struct input_dev *inputdev = dev_get_drvdata(dev);
 
 			input_report_abs(inputdev, ABS_X, x);
 			input_report_abs(inputdev, ABS_Y, y);
@@ -317,18 +318,17 @@ static struct device_attribute cmpc_accel_g_select_attr_v4 = {
 
 static int cmpc_accel_open_v4(struct input_dev *input)
 {
-	struct acpi_device *acpi;
+	acpi_handle handle = ACPI_HANDLE(input->dev.parent);
 	struct cmpc_accel *accel;
 
-	acpi = to_acpi_device(input->dev.parent);
 	accel = dev_get_drvdata(&input->dev);
 	if (!accel)
 		return -ENXIO;
 
-	cmpc_accel_set_sensitivity_v4(acpi->handle, accel->sensitivity);
-	cmpc_accel_set_g_select_v4(acpi->handle, accel->g_select);
+	cmpc_accel_set_sensitivity_v4(handle, accel->sensitivity);
+	cmpc_accel_set_g_select_v4(handle, accel->g_select);
 
-	if (ACPI_SUCCESS(cmpc_start_accel_v4(acpi->handle))) {
+	if (ACPI_SUCCESS(cmpc_start_accel_v4(handle))) {
 		accel->inputdev_state = CMPC_ACCEL_DEV_STATE_OPEN;
 		return 0;
 	}
@@ -337,13 +337,11 @@ static int cmpc_accel_open_v4(struct input_dev *input)
 
 static void cmpc_accel_close_v4(struct input_dev *input)
 {
-	struct acpi_device *acpi;
 	struct cmpc_accel *accel;
 
-	acpi = to_acpi_device(input->dev.parent);
 	accel = dev_get_drvdata(&input->dev);
 
-	cmpc_stop_accel_v4(acpi->handle);
+	cmpc_stop_accel_v4(ACPI_HANDLE(input->dev.parent));
 	accel->inputdev_state = CMPC_ACCEL_DEV_STATE_CLOSED;
 }
 
@@ -367,7 +365,7 @@ static int cmpc_accel_suspend_v4(struct device *dev)
 	accel = dev_get_drvdata(&inputdev->dev);
 
 	if (accel->inputdev_state == CMPC_ACCEL_DEV_STATE_OPEN)
-		return cmpc_stop_accel_v4(to_acpi_device(dev)->handle);
+		return cmpc_stop_accel_v4(ACPI_HANDLE(dev));
 
 	return 0;
 }
@@ -381,12 +379,12 @@ static int cmpc_accel_resume_v4(struct device *dev)
 	accel = dev_get_drvdata(&inputdev->dev);
 
 	if (accel->inputdev_state == CMPC_ACCEL_DEV_STATE_OPEN) {
-		cmpc_accel_set_sensitivity_v4(to_acpi_device(dev)->handle,
-					      accel->sensitivity);
-		cmpc_accel_set_g_select_v4(to_acpi_device(dev)->handle,
-					   accel->g_select);
+		acpi_handle handle = ACPI_HANDLE(dev);
 
-		if (ACPI_FAILURE(cmpc_start_accel_v4(to_acpi_device(dev)->handle)))
+		cmpc_accel_set_sensitivity_v4(handle, accel->sensitivity);
+		cmpc_accel_set_g_select_v4(handle, accel->g_select);
+
+		if (ACPI_FAILURE(cmpc_start_accel_v4(handle)))
 			return -EIO;
 	}
 
@@ -394,11 +392,12 @@ static int cmpc_accel_resume_v4(struct device *dev)
 }
 #endif
 
-static int cmpc_accel_add_v4(struct acpi_device *acpi)
+static int cmpc_accel_probe_v4(struct platform_device *pdev)
 {
-	int error;
+	struct acpi_device *acpi = ACPI_COMPANION(&pdev->dev);
 	struct input_dev *inputdev;
 	struct cmpc_accel *accel;
+	int error;
 
 	accel = kmalloc_obj(*accel);
 	if (!accel)
@@ -406,11 +405,12 @@ static int cmpc_accel_add_v4(struct acpi_device *acpi)
 
 	accel->inputdev_state = CMPC_ACCEL_DEV_STATE_CLOSED;
 
-	error = cmpc_add_notify_device(&acpi->dev, "cmpc_accel_v4", cmpc_accel_idev_init_v4);
+	error = cmpc_add_notify_device(&pdev->dev, "cmpc_accel_v4", cmpc_accel_idev_init_v4);
 	if (error)
 		goto failed_input;
 
-	inputdev = dev_get_drvdata(&acpi->dev);
+	inputdev = dev_get_drvdata(&pdev->dev);
+	dev_set_drvdata(&acpi->dev, inputdev);
 
 	accel->sensitivity = CMPC_ACCEL_SENSITIVITY_DEFAULT;
 	cmpc_accel_set_sensitivity_v4(acpi->handle, accel->sensitivity);
@@ -427,7 +427,7 @@ static int cmpc_accel_add_v4(struct acpi_device *acpi)
 		goto failed_g_select;
 
 	error = acpi_dev_install_notify_handler(acpi, ACPI_DEVICE_NOTIFY,
-						cmpc_accel_handler_v4, acpi);
+						cmpc_accel_handler_v4, &pdev->dev);
 	if (error)
 		goto failed_notify_handler;
 
@@ -440,22 +440,25 @@ static int cmpc_accel_add_v4(struct acpi_device *acpi)
 failed_g_select:
 	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4);
 failed_sensitivity:
-	cmpc_remove_notify_device(&acpi->dev);
+	dev_set_drvdata(&acpi->dev, NULL);
+	cmpc_remove_notify_device(&pdev->dev);
 failed_input:
 	kfree(accel);
 	return error;
 }
 
-static void cmpc_accel_remove_v4(struct acpi_device *acpi)
+static void cmpc_accel_remove_v4(struct platform_device *pdev)
 {
-	struct input_dev *inputdev = dev_get_drvdata(&acpi->dev);
+	struct input_dev *inputdev = platform_get_drvdata(pdev);
 	struct cmpc_accel *accel = dev_get_drvdata(&inputdev->dev);
+	struct acpi_device *acpi = ACPI_COMPANION(&pdev->dev);
 
 	acpi_dev_remove_notify_handler(acpi, ACPI_DEVICE_NOTIFY,
 				       cmpc_accel_handler_v4);
 	device_remove_file(&acpi->dev, &cmpc_accel_g_select_attr_v4);
 	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4);
-	cmpc_remove_notify_device(&acpi->dev);
+	dev_set_drvdata(&acpi->dev, NULL);
+	cmpc_remove_notify_device(&pdev->dev);
 	kfree(accel);
 }
 
@@ -467,15 +470,14 @@ static const struct acpi_device_id cmpc_accel_device_ids_v4[] = {
 	{"", 0}
 };
 
-static struct acpi_driver cmpc_accel_acpi_driver_v4 = {
-	.name = "cmpc_accel_v4",
-	.class = "cmpc_accel_v4",
-	.ids = cmpc_accel_device_ids_v4,
-	.ops = {
-		.add = cmpc_accel_add_v4,
-		.remove = cmpc_accel_remove_v4,
+static struct platform_driver cmpc_accel_acpi_driver_v4 = {
+	.probe = cmpc_accel_probe_v4,
+	.remove = cmpc_accel_remove_v4,
+	.driver = {
+		.name = "cmpc_accel_v4",
+		.acpi_match_table = cmpc_accel_device_ids_v4,
+		.pm = &cmpc_accel_pm,
 	},
-	.drv.pm = &cmpc_accel_pm,
 };
 
 
@@ -1176,7 +1178,7 @@ static int cmpc_init(void)
 	if (r)
 		goto failed_accel;
 
-	r = acpi_bus_register_driver(&cmpc_accel_acpi_driver_v4);
+	r = platform_driver_register(&cmpc_accel_acpi_driver_v4);
 	if (r)
 		goto failed_accel_v4;
 
@@ -1200,7 +1202,7 @@ static int cmpc_init(void)
 
 static void cmpc_exit(void)
 {
-	acpi_bus_unregister_driver(&cmpc_accel_acpi_driver_v4);
+	platform_driver_unregister(&cmpc_accel_acpi_driver_v4);
 	acpi_bus_unregister_driver(&cmpc_accel_acpi_driver);
 	acpi_bus_unregister_driver(&cmpc_tablet_acpi_driver);
 	acpi_bus_unregister_driver(&cmpc_ipml_acpi_driver);




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

* [PATCH v1 07/10] platform/x86: classmate-laptop: Convert accel driver to a platform one
  2026-05-07 19:58 [PATCH v1 00/10] platform/x86: classmate-laptop: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
                   ` (5 preceding siblings ...)
  2026-05-07 20:10 ` [PATCH v1 06/10] platform/x86: classmate-laptop: Convert v4 accel driver to a platform one Rafael J. Wysocki
@ 2026-05-07 20:10 ` Rafael J. Wysocki
  2026-05-07 20:11 ` [PATCH v1 08/10] platform/x86: classmate-laptop: Convert tablet " Rafael J. Wysocki
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-05-07 20:10 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
	Thadeu Lima de Souza Cascardo

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

In all cases in which a struct acpi_driver is used for binding a driver
to an ACPI device object, a corresponding platform device is created by
the ACPI core and that device is regarded as a proper representation of
underlying hardware.  Accordingly, a struct platform_driver should be
used by driver code to bind to that device.  There are multiple reasons
why drivers should not bind directly to ACPI device objects [1].

Overall, it is better to bind drivers to platform devices than to their
ACPI companions, so convert cmpc_accel_acpi_driver in the platform
x86 classmate-laptop driver from an ACPI driver to a platform one.

After this change, the input device registered by the driver will
appear under the platform device used for driver binding, but the sysfs
attribute added by the driver under the ACPI companion of that device
will stay there in case there are utilities in user space expecting
it to be present there.

While this is not expected to alter functionality, it changes sysfs
layout and so it will be visible to user space.

Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/platform/x86/classmate-laptop.c | 60 ++++++++++++-------------
 1 file changed, 29 insertions(+), 31 deletions(-)

diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
index a19082267f41..06040e69eb31 100644
--- a/drivers/platform/x86/classmate-laptop.c
+++ b/drivers/platform/x86/classmate-laptop.c
@@ -559,15 +559,15 @@ static acpi_status cmpc_get_accel(acpi_handle handle,
 
 static void cmpc_accel_handler(acpi_handle handle, u32 event, void *data)
 {
-	struct acpi_device *dev = data;
+	struct device *dev = data;
 
 	if (event == 0x81) {
 		unsigned char x, y, z;
 		acpi_status status;
 
-		status = cmpc_get_accel(dev->handle, &x, &y, &z);
+		status = cmpc_get_accel(ACPI_HANDLE(dev), &x, &y, &z);
 		if (ACPI_SUCCESS(status)) {
-			struct input_dev *inputdev = dev_get_drvdata(&dev->dev);
+			struct input_dev *inputdev = dev_get_drvdata(dev);
 
 			input_report_abs(inputdev, ABS_X, x);
 			input_report_abs(inputdev, ABS_Y, y);
@@ -634,20 +634,14 @@ static struct device_attribute cmpc_accel_sensitivity_attr = {
 
 static int cmpc_accel_open(struct input_dev *input)
 {
-	struct acpi_device *acpi;
-
-	acpi = to_acpi_device(input->dev.parent);
-	if (ACPI_SUCCESS(cmpc_start_accel(acpi->handle)))
+	if (ACPI_SUCCESS(cmpc_start_accel(ACPI_HANDLE(input->dev.parent))))
 		return 0;
 	return -EIO;
 }
 
 static void cmpc_accel_close(struct input_dev *input)
 {
-	struct acpi_device *acpi;
-
-	acpi = to_acpi_device(input->dev.parent);
-	cmpc_stop_accel(acpi->handle);
+	cmpc_stop_accel(ACPI_HANDLE(input->dev.parent));
 }
 
 static void cmpc_accel_idev_init(struct input_dev *inputdev)
@@ -660,21 +654,23 @@ static void cmpc_accel_idev_init(struct input_dev *inputdev)
 	inputdev->close = cmpc_accel_close;
 }
 
-static int cmpc_accel_add(struct acpi_device *acpi)
+static int cmpc_accel_probe(struct platform_device *pdev)
 {
-	int error;
+	struct acpi_device *acpi = ACPI_COMPANION(&pdev->dev);
 	struct input_dev *inputdev;
 	struct cmpc_accel *accel;
+	int error;
 
 	accel = kmalloc_obj(*accel);
 	if (!accel)
 		return -ENOMEM;
 
-	error = cmpc_add_notify_device(&acpi->dev, "cmpc_accel", cmpc_accel_idev_init);
+	error = cmpc_add_notify_device(&pdev->dev, "cmpc_accel", cmpc_accel_idev_init);
 	if (error)
 		goto failed_input;
 
-	inputdev = dev_get_drvdata(&acpi->dev);
+	inputdev = dev_get_drvdata(&pdev->dev);
+	dev_set_drvdata(&acpi->dev, inputdev);
 
 	accel->sensitivity = CMPC_ACCEL_SENSITIVITY_DEFAULT;
 	cmpc_accel_set_sensitivity(acpi->handle, accel->sensitivity);
@@ -684,7 +680,7 @@ static int cmpc_accel_add(struct acpi_device *acpi)
 		goto failed_file;
 
 	error = acpi_dev_install_notify_handler(acpi, ACPI_DEVICE_NOTIFY,
-						cmpc_accel_handler, acpi);
+						cmpc_accel_handler, &pdev->dev);
 	if (error)
 		goto failed_notify_handler;
 
@@ -695,21 +691,24 @@ static int cmpc_accel_add(struct acpi_device *acpi)
 failed_notify_handler:
 	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr);
 failed_file:
-	cmpc_remove_notify_device(&acpi->dev);
+	dev_set_drvdata(&acpi->dev, NULL);
+	cmpc_remove_notify_device(&pdev->dev);
 failed_input:
 	kfree(accel);
 	return error;
 }
 
-static void cmpc_accel_remove(struct acpi_device *acpi)
+static void cmpc_accel_remove(struct platform_device *pdev)
 {
-	struct input_dev *inputdev = dev_get_drvdata(&acpi->dev);
+	struct input_dev *inputdev = dev_get_drvdata(&pdev->dev);
 	struct cmpc_accel *accel = dev_get_drvdata(&inputdev->dev);
+	struct acpi_device *acpi = ACPI_COMPANION(&pdev->dev);
 
 	acpi_dev_remove_notify_handler(acpi, ACPI_DEVICE_NOTIFY,
 				       cmpc_accel_handler);
 	device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr);
-	cmpc_remove_notify_device(&acpi->dev);
+	dev_set_drvdata(&acpi->dev, NULL);
+	cmpc_remove_notify_device(&pdev->dev);
 	kfree(accel);
 }
 
@@ -718,14 +717,13 @@ static const struct acpi_device_id cmpc_accel_device_ids[] = {
 	{"", 0}
 };
 
-static struct acpi_driver cmpc_accel_acpi_driver = {
-	.name = "cmpc_accel",
-	.class = "cmpc_accel",
-	.ids = cmpc_accel_device_ids,
-	.ops = {
-		.add = cmpc_accel_add,
-		.remove = cmpc_accel_remove,
-	}
+static struct platform_driver cmpc_accel_acpi_driver = {
+	.probe = cmpc_accel_probe,
+	.remove = cmpc_accel_remove,
+	.driver = {
+		.name = "cmpc_accel",
+		.acpi_match_table = cmpc_accel_device_ids,
+	},
 };
 
 
@@ -1174,7 +1172,7 @@ static int cmpc_init(void)
 	if (r)
 		goto failed_tablet;
 
-	r = acpi_bus_register_driver(&cmpc_accel_acpi_driver);
+	r = platform_driver_register(&cmpc_accel_acpi_driver);
 	if (r)
 		goto failed_accel;
 
@@ -1185,7 +1183,7 @@ static int cmpc_init(void)
 	return r;
 
 failed_accel_v4:
-	acpi_bus_unregister_driver(&cmpc_accel_acpi_driver);
+	platform_driver_unregister(&cmpc_accel_acpi_driver);
 
 failed_accel:
 	acpi_bus_unregister_driver(&cmpc_tablet_acpi_driver);
@@ -1203,7 +1201,7 @@ static int cmpc_init(void)
 static void cmpc_exit(void)
 {
 	platform_driver_unregister(&cmpc_accel_acpi_driver_v4);
-	acpi_bus_unregister_driver(&cmpc_accel_acpi_driver);
+	platform_driver_unregister(&cmpc_accel_acpi_driver);
 	acpi_bus_unregister_driver(&cmpc_tablet_acpi_driver);
 	acpi_bus_unregister_driver(&cmpc_ipml_acpi_driver);
 	acpi_bus_unregister_driver(&cmpc_keys_acpi_driver);
 
2.51.0





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

* [PATCH v1 08/10] platform/x86: classmate-laptop: Convert tablet driver to a platform one
  2026-05-07 19:58 [PATCH v1 00/10] platform/x86: classmate-laptop: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
                   ` (6 preceding siblings ...)
  2026-05-07 20:10 ` [PATCH v1 07/10] platform/x86: classmate-laptop: Convert " Rafael J. Wysocki
@ 2026-05-07 20:11 ` Rafael J. Wysocki
  2026-05-07 20:12 ` [PATCH v1 09/10] platform/x86: classmate-laptop: Convert ipml " Rafael J. Wysocki
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-05-07 20:11 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
	Thadeu Lima de Souza Cascardo

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

In all cases in which a struct acpi_driver is used for binding a driver
to an ACPI device object, a corresponding platform device is created by
the ACPI core and that device is regarded as a proper representation of
underlying hardware.  Accordingly, a struct platform_driver should be
used by driver code to bind to that device.  There are multiple reasons
why drivers should not bind directly to ACPI device objects [1].

Overall, it is better to bind drivers to platform devices than to their
ACPI companions, so convert cmpc_tablet_acpi_driver in the platform
x86 classmate-laptop driver from an ACPI driver to a platform one.

After this change, the input device registered by the driver will appear
under the platform device used for driver binding.

While this is not expected to alter functionality, it changes sysfs
layout and so it will be visible to user space.

Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/platform/x86/classmate-laptop.c | 53 ++++++++++++-------------
 1 file changed, 26 insertions(+), 27 deletions(-)

diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
index 06040e69eb31..0bb0359387a7 100644
--- a/drivers/platform/x86/classmate-laptop.c
+++ b/drivers/platform/x86/classmate-laptop.c
@@ -750,12 +750,12 @@ static acpi_status cmpc_get_tablet(acpi_handle handle,
 
 static void cmpc_tablet_handler(acpi_handle handle, u32 event, void *data)
 {
-	struct acpi_device *dev = data;
+	struct device *dev = data;
 	unsigned long long val = 0;
-	struct input_dev *inputdev = dev_get_drvdata(&dev->dev);
+	struct input_dev *inputdev = dev_get_drvdata(dev);
 
 	if (event == 0x81) {
-		if (ACPI_SUCCESS(cmpc_get_tablet(dev->handle, &val))) {
+		if (ACPI_SUCCESS(cmpc_get_tablet(ACPI_HANDLE(dev), &val))) {
 			input_report_switch(inputdev, SW_TABLET_MODE, !val);
 			input_sync(inputdev);
 		}
@@ -764,40 +764,40 @@ static void cmpc_tablet_handler(acpi_handle handle, u32 event, void *data)
 
 static void cmpc_tablet_idev_init(struct input_dev *inputdev)
 {
+	acpi_handle handle = ACPI_HANDLE(inputdev->dev.parent);
 	unsigned long long val = 0;
-	struct acpi_device *acpi;
 
 	set_bit(EV_SW, inputdev->evbit);
 	set_bit(SW_TABLET_MODE, inputdev->swbit);
 
-	acpi = to_acpi_device(inputdev->dev.parent);
-	if (ACPI_SUCCESS(cmpc_get_tablet(acpi->handle, &val))) {
+	if (ACPI_SUCCESS(cmpc_get_tablet(handle, &val))) {
 		input_report_switch(inputdev, SW_TABLET_MODE, !val);
 		input_sync(inputdev);
 	}
 }
 
-static int cmpc_tablet_add(struct acpi_device *acpi)
+static int cmpc_tablet_probe(struct platform_device *pdev)
 {
 	int error;
 
-	error = cmpc_add_notify_device(&acpi->dev, "cmpc_tablet", cmpc_tablet_idev_init);
+	error = cmpc_add_notify_device(&pdev->dev, "cmpc_tablet", cmpc_tablet_idev_init);
 	if (error)
 		return error;
 
-	error = acpi_dev_install_notify_handler(acpi, ACPI_DEVICE_NOTIFY,
-						cmpc_tablet_handler, acpi);
+	error = acpi_dev_install_notify_handler(ACPI_COMPANION(&pdev->dev),
+						ACPI_DEVICE_NOTIFY,
+						cmpc_tablet_handler, &pdev->dev);
 	if (error)
-		cmpc_remove_notify_device(&acpi->dev);
+		cmpc_remove_notify_device(&pdev->dev);
 
 	return error;
 }
 
-static void cmpc_tablet_remove(struct acpi_device *acpi)
+static void cmpc_tablet_remove(struct platform_device *pdev)
 {
-	acpi_dev_remove_notify_handler(acpi, ACPI_DEVICE_NOTIFY,
-				       cmpc_tablet_handler);
-	cmpc_remove_notify_device(&acpi->dev);
+	acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev),
+				       ACPI_DEVICE_NOTIFY, cmpc_tablet_handler);
+	cmpc_remove_notify_device(&pdev->dev);
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -806,7 +806,7 @@ static int cmpc_tablet_resume(struct device *dev)
 	struct input_dev *inputdev = dev_get_drvdata(dev);
 
 	unsigned long long val = 0;
-	if (ACPI_SUCCESS(cmpc_get_tablet(to_acpi_device(dev)->handle, &val))) {
+	if (ACPI_SUCCESS(cmpc_get_tablet(ACPI_HANDLE(dev), &val))) {
 		input_report_switch(inputdev, SW_TABLET_MODE, !val);
 		input_sync(inputdev);
 	}
@@ -821,15 +821,14 @@ static const struct acpi_device_id cmpc_tablet_device_ids[] = {
 	{"", 0}
 };
 
-static struct acpi_driver cmpc_tablet_acpi_driver = {
-	.name = "cmpc_tablet",
-	.class = "cmpc_tablet",
-	.ids = cmpc_tablet_device_ids,
-	.ops = {
-		.add = cmpc_tablet_add,
-		.remove = cmpc_tablet_remove,
+static struct platform_driver cmpc_tablet_acpi_driver = {
+	.probe = cmpc_tablet_probe,
+	.remove = cmpc_tablet_remove,
+	.driver = {
+		.name = "cmpc_tablet",
+		.acpi_match_table = cmpc_tablet_device_ids,
+		.pm = &cmpc_tablet_pm,
 	},
-	.drv.pm = &cmpc_tablet_pm,
 };
 
 
@@ -1168,7 +1167,7 @@ static int cmpc_init(void)
 	if (r)
 		goto failed_bl;
 
-	r = acpi_bus_register_driver(&cmpc_tablet_acpi_driver);
+	r = platform_driver_register(&cmpc_tablet_acpi_driver);
 	if (r)
 		goto failed_tablet;
 
@@ -1186,7 +1185,7 @@ static int cmpc_init(void)
 	platform_driver_unregister(&cmpc_accel_acpi_driver);
 
 failed_accel:
-	acpi_bus_unregister_driver(&cmpc_tablet_acpi_driver);
+	platform_driver_unregister(&cmpc_tablet_acpi_driver);
 
 failed_tablet:
 	acpi_bus_unregister_driver(&cmpc_ipml_acpi_driver);
@@ -1202,7 +1201,7 @@ static void cmpc_exit(void)
 {
 	platform_driver_unregister(&cmpc_accel_acpi_driver_v4);
 	platform_driver_unregister(&cmpc_accel_acpi_driver);
-	acpi_bus_unregister_driver(&cmpc_tablet_acpi_driver);
+	platform_driver_unregister(&cmpc_tablet_acpi_driver);
 	acpi_bus_unregister_driver(&cmpc_ipml_acpi_driver);
 	acpi_bus_unregister_driver(&cmpc_keys_acpi_driver);
 }




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

* [PATCH v1 09/10] platform/x86: classmate-laptop: Convert ipml driver to a platform one
  2026-05-07 19:58 [PATCH v1 00/10] platform/x86: classmate-laptop: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
                   ` (7 preceding siblings ...)
  2026-05-07 20:11 ` [PATCH v1 08/10] platform/x86: classmate-laptop: Convert tablet " Rafael J. Wysocki
@ 2026-05-07 20:12 ` Rafael J. Wysocki
  2026-05-07 20:14 ` [PATCH v1 10/10] platform/x86: classmate-laptop: Convert keys " Rafael J. Wysocki
  2026-05-08 12:05 ` [PATCH v1 00/10] platform/x86: classmate-laptop: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
  10 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-05-07 20:12 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
	Thadeu Lima de Souza Cascardo

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

In all cases in which a struct acpi_driver is used for binding a driver
to an ACPI device object, a corresponding platform device is created by
the ACPI core and that device is regarded as a proper representation of
underlying hardware.  Accordingly, a struct platform_driver should be
used by driver code to bind to that device.  There are multiple reasons
why drivers should not bind directly to ACPI device objects [1].

Overall, it is better to bind drivers to platform devices than to their
ACPI companions, so convert cmpc_ipml_acpi_driver in the platform
x86 classmate-laptop driver from an ACPI driver to a platform one.

After this change, the backlight and rfkill devices registered by the
driver will appear under the platform device used for driver binding.

While this is not expected to alter functionality, it changes sysfs
layout and so it will be visible to user space.

Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/platform/x86/classmate-laptop.c | 40 ++++++++++++-------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
index 0bb0359387a7..dc2b7a48435c 100644
--- a/drivers/platform/x86/classmate-laptop.c
+++ b/drivers/platform/x86/classmate-laptop.c
@@ -995,11 +995,12 @@ struct ipml200_dev {
 	struct rfkill *rf;
 };
 
-static int cmpc_ipml_add(struct acpi_device *acpi)
+static int cmpc_ipml_probe(struct platform_device *pdev)
 {
-	int retval;
+	acpi_handle handle = ACPI_HANDLE(&pdev->dev);
 	struct ipml200_dev *ipml;
 	struct backlight_properties props;
+	int retval;
 
 	ipml = kmalloc_obj(*ipml);
 	if (ipml == NULL)
@@ -1008,16 +1009,16 @@ static int cmpc_ipml_add(struct acpi_device *acpi)
 	memset(&props, 0, sizeof(struct backlight_properties));
 	props.type = BACKLIGHT_PLATFORM;
 	props.max_brightness = 7;
-	ipml->bd = backlight_device_register("cmpc_bl", &acpi->dev,
-					     acpi->handle, &cmpc_bl_ops,
+	ipml->bd = backlight_device_register("cmpc_bl", &pdev->dev,
+					     handle, &cmpc_bl_ops,
 					     &props);
 	if (IS_ERR(ipml->bd)) {
 		retval = PTR_ERR(ipml->bd);
 		goto out_bd;
 	}
 
-	ipml->rf = rfkill_alloc("cmpc_rfkill", &acpi->dev, RFKILL_TYPE_WLAN,
-				&cmpc_rfkill_ops, acpi->handle);
+	ipml->rf = rfkill_alloc("cmpc_rfkill", &pdev->dev, RFKILL_TYPE_WLAN,
+				&cmpc_rfkill_ops, handle);
 	/*
 	 * If RFKILL is disabled, rfkill_alloc will return ERR_PTR(-ENODEV).
 	 * This is OK, however, since all other uses of the device will not
@@ -1031,7 +1032,7 @@ static int cmpc_ipml_add(struct acpi_device *acpi)
 		}
 	}
 
-	dev_set_drvdata(&acpi->dev, ipml);
+	platform_set_drvdata(pdev, ipml);
 	return 0;
 
 out_bd:
@@ -1039,11 +1040,11 @@ static int cmpc_ipml_add(struct acpi_device *acpi)
 	return retval;
 }
 
-static void cmpc_ipml_remove(struct acpi_device *acpi)
+static void cmpc_ipml_remove(struct platform_device *pdev)
 {
 	struct ipml200_dev *ipml;
 
-	ipml = dev_get_drvdata(&acpi->dev);
+	ipml = platform_get_drvdata(pdev);
 
 	backlight_device_unregister(ipml->bd);
 
@@ -1060,14 +1061,13 @@ static const struct acpi_device_id cmpc_ipml_device_ids[] = {
 	{"", 0}
 };
 
-static struct acpi_driver cmpc_ipml_acpi_driver = {
-	.name = "cmpc",
-	.class = "cmpc",
-	.ids = cmpc_ipml_device_ids,
-	.ops = {
-		.add = cmpc_ipml_add,
-		.remove = cmpc_ipml_remove
-	}
+static struct platform_driver cmpc_ipml_acpi_driver = {
+	.probe = cmpc_ipml_probe,
+	.remove = cmpc_ipml_remove,
+	.driver = {
+		.name = "cmpc",
+		.acpi_match_table = cmpc_ipml_device_ids,
+	},
 };
 
 
@@ -1163,7 +1163,7 @@ static int cmpc_init(void)
 	if (r)
 		goto failed_keys;
 
-	r = acpi_bus_register_driver(&cmpc_ipml_acpi_driver);
+	r = platform_driver_register(&cmpc_ipml_acpi_driver);
 	if (r)
 		goto failed_bl;
 
@@ -1188,7 +1188,7 @@ static int cmpc_init(void)
 	platform_driver_unregister(&cmpc_tablet_acpi_driver);
 
 failed_tablet:
-	acpi_bus_unregister_driver(&cmpc_ipml_acpi_driver);
+	platform_driver_unregister(&cmpc_ipml_acpi_driver);
 
 failed_bl:
 	acpi_bus_unregister_driver(&cmpc_keys_acpi_driver);
@@ -1202,7 +1202,7 @@ static void cmpc_exit(void)
 	platform_driver_unregister(&cmpc_accel_acpi_driver_v4);
 	platform_driver_unregister(&cmpc_accel_acpi_driver);
 	platform_driver_unregister(&cmpc_tablet_acpi_driver);
-	acpi_bus_unregister_driver(&cmpc_ipml_acpi_driver);
+	platform_driver_unregister(&cmpc_ipml_acpi_driver);
 	acpi_bus_unregister_driver(&cmpc_keys_acpi_driver);
 }
 




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

* [PATCH v1 10/10] platform/x86: classmate-laptop: Convert keys driver to a platform one
  2026-05-07 19:58 [PATCH v1 00/10] platform/x86: classmate-laptop: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
                   ` (8 preceding siblings ...)
  2026-05-07 20:12 ` [PATCH v1 09/10] platform/x86: classmate-laptop: Convert ipml " Rafael J. Wysocki
@ 2026-05-07 20:14 ` Rafael J. Wysocki
  2026-05-08 12:05 ` [PATCH v1 00/10] platform/x86: classmate-laptop: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
  10 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-05-07 20:14 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
	Thadeu Lima de Souza Cascardo

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

In all cases in which a struct acpi_driver is used for binding a driver
to an ACPI device object, a corresponding platform device is created by
the ACPI core and that device is regarded as a proper representation of
underlying hardware.  Accordingly, a struct platform_driver should be
used by driver code to bind to that device.  There are multiple reasons
why drivers should not bind directly to ACPI device objects [1].

Overall, it is better to bind drivers to platform devices than to their
ACPI companions, so convert cmpc_keys_acpi_driver in the platform
x86 classmate-laptop driver from an ACPI driver to a platform one.

After this change, the input device registered by the driver will appear
under the platform device used for driver binding.

While this is not expected to alter functionality, it changes sysfs
layout and so it will be visible to user space.

Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/platform/x86/classmate-laptop.c | 44 ++++++++++++-------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
index dc2b7a48435c..d69dd9c9fde1 100644
--- a/drivers/platform/x86/classmate-laptop.c
+++ b/drivers/platform/x86/classmate-laptop.c
@@ -1092,13 +1092,13 @@ static int cmpc_keys_codes[] = {
 
 static void cmpc_keys_handler(acpi_handle handle, u32 event, void *data)
 {
-	struct acpi_device *dev = data;
+	struct device *dev = data;
 	struct input_dev *inputdev;
 	int code = KEY_MAX;
 
 	if ((event & 0x0F) < ARRAY_SIZE(cmpc_keys_codes))
 		code = cmpc_keys_codes[event & 0x0F];
-	inputdev = dev_get_drvdata(&dev->dev);
+	inputdev = dev_get_drvdata(dev);
 	input_report_key(inputdev, code, !(event & 0x10));
 	input_sync(inputdev);
 }
@@ -1112,27 +1112,28 @@ static void cmpc_keys_idev_init(struct input_dev *inputdev)
 		set_bit(cmpc_keys_codes[i], inputdev->keybit);
 }
 
-static int cmpc_keys_add(struct acpi_device *acpi)
+static int cmpc_keys_probe(struct platform_device *pdev)
 {
 	int error;
 
-	error = cmpc_add_notify_device(&acpi->dev, "cmpc_keys", cmpc_keys_idev_init);
+	error = cmpc_add_notify_device(&pdev->dev, "cmpc_keys", cmpc_keys_idev_init);
 	if (error)
 		return error;
 
-	error = acpi_dev_install_notify_handler(acpi, ACPI_DEVICE_NOTIFY,
-						cmpc_keys_handler, acpi);
+	error = acpi_dev_install_notify_handler(ACPI_COMPANION(&pdev->dev),
+						ACPI_DEVICE_NOTIFY,
+						cmpc_keys_handler, &pdev->dev);
 	if (error)
-		cmpc_remove_notify_device(&acpi->dev);
+		cmpc_remove_notify_device(&pdev->dev);
 
 	return error;
 }
 
-static void cmpc_keys_remove(struct acpi_device *acpi)
+static void cmpc_keys_remove(struct platform_device *pdev)
 {
-	acpi_dev_remove_notify_handler(acpi, ACPI_DEVICE_NOTIFY,
-				       cmpc_keys_handler);
-	cmpc_remove_notify_device(&acpi->dev);
+	acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev),
+				       ACPI_DEVICE_NOTIFY, cmpc_keys_handler);
+	cmpc_remove_notify_device(&pdev->dev);
 }
 
 static const struct acpi_device_id cmpc_keys_device_ids[] = {
@@ -1140,14 +1141,13 @@ static const struct acpi_device_id cmpc_keys_device_ids[] = {
 	{"", 0}
 };
 
-static struct acpi_driver cmpc_keys_acpi_driver = {
-	.name = "cmpc_keys",
-	.class = "cmpc_keys",
-	.ids = cmpc_keys_device_ids,
-	.ops = {
-		.add = cmpc_keys_add,
-		.remove = cmpc_keys_remove,
-	}
+static struct platform_driver cmpc_keys_acpi_driver = {
+	.probe = cmpc_keys_probe,
+	.remove = cmpc_keys_remove,
+	.driver = {
+		.name = "cmpc_keys",
+		.acpi_match_table = cmpc_keys_device_ids,
+	},
 };
 
 
@@ -1159,7 +1159,7 @@ static int cmpc_init(void)
 {
 	int r;
 
-	r = acpi_bus_register_driver(&cmpc_keys_acpi_driver);
+	r = platform_driver_register(&cmpc_keys_acpi_driver);
 	if (r)
 		goto failed_keys;
 
@@ -1191,7 +1191,7 @@ static int cmpc_init(void)
 	platform_driver_unregister(&cmpc_ipml_acpi_driver);
 
 failed_bl:
-	acpi_bus_unregister_driver(&cmpc_keys_acpi_driver);
+	platform_driver_unregister(&cmpc_keys_acpi_driver);
 
 failed_keys:
 	return r;
@@ -1203,7 +1203,7 @@ static void cmpc_exit(void)
 	platform_driver_unregister(&cmpc_accel_acpi_driver);
 	platform_driver_unregister(&cmpc_tablet_acpi_driver);
 	platform_driver_unregister(&cmpc_ipml_acpi_driver);
-	acpi_bus_unregister_driver(&cmpc_keys_acpi_driver);
+	platform_driver_unregister(&cmpc_keys_acpi_driver);
 }
 
 module_init(cmpc_init);
-- 
2.51.0





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

* Re: [PATCH v1 00/10] platform/x86: classmate-laptop: Bind to platform devices instead of ACPI ones
  2026-05-07 19:58 [PATCH v1 00/10] platform/x86: classmate-laptop: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
                   ` (9 preceding siblings ...)
  2026-05-07 20:14 ` [PATCH v1 10/10] platform/x86: classmate-laptop: Convert keys " Rafael J. Wysocki
@ 2026-05-08 12:05 ` Rafael J. Wysocki
  10 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-05-08 12:05 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: LKML, Linux ACPI, Hans de Goede, platform-driver-x86,
	Thadeu Lima de Souza Cascardo

On Thu, May 7, 2026 at 10:15 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> Hi All,
>
> This series is part of a larger effort to switch over all drivers using
> the struct acpi_driver interface to the more common struct platform_driver
> interface and eliminate the former.  The background is explained in
> Documentation/driver-api/acpi/acpi-drivers.rst and in the changelog of
> the patch that introduced the above document:
>
> https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/
>
> The bottom line is that the kernel would be better off without struct
> acpi_driver and so it is better to get rid of it.
>
> This series carries out driver conversion of 5 subdrivers in the platform x86
> classmate-laptop driver.
>
> The first 5 patches in the series are preliminary.
>
> Patch [01/10] updates remove callbacks of 2 subdrivers in classmate-laptop
> to free memory allocated during initialization as appropriate.

After posting this series I realized that it would be more convenient
to switch the _add() callbacks allocating the memory over to
devm_kzalloc() because that would lead to fewer changes overall in
subsequent patches.

So there will be a v2, but I'll first post two more driver conversion series.

Thanks!

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

end of thread, other threads:[~2026-05-08 12:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07 19:58 [PATCH v1 00/10] platform/x86: classmate-laptop: Bind to platform devices instead of ACPI ones Rafael J. Wysocki
2026-05-07 20:00 ` [PATCH v1 01/10] platform/x86: classmate-laptop: Address memory leaks on driver removal Rafael J. Wysocki
2026-05-07 20:01 ` [PATCH v1 02/10] platform/x86: classmate-laptop: Unify probe rollback and remove code Rafael J. Wysocki
2026-05-07 20:03 ` [PATCH v1 03/10] platform/x86: classmate-laptop: Pass struct device pointer to helpers Rafael J. Wysocki
2026-05-07 20:04 ` [PATCH v1 04/10] platform/x86: classmate-laptop: Rename two helper functions Rafael J. Wysocki
2026-05-07 20:07 ` [PATCH v1 05/10] platform/x86: classmate-laptop: Register ACPI notify handlers directly Rafael J. Wysocki
2026-05-07 20:10 ` [PATCH v1 06/10] platform/x86: classmate-laptop: Convert v4 accel driver to a platform one Rafael J. Wysocki
2026-05-07 20:10 ` [PATCH v1 07/10] platform/x86: classmate-laptop: Convert " Rafael J. Wysocki
2026-05-07 20:11 ` [PATCH v1 08/10] platform/x86: classmate-laptop: Convert tablet " Rafael J. Wysocki
2026-05-07 20:12 ` [PATCH v1 09/10] platform/x86: classmate-laptop: Convert ipml " Rafael J. Wysocki
2026-05-07 20:14 ` [PATCH v1 10/10] platform/x86: classmate-laptop: Convert keys " Rafael J. Wysocki
2026-05-08 12:05 ` [PATCH v1 00/10] platform/x86: classmate-laptop: Bind to platform devices instead of ACPI ones Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox