]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
iio: st_sensors: match sensors using ACPI handle
authorShrirang Bagul <shrirang.bagul@canonical.com>
Thu, 24 Nov 2016 05:33:43 +0000 (13:33 +0800)
committerJonathan Cameron <jic23@kernel.org>
Sat, 3 Dec 2016 08:56:26 +0000 (08:56 +0000)
Add support to match st sensors using information passed from ACPI DST
tables.

Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/common/st_sensors/st_sensors_i2c.c
include/linux/iio/common/st_sensors_i2c.h

index b43aa36031f88a318469882ae011f159408bacf0..c83df4dbfcd73567440e8d186938644b6bf02c91 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/slab.h>
 #include <linux/iio/iio.h>
 #include <linux/of_device.h>
+#include <linux/acpi.h>
 
 #include <linux/iio/common/st_sensors_i2c.h>
 
@@ -107,6 +108,25 @@ void st_sensors_of_i2c_probe(struct i2c_client *client,
 EXPORT_SYMBOL(st_sensors_of_i2c_probe);
 #endif
 
+#ifdef CONFIG_ACPI
+int st_sensors_match_acpi_device(struct device *dev)
+{
+       const struct acpi_device_id *acpi_id;
+       kernel_ulong_t driver_data = 0;
+
+       if (ACPI_HANDLE(dev)) {
+               acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev);
+               if (!acpi_id) {
+                       dev_err(dev, "No driver data\n");
+                       return -EINVAL;
+               }
+               driver_data = acpi_id->driver_data;
+       }
+       return driver_data;
+}
+EXPORT_SYMBOL(st_sensors_match_acpi_device);
+#endif
+
 MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
 MODULE_DESCRIPTION("STMicroelectronics ST-sensors i2c driver");
 MODULE_LICENSE("GPL v2");
index 1796af09336819849d4cdd5ac422c115b6c9a725..254de3c7dde8aa348139e4783ce9376251213688 100644 (file)
@@ -28,4 +28,13 @@ static inline void st_sensors_of_i2c_probe(struct i2c_client *client,
 }
 #endif
 
+#ifdef CONFIG_ACPI
+int st_sensors_match_acpi_device(struct device *dev);
+#else
+static inline int st_sensors_match_acpi_device(struct device *dev)
+{
+       return -ENODEV;
+}
+#endif
+
 #endif /* ST_SENSORS_I2C_H */