Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Shrirang Bagul and committed by
Jonathan Cameron
3dc59262 af8bc2fb

+29
+20
drivers/iio/common/st_sensors/st_sensors_i2c.c
··· 13 13 #include <linux/slab.h> 14 14 #include <linux/iio/iio.h> 15 15 #include <linux/of_device.h> 16 + #include <linux/acpi.h> 16 17 17 18 #include <linux/iio/common/st_sensors_i2c.h> 18 19 ··· 106 105 client->name[sizeof(client->name) - 1] = '\0'; 107 106 } 108 107 EXPORT_SYMBOL(st_sensors_of_i2c_probe); 108 + #endif 109 + 110 + #ifdef CONFIG_ACPI 111 + int st_sensors_match_acpi_device(struct device *dev) 112 + { 113 + const struct acpi_device_id *acpi_id; 114 + kernel_ulong_t driver_data = 0; 115 + 116 + if (ACPI_HANDLE(dev)) { 117 + acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev); 118 + if (!acpi_id) { 119 + dev_err(dev, "No driver data\n"); 120 + return -EINVAL; 121 + } 122 + driver_data = acpi_id->driver_data; 123 + } 124 + return driver_data; 125 + } 126 + EXPORT_SYMBOL(st_sensors_match_acpi_device); 109 127 #endif 110 128 111 129 MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
+9
include/linux/iio/common/st_sensors_i2c.h
··· 28 28 } 29 29 #endif 30 30 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 + 31 40 #endif /* ST_SENSORS_I2C_H */