platform/x86: intel: Bind to platform devices instead of ACPI ones
Subsystems (2)
Rafael J. Wysocki
maintainercover platform/x86: intel: Bind to platform devices instead of ACPI ones
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/[email protected]/
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 two platform x86 Intel drivers, intel-rst (patch [1/2] and intel-smartconnect (patch [2/2]).
Thanks!
Rafael J. Wysocki
maintainerPATCH 1/2 platform/x86: intel/rst: Convert ACPI driver to a platform one
From: "Rafael J. Wysocki" <[email protected]>
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 Intel Rapid Start Technology (rst) 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.
--- drivers/platform/x86/intel/rst.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/platform/x86/intel/rst.c +13 -10
@@ -5,6 +5,7 @@#include <linux/acpi.h> #include <linux/module.h> +#include <linux/platform_device.h> #include <linux/slab.h> MODULE_DESCRIPTION ("Intel Rapid Start Technology Driver" );
@@ -99,8 +100,9 @@ static struct device_attribute irst_timeout_attr = { .store = irst_store_wakeup_time }; -static int irst_add (struct acpi_device *acpi) +static int irst_probe (struct platform_device *pdev) { +struct acpi_device *acpi =ACPI_COMPANION (&pdev->dev);int error; error =device_create_file (&acpi->dev, &irst_timeout_attr);
@@ -114,8 +116,10 @@ static int irst_add(struct acpi_device *acpi)return error; } -static void irst_remove (struct acpi_device *acpi) +static void irst_remove (struct platform_device *pdev) { +struct acpi_device *acpi =ACPI_COMPANION (&pdev->dev); +device_remove_file (&acpi->dev, &irst_wakeup_attr);device_remove_file (&acpi->dev, &irst_timeout_attr); }
@@ -125,16 +129,15 @@ static const struct acpi_device_id irst_ids[] = { {"", 0} }; -static struct acpi_driver irst_driver = { - .name ="intel_rapid_start" , - .class ="intel_rapid_start" , - .ids = irst_ids, - .ops = { - .add = irst_add, - .remove = irst_remove, +static struct platform_driver irst_driver = { + .probe = irst_probe, + .remove = irst_remove, + .driver = { + .name ="intel_rapid_start" , + .acpi_match_table = irst_ids, }, }; -module_acpi_driver (irst_driver); +module_platform_driver (irst_driver);MODULE_DEVICE_TABLE (acpi, irst_ids);
Signature · 1 line
2.51.0
Rafael J. Wysocki
maintainerPATCH 2/2 platform/x86: intel/smartconnect: Convert ACPI driver to a platform one
In reply to Rafael J. WysockiFrom: "Rafael J. Wysocki" <[email protected]>
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 Intel Smart Connect disabling 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.
--- drivers/platform/x86/intel/smartconnect.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
drivers/platform/x86/intel/smartconnect.c +12 -11
@@ -5,22 +5,24 @@#include <linux/acpi.h> #include <linux/module.h> +#include <linux/platform_device.h> MODULE_DESCRIPTION ("Intel Smart Connect disabling driver" );MODULE_LICENSE ("GPL" ); -static int smartconnect_acpi_init (struct acpi_device *acpi) +static int smartconnect_acpi_probe (struct platform_device *pdev) { +acpi_handle handle =ACPI_HANDLE (&pdev->dev);unsigned long long value;acpi_status status; - status =acpi_evaluate_integer (acpi->handle,"GAOS" ,NULL , &value); + status =acpi_evaluate_integer (handle,"GAOS" ,NULL , &value);if (ACPI_FAILURE (status))return -EINVAL ;if (value &0x1 ) { -dev_info (&acpi->dev,"Disabling Intel Smart Connect\n" ); - status =acpi_execute_simple_method (acpi->handle,"SAOS" ,0 ); +dev_info (&pdev->dev,"Disabling Intel Smart Connect\n" ); + status =acpi_execute_simple_method (handle,"SAOS" ,0 ); }return 0 ;
@@ -32,13 +34,12 @@ static const struct acpi_device_id smartconnect_ids[] = { };MODULE_DEVICE_TABLE (acpi, smartconnect_ids); -static struct acpi_driver smartconnect_driver = { - .name ="intel_smart_connect" , - .class ="intel_smart_connect" , - .ids = smartconnect_ids, - .ops = { - .add = smartconnect_acpi_init, +static struct platform_driver smartconnect_driver = { + .probe = smartconnect_acpi_probe, + .driver = { + .name ="intel_smart_connect" , + .acpi_match_table = smartconnect_ids, }, }; -module_acpi_driver (smartconnect_driver); +module_platform_driver (smartconnect_driver);
Signature · 1 line
2.51.0
Ilpo Järvinen
maintainerQuoted 9 lines · Rafael J. Wysocki
This series is part of a larger effort to switch over all drivers using the struct
acpi_driverinterface to the more common structplatform_driverinterface and eliminate the former. The background is explained inDocumentation/driver-api/acpi/acpi-drivers.rstand in the changelog of the patch that introduced the above document:https://lore.kernel.org/all/[email protected]/
[...]
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/2] platform/x86: intel/rst: Convert ACPI driver to a platform one
commit: 163a68a31f743c5a820f348322b9162bc89c720a
[2/2] platform/x86: intel/smartconnect: Convert ACPI driver to a platform one
commit: 8a44bd3ffdb269c028236d9165ce06a46c091373--
i.