Commit 3dc59262 authored by Shrirang Bagul's avatar Shrirang Bagul Committed by Jonathan Cameron

iio: st_sensors: match sensors using ACPI handle

Add support to match st sensors using information passed from ACPI DST
tables.
Signed-off-by: default avatarShrirang Bagul <shrirang.bagul@canonical.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent af8bc2fb
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/iio/iio.h> #include <linux/iio/iio.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/acpi.h>
#include <linux/iio/common/st_sensors_i2c.h> #include <linux/iio/common/st_sensors_i2c.h>
...@@ -107,6 +108,25 @@ void st_sensors_of_i2c_probe(struct i2c_client *client, ...@@ -107,6 +108,25 @@ void st_sensors_of_i2c_probe(struct i2c_client *client,
EXPORT_SYMBOL(st_sensors_of_i2c_probe); EXPORT_SYMBOL(st_sensors_of_i2c_probe);
#endif #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_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
MODULE_DESCRIPTION("STMicroelectronics ST-sensors i2c driver"); MODULE_DESCRIPTION("STMicroelectronics ST-sensors i2c driver");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
...@@ -28,4 +28,13 @@ static inline void st_sensors_of_i2c_probe(struct i2c_client *client, ...@@ -28,4 +28,13 @@ static inline void st_sensors_of_i2c_probe(struct i2c_client *client,
} }
#endif #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 */ #endif /* ST_SENSORS_I2C_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment