* [PATCH v2 1/3] platform/x86: system76: Drop redundant devm_led_classdev_unregister()
2026-03-18 13:48 [PATCH v2 0/3] platform/x86: system76: Bind to a platform device instead of an ACPI one Rafael J. Wysocki
@ 2026-03-18 13:50 ` Rafael J. Wysocki
2026-03-18 13:53 ` [PATCH v2 2/3] platform/x86: system76: Register ACPI notify handler directly Rafael J. Wysocki
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2026-03-18 13:50 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: Hans de Goede, LKML, Linux ACPI, platform-driver-x86,
Jeremy Soller, System76 Product Development
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Drop two redundant devm_led_classdev_unregister() calls from
system76_remove().
No intentional functional impact.
Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
v1 -> v2: New patch
---
drivers/platform/x86/system76_acpi.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/platform/x86/system76_acpi.c b/drivers/platform/x86/system76_acpi.c
index 3da753b3d00d..d8b64e2c2713 100644
--- a/drivers/platform/x86/system76_acpi.c
+++ b/drivers/platform/x86/system76_acpi.c
@@ -800,9 +800,6 @@ static void system76_remove(struct acpi_device *acpi_dev)
kfree(data->ntmp);
}
- devm_led_classdev_unregister(&acpi_dev->dev, &data->ap_led);
- devm_led_classdev_unregister(&acpi_dev->dev, &data->kb_led);
-
system76_get(data, "FINI");
}
--
2.51.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 2/3] platform/x86: system76: Register ACPI notify handler directly
2026-03-18 13:48 [PATCH v2 0/3] platform/x86: system76: Bind to a platform device instead of an ACPI one Rafael J. Wysocki
2026-03-18 13:50 ` [PATCH v2 1/3] platform/x86: system76: Drop redundant devm_led_classdev_unregister() Rafael J. Wysocki
@ 2026-03-18 13:53 ` Rafael J. Wysocki
2026-03-18 13:54 ` [PATCH v2 3/3] platform/x86: system76: Convert ACPI driver to a platform one Rafael J. Wysocki
2026-03-23 10:46 ` [PATCH v2 0/3] platform/x86: system76: Bind to a platform device instead of an ACPI one Ilpo Järvinen
3 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2026-03-18 13:53 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: Hans de Goede, LKML, Linux ACPI, platform-driver-x86,
Jeremy Soller, System76 Product Development
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
To facilitate subsequent conversion of the driver to a platform one,
make it install an ACPI notify handler directly instead of using
a .notify() callback in struct acpi_driver.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
v1 -> v2:
* Rebase on top of [1/3]
* Use the observation that the notify handler does not access memory
allocated when data->has_open_ec is set and so it can be registered
earlier, which allows the probe rollback path to be simplified
---
drivers/platform/x86/system76_acpi.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/platform/x86/system76_acpi.c b/drivers/platform/x86/system76_acpi.c
index d8b64e2c2713..fc11427c36a5 100644
--- a/drivers/platform/x86/system76_acpi.c
+++ b/drivers/platform/x86/system76_acpi.c
@@ -644,11 +644,10 @@ static void input_key(struct system76_data *data, unsigned int code)
}
// Handle ACPI notification
-static void system76_notify(struct acpi_device *acpi_dev, u32 event)
+static void system76_notify(acpi_handle handle, u32 event, void *context)
{
- struct system76_data *data;
+ struct system76_data *data = context;
- data = acpi_driver_data(acpi_dev);
switch (event) {
case 0x80:
kb_led_hotkey_hardware(data);
@@ -757,7 +756,12 @@ static int system76_add(struct acpi_device *acpi_dev)
err = input_register_device(data->input);
if (err)
- goto error;
+ return err;
+
+ err = acpi_dev_install_notify_handler(acpi_dev, ACPI_DEVICE_NOTIFY,
+ system76_notify, data);
+ if (err)
+ return err;
if (data->has_open_ec) {
err = system76_get_object(data, "NFAN", &data->nfan);
@@ -784,6 +788,7 @@ static int system76_add(struct acpi_device *acpi_dev)
kfree(data->ntmp);
kfree(data->nfan);
}
+ acpi_dev_remove_notify_handler(acpi_dev, ACPI_DEVICE_NOTIFY, system76_notify);
return err;
}
@@ -800,6 +805,8 @@ static void system76_remove(struct acpi_device *acpi_dev)
kfree(data->ntmp);
}
+ acpi_dev_remove_notify_handler(acpi_dev, ACPI_DEVICE_NOTIFY, system76_notify);
+
system76_get(data, "FINI");
}
@@ -810,7 +817,6 @@ static struct acpi_driver system76_driver = {
.ops = {
.add = system76_add,
.remove = system76_remove,
- .notify = system76_notify,
},
};
module_acpi_driver(system76_driver);
--
2.51.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 3/3] platform/x86: system76: Convert ACPI driver to a platform one
2026-03-18 13:48 [PATCH v2 0/3] platform/x86: system76: Bind to a platform device instead of an ACPI one Rafael J. Wysocki
2026-03-18 13:50 ` [PATCH v2 1/3] platform/x86: system76: Drop redundant devm_led_classdev_unregister() Rafael J. Wysocki
2026-03-18 13:53 ` [PATCH v2 2/3] platform/x86: system76: Register ACPI notify handler directly Rafael J. Wysocki
@ 2026-03-18 13:54 ` Rafael J. Wysocki
2026-03-23 10:46 ` [PATCH v2 0/3] platform/x86: system76: Bind to a platform device instead of an ACPI one Ilpo Järvinen
3 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2026-03-18 13:54 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: Hans de Goede, LKML, Linux ACPI, platform-driver-x86,
Jeremy Soller, System76 Product Development
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 the System76 ACPI driver to a platform one.
After this change, the subordinate hwmon, input and LED class devices
will be registered under the platform device used for driver binding
instead of its ACPI companion.
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>
---
v1 -> v2: Rebase on top of the new [1/3] and the updated [2/3].
---
drivers/platform/x86/system76_acpi.c | 48 +++++++++++++++-------------
1 file changed, 25 insertions(+), 23 deletions(-)
diff --git a/drivers/platform/x86/system76_acpi.c b/drivers/platform/x86/system76_acpi.c
index fc11427c36a5..693cbb461382 100644
--- a/drivers/platform/x86/system76_acpi.c
+++ b/drivers/platform/x86/system76_acpi.c
@@ -18,6 +18,7 @@
#include <linux/leds.h>
#include <linux/module.h>
#include <linux/pci_ids.h>
+#include <linux/platform_device.h>
#include <linux/power_supply.h>
#include <linux/sysfs.h>
#include <linux/types.h>
@@ -670,16 +671,19 @@ static void system76_notify(acpi_handle handle, u32 event, void *context)
}
}
-// Add a System76 ACPI device
-static int system76_add(struct acpi_device *acpi_dev)
+// Probe a System76 platform device
+static int system76_probe(struct platform_device *pdev)
{
+ struct acpi_device *acpi_dev = ACPI_COMPANION(&pdev->dev);
struct system76_data *data;
int err;
- data = devm_kzalloc(&acpi_dev->dev, sizeof(*data), GFP_KERNEL);
+ data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
- acpi_dev->driver_data = data;
+
+ platform_set_drvdata(pdev, data);
+
data->acpi_dev = acpi_dev;
// Some models do not run open EC firmware. Check for an ACPI method
@@ -695,7 +699,7 @@ static int system76_add(struct acpi_device *acpi_dev)
data->ap_led.brightness_set_blocking = ap_led_set;
data->ap_led.max_brightness = 1;
data->ap_led.default_trigger = "rfkill-none";
- err = devm_led_classdev_register(&acpi_dev->dev, &data->ap_led);
+ err = devm_led_classdev_register(&pdev->dev, &data->ap_led);
if (err)
return err;
@@ -739,19 +743,19 @@ static int system76_add(struct acpi_device *acpi_dev)
}
if (data->kbled_type != KBLED_NONE) {
- err = devm_led_classdev_register(&acpi_dev->dev, &data->kb_led);
+ err = devm_led_classdev_register(&pdev->dev, &data->kb_led);
if (err)
return err;
}
- data->input = devm_input_allocate_device(&acpi_dev->dev);
+ data->input = devm_input_allocate_device(&pdev->dev);
if (!data->input)
return -ENOMEM;
data->input->name = "System76 ACPI Hotkeys";
data->input->phys = "system76_acpi/input0";
data->input->id.bustype = BUS_HOST;
- data->input->dev.parent = &acpi_dev->dev;
+ data->input->dev.parent = &pdev->dev;
input_set_capability(data->input, EV_KEY, KEY_SCREENLOCK);
err = input_register_device(data->input);
@@ -772,7 +776,7 @@ static int system76_add(struct acpi_device *acpi_dev)
if (err)
goto error;
- data->therm = devm_hwmon_device_register_with_info(&acpi_dev->dev,
+ data->therm = devm_hwmon_device_register_with_info(&pdev->dev,
"system76_acpi", data, &thermal_chip_info, NULL);
err = PTR_ERR_OR_ZERO(data->therm);
if (err)
@@ -792,12 +796,10 @@ static int system76_add(struct acpi_device *acpi_dev)
return err;
}
-// Remove a System76 ACPI device
-static void system76_remove(struct acpi_device *acpi_dev)
+// Remove a System76 platform device
+static void system76_remove(struct platform_device *pdev)
{
- struct system76_data *data;
-
- data = acpi_driver_data(acpi_dev);
+ struct system76_data *data = platform_get_drvdata(pdev);
if (data->has_open_ec) {
system76_battery_exit();
@@ -805,21 +807,21 @@ static void system76_remove(struct acpi_device *acpi_dev)
kfree(data->ntmp);
}
- acpi_dev_remove_notify_handler(acpi_dev, ACPI_DEVICE_NOTIFY, system76_notify);
+ acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev),
+ ACPI_DEVICE_NOTIFY, system76_notify);
system76_get(data, "FINI");
}
-static struct acpi_driver system76_driver = {
- .name = "System76 ACPI Driver",
- .class = "hotkey",
- .ids = device_ids,
- .ops = {
- .add = system76_add,
- .remove = system76_remove,
+static struct platform_driver system76_driver = {
+ .probe = system76_probe,
+ .remove = system76_remove,
+ .driver = {
+ .name = "System76 ACPI Driver",
+ .acpi_match_table = device_ids,
},
};
-module_acpi_driver(system76_driver);
+module_platform_driver(system76_driver);
MODULE_DESCRIPTION("System76 ACPI Driver");
MODULE_AUTHOR("Jeremy Soller <jeremy@system76.com>");
--
2.51.0
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2 0/3] platform/x86: system76: Bind to a platform device instead of an ACPI one
2026-03-18 13:48 [PATCH v2 0/3] platform/x86: system76: Bind to a platform device instead of an ACPI one Rafael J. Wysocki
` (2 preceding siblings ...)
2026-03-18 13:54 ` [PATCH v2 3/3] platform/x86: system76: Convert ACPI driver to a platform one Rafael J. Wysocki
@ 2026-03-23 10:46 ` Ilpo Järvinen
3 siblings, 0 replies; 5+ messages in thread
From: Ilpo Järvinen @ 2026-03-23 10:46 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Hans de Goede, LKML, Linux ACPI, platform-driver-x86,
Jeremy Soller, System76 Product Development
On Wed, 18 Mar 2026 14:48:57 +0100, Rafael J. Wysocki wrote:
> This is an update of
>
> https://lore.kernel.org/linux-acpi/2841136.mvXUDI8C0e@rafael.j.wysocki/
>
> adding one preparatory patch and updating the other patches to implement
> the probe rollback code path slightly differently.
>
> [...]
Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.
The list of commits applied:
[1/3] platform/x86: system76: Drop redundant devm_led_classdev_unregister()
commit: 5539165cae8e133275f0eed4cfa131cda974a1a3
[2/3] platform/x86: system76: Register ACPI notify handler directly
commit: 89729c9c6c158259b8de14c57b5aac6a25dfac3d
[3/3] platform/x86: system76: Convert ACPI driver to a platform one
commit: 80b8f68b94abcf6f2f8c71a685b2a70fd7c502b0
--
i.
^ permalink raw reply [flat|nested] 5+ messages in thread