platform/x86: panasonic-laptop: Convert ACPI driver to a platform one

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 Panasonic laptop ACPI driver to a platform
one.

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

To maintain backwards compatibility with possibly existing user space,
the sysfs attributes created by the driver under the ACPI device object
used by it are not relocated.  Accordingly, the driver will continue to
use the driver_data pointer in struct acpi_device which needs to be
cleared on driver removal.

Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/8664183.T7Z3S40VBb@rafael.j.wysocki
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
Rafael J. Wysocki 2026-03-20 11:35:54 +01:00 committed by Ilpo Järvinen
parent 0381b6a657
commit de6837243a
No known key found for this signature in database
GPG Key ID: 59AC4F6153E5CE31

View File

@ -183,8 +183,8 @@ enum SINF_BITS { SINF_NUM_BATTERIES = 0,
}; };
/* R1 handles SINF_AC_CUR_BRIGHT as SINF_CUR_BRIGHT, doesn't know AC state */ /* R1 handles SINF_AC_CUR_BRIGHT as SINF_CUR_BRIGHT, doesn't know AC state */
static int acpi_pcc_hotkey_add(struct acpi_device *device); static int acpi_pcc_hotkey_probe(struct platform_device *pdev);
static void acpi_pcc_hotkey_remove(struct acpi_device *device); static void acpi_pcc_hotkey_remove(struct platform_device *pdev);
static void acpi_pcc_hotkey_notify(acpi_handle handle, u32 event, void *data); static void acpi_pcc_hotkey_notify(acpi_handle handle, u32 event, void *data);
static const struct acpi_device_id pcc_device_ids[] = { static const struct acpi_device_id pcc_device_ids[] = {
@ -201,15 +201,14 @@ static int acpi_pcc_hotkey_resume(struct device *dev);
#endif #endif
static SIMPLE_DEV_PM_OPS(acpi_pcc_hotkey_pm, NULL, acpi_pcc_hotkey_resume); static SIMPLE_DEV_PM_OPS(acpi_pcc_hotkey_pm, NULL, acpi_pcc_hotkey_resume);
static struct acpi_driver acpi_pcc_driver = { static struct platform_driver acpi_pcc_driver = {
.name = ACPI_PCC_DRIVER_NAME, .probe = acpi_pcc_hotkey_probe,
.class = ACPI_PCC_CLASS, .remove = acpi_pcc_hotkey_remove,
.ids = pcc_device_ids, .driver = {
.ops = { .name = ACPI_PCC_DRIVER_NAME,
.add = acpi_pcc_hotkey_add, .acpi_match_table = pcc_device_ids,
.remove = acpi_pcc_hotkey_remove, .pm = &acpi_pcc_hotkey_pm,
}, },
.drv.pm = &acpi_pcc_hotkey_pm,
}; };
static const struct key_entry panasonic_keymap[] = { static const struct key_entry panasonic_keymap[] = {
@ -964,7 +963,7 @@ static int acpi_pcc_init_input(struct pcc_acpi *pcc)
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int acpi_pcc_hotkey_resume(struct device *dev) static int acpi_pcc_hotkey_resume(struct device *dev)
{ {
struct pcc_acpi *pcc = acpi_driver_data(to_acpi_device(dev)); struct pcc_acpi *pcc = acpi_driver_data(ACPI_COMPANION(dev));
if (pcc->num_sifr > SINF_MUTE) if (pcc->num_sifr > SINF_MUTE)
acpi_pcc_write_sset(pcc, SINF_MUTE, pcc->mute); acpi_pcc_write_sset(pcc, SINF_MUTE, pcc->mute);
@ -980,8 +979,9 @@ static int acpi_pcc_hotkey_resume(struct device *dev)
} }
#endif #endif
static int acpi_pcc_hotkey_add(struct acpi_device *device) static int acpi_pcc_hotkey_probe(struct platform_device *pdev)
{ {
struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
struct backlight_properties props; struct backlight_properties props;
struct pcc_acpi *pcc; struct pcc_acpi *pcc;
int num_sifr, result; int num_sifr, result;
@ -1107,6 +1107,7 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
out_input: out_input:
input_unregister_device(pcc->input_dev); input_unregister_device(pcc->input_dev);
out_sinf: out_sinf:
device->driver_data = NULL;
kfree(pcc->sinf); kfree(pcc->sinf);
out_hotkey: out_hotkey:
kfree(pcc); kfree(pcc);
@ -1114,8 +1115,9 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
return result; return result;
} }
static void acpi_pcc_hotkey_remove(struct acpi_device *device) static void acpi_pcc_hotkey_remove(struct platform_device *pdev)
{ {
struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
struct pcc_acpi *pcc = acpi_driver_data(device); struct pcc_acpi *pcc = acpi_driver_data(device);
i8042_remove_filter(panasonic_i8042_filter); i8042_remove_filter(panasonic_i8042_filter);
@ -1135,8 +1137,10 @@ static void acpi_pcc_hotkey_remove(struct acpi_device *device)
input_unregister_device(pcc->input_dev); input_unregister_device(pcc->input_dev);
device->driver_data = NULL;
kfree(pcc->sinf); kfree(pcc->sinf);
kfree(pcc); kfree(pcc);
} }
module_acpi_driver(acpi_pcc_driver); module_platform_driver(acpi_pcc_driver);