Unverified Commit 8a44bd3f authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Ilpo Järvinen
Browse files

platform/x86: intel/smartconnect: 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 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.

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

 [1]
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/24282289.6Emhk5qWAg@rafael.j.wysocki


Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
parent 163a68a3
Loading
Loading
Loading
Loading
+12 −11
Original line number Diff line number Diff line
@@ -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 = {
static struct platform_driver smartconnect_driver = {
	.probe = smartconnect_acpi_probe,
	.driver = {
		.name = "intel_smart_connect",
	.class = "intel_smart_connect",
	.ids = smartconnect_ids,
	.ops = {
		.add = smartconnect_acpi_init,
		.acpi_match_table = smartconnect_ids,
	},
};

module_acpi_driver(smartconnect_driver);
module_platform_driver(smartconnect_driver);