Skip to content

Commit 3dc5926

Browse files
daedalus81jic23
authored andcommitted
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>
1 parent af8bc2f commit 3dc5926

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

‎drivers/iio/common/st_sensors/st_sensors_i2c.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/slab.h>
1414
#include <linux/iio/iio.h>
1515
#include <linux/of_device.h>
16+
#include <linux/acpi.h>
1617

1718
#include <linux/iio/common/st_sensors_i2c.h>
1819

@@ -107,6 +108,25 @@ void st_sensors_of_i2c_probe(struct i2c_client *client,
107108
EXPORT_SYMBOL(st_sensors_of_i2c_probe);
108109
#endif
109110

111+
#ifdef CONFIG_ACPI
112+
int st_sensors_match_acpi_device(struct device *dev)
113+
{
114+
const struct acpi_device_id *acpi_id;
115+
kernel_ulong_t driver_data = 0;
116+
117+
if (ACPI_HANDLE(dev)) {
118+
acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev);
119+
if (!acpi_id) {
120+
dev_err(dev, "No driver data\n");
121+
return -EINVAL;
122+
}
123+
driver_data = acpi_id->driver_data;
124+
}
125+
return driver_data;
126+
}
127+
EXPORT_SYMBOL(st_sensors_match_acpi_device);
128+
#endif
129+
110130
MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
111131
MODULE_DESCRIPTION("STMicroelectronics ST-sensors i2c driver");
112132
MODULE_LICENSE("GPL v2");

‎include/linux/iio/common/st_sensors_i2c.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,13 @@ static inline void st_sensors_of_i2c_probe(struct i2c_client *client,
2828
}
2929
#endif
3030

31+
#ifdef CONFIG_ACPI
32+
int st_sensors_match_acpi_device(struct device *dev);
33+
#else
34+
static inline int st_sensors_match_acpi_device(struct device *dev)
35+
{
36+
return -ENODEV;
37+
}
38+
#endif
39+
3140
#endif /* ST_SENSORS_I2C_H */

0 commit comments

Comments
 (0)