diff options
author | Shrirang Bagul <shrirang.bagul@canonical.com> | 2016-11-24 13:33:43 +0800 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2016-12-03 08:56:26 +0000 |
commit | 3dc59262f76241b342316bbac8b5ffe138995b2d (patch) | |
tree | 8749b4d9b328005e6779ce2bd3497780fe4ef4ab /drivers/iio/common | |
parent | af8bc2fb99d4eea2d026d42db18abc5f3876936a (diff) | |
download | linux-3dc59262f76241b342316bbac8b5ffe138995b2d.tar.bz2 |
iio: st_sensors: match sensors using ACPI handle
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>
Diffstat (limited to 'drivers/iio/common')
-rw-r--r-- | drivers/iio/common/st_sensors/st_sensors_i2c.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/iio/common/st_sensors/st_sensors_i2c.c b/drivers/iio/common/st_sensors/st_sensors_i2c.c index b43aa36031f8..c83df4dbfcd7 100644 --- a/drivers/iio/common/st_sensors/st_sensors_i2c.c +++ b/drivers/iio/common/st_sensors/st_sensors_i2c.c @@ -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"); |