Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Rafael J. Wysocki and committed by
Ilpo Järvinen
de683724 0381b6a6

+19 -15
+19 -15
drivers/platform/x86/panasonic-laptop.c
··· 183 183 }; 184 184 /* R1 handles SINF_AC_CUR_BRIGHT as SINF_CUR_BRIGHT, doesn't know AC state */ 185 185 186 - static int acpi_pcc_hotkey_add(struct acpi_device *device); 187 - static void acpi_pcc_hotkey_remove(struct acpi_device *device); 186 + static int acpi_pcc_hotkey_probe(struct platform_device *pdev); 187 + static void acpi_pcc_hotkey_remove(struct platform_device *pdev); 188 188 static void acpi_pcc_hotkey_notify(acpi_handle handle, u32 event, void *data); 189 189 190 190 static const struct acpi_device_id pcc_device_ids[] = { ··· 201 201 #endif 202 202 static SIMPLE_DEV_PM_OPS(acpi_pcc_hotkey_pm, NULL, acpi_pcc_hotkey_resume); 203 203 204 - static struct acpi_driver acpi_pcc_driver = { 205 - .name = ACPI_PCC_DRIVER_NAME, 206 - .class = ACPI_PCC_CLASS, 207 - .ids = pcc_device_ids, 208 - .ops = { 209 - .add = acpi_pcc_hotkey_add, 210 - .remove = acpi_pcc_hotkey_remove, 211 - }, 212 - .drv.pm = &acpi_pcc_hotkey_pm, 204 + static struct platform_driver acpi_pcc_driver = { 205 + .probe = acpi_pcc_hotkey_probe, 206 + .remove = acpi_pcc_hotkey_remove, 207 + .driver = { 208 + .name = ACPI_PCC_DRIVER_NAME, 209 + .acpi_match_table = pcc_device_ids, 210 + .pm = &acpi_pcc_hotkey_pm, 211 + }, 213 212 }; 214 213 215 214 static const struct key_entry panasonic_keymap[] = { ··· 963 964 #ifdef CONFIG_PM_SLEEP 964 965 static int acpi_pcc_hotkey_resume(struct device *dev) 965 966 { 966 - struct pcc_acpi *pcc = acpi_driver_data(to_acpi_device(dev)); 967 + struct pcc_acpi *pcc = acpi_driver_data(ACPI_COMPANION(dev)); 967 968 968 969 if (pcc->num_sifr > SINF_MUTE) 969 970 acpi_pcc_write_sset(pcc, SINF_MUTE, pcc->mute); ··· 979 980 } 980 981 #endif 981 982 982 - static int acpi_pcc_hotkey_add(struct acpi_device *device) 983 + static int acpi_pcc_hotkey_probe(struct platform_device *pdev) 983 984 { 985 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 984 986 struct backlight_properties props; 985 987 struct pcc_acpi *pcc; 986 988 int num_sifr, result; ··· 1107 1107 out_input: 1108 1108 input_unregister_device(pcc->input_dev); 1109 1109 out_sinf: 1110 + device->driver_data = NULL; 1110 1111 kfree(pcc->sinf); 1111 1112 out_hotkey: 1112 1113 kfree(pcc); ··· 1115 1114 return result; 1116 1115 } 1117 1116 1118 - static void acpi_pcc_hotkey_remove(struct acpi_device *device) 1117 + static void acpi_pcc_hotkey_remove(struct platform_device *pdev) 1119 1118 { 1119 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 1120 1120 struct pcc_acpi *pcc = acpi_driver_data(device); 1121 1121 1122 1122 i8042_remove_filter(panasonic_i8042_filter); ··· 1137 1135 1138 1136 input_unregister_device(pcc->input_dev); 1139 1137 1138 + device->driver_data = NULL; 1139 + 1140 1140 kfree(pcc->sinf); 1141 1141 kfree(pcc); 1142 1142 } 1143 1143 1144 - module_acpi_driver(acpi_pcc_driver); 1144 + module_platform_driver(acpi_pcc_driver);