summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2026-03-04 19:33:14 +0100
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2026-03-14 12:10:21 +0000
commitd4243cb08a272b6cc0f7c8293f9c7e128b51795c (patch)
treeb7125a8f3b7997468f2f5671a57a351b0ff9f2b4
parent1653e0897f1526acfb6d041d4920ebc6a3c3b028 (diff)
iio: light: acpi-als: 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 ACPI ambient light sensor driver to a platform one. After this change, the subordinate IIO device 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> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r--drivers/iio/light/acpi-als.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/iio/light/acpi-als.c b/drivers/iio/light/acpi-als.c
index 2fe6b493c012..ab229318dce9 100644
--- a/drivers/iio/light/acpi-als.c
+++ b/drivers/iio/light/acpi-als.c
@@ -18,6 +18,7 @@
#include <linux/err.h>
#include <linux/irq.h>
#include <linux/mutex.h>
+#include <linux/platform_device.h>
#include <linux/iio/iio.h>
#include <linux/iio/buffer.h>
@@ -175,9 +176,10 @@ out:
return IRQ_HANDLED;
}
-static int acpi_als_add(struct acpi_device *device)
+static int acpi_als_probe(struct platform_device *pdev)
{
- struct device *dev = &device->dev;
+ struct device *dev = &pdev->dev;
+ struct acpi_device *device = ACPI_COMPANION(dev);
struct iio_dev *indio_dev;
struct acpi_als *als;
int ret;
@@ -188,7 +190,6 @@ static int acpi_als_add(struct acpi_device *device)
als = iio_priv(indio_dev);
- device->driver_data = indio_dev;
als->device = device;
mutex_init(&als->lock);
@@ -226,9 +227,10 @@ static int acpi_als_add(struct acpi_device *device)
acpi_als_notify, indio_dev);
}
-static void acpi_als_remove(struct acpi_device *device)
+static void acpi_als_remove(struct platform_device *pdev)
{
- acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, acpi_als_notify);
+ acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev),
+ ACPI_DEVICE_NOTIFY, acpi_als_notify);
}
static const struct acpi_device_id acpi_als_device_ids[] = {
@@ -238,17 +240,15 @@ static const struct acpi_device_id acpi_als_device_ids[] = {
MODULE_DEVICE_TABLE(acpi, acpi_als_device_ids);
-static struct acpi_driver acpi_als_driver = {
- .name = "acpi_als",
- .class = ACPI_ALS_CLASS,
- .ids = acpi_als_device_ids,
- .ops = {
- .add = acpi_als_add,
- .remove = acpi_als_remove,
+static struct platform_driver acpi_als_driver = {
+ .probe = acpi_als_probe,
+ .remove = acpi_als_remove,
+ .driver = {
+ .name = "acpi_als",
+ .acpi_match_table = acpi_als_device_ids,
},
};
-
-module_acpi_driver(acpi_als_driver);
+module_platform_driver(acpi_als_driver);
MODULE_AUTHOR("Zhang Rui <rui.zhang@intel.com>");
MODULE_AUTHOR("Martin Liska <marxin.liska@gmail.com>");