summaryrefslogtreecommitdiffstats
path: root/drivers/iio/pressure/st_pressure_i2c.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/iio/pressure/st_pressure_i2c.c')
-rw-r--r--drivers/iio/pressure/st_pressure_i2c.c51
1 files changed, 38 insertions, 13 deletions
diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c
index ed18701c68c9..17417a4d5a5f 100644
--- a/drivers/iio/pressure/st_pressure_i2c.c
+++ b/drivers/iio/pressure/st_pressure_i2c.c
@@ -11,6 +11,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/acpi.h>
#include <linux/i2c.h>
#include <linux/iio/iio.h>
@@ -43,25 +44,56 @@ MODULE_DEVICE_TABLE(of, st_press_of_match);
#define st_press_of_match NULL
#endif
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id st_press_acpi_match[] = {
+ {"SNO9210", LPS22HB},
+ { },
+};
+MODULE_DEVICE_TABLE(acpi, st_press_acpi_match);
+#else
+#define st_press_acpi_match NULL
+#endif
+
+static const struct i2c_device_id st_press_id_table[] = {
+ { LPS001WP_PRESS_DEV_NAME, LPS001WP },
+ { LPS25H_PRESS_DEV_NAME, LPS25H },
+ { LPS331AP_PRESS_DEV_NAME, LPS331AP },
+ { LPS22HB_PRESS_DEV_NAME, LPS22HB },
+ {},
+};
+MODULE_DEVICE_TABLE(i2c, st_press_id_table);
+
static int st_press_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct iio_dev *indio_dev;
struct st_sensor_data *press_data;
- int err;
+ int ret;
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*press_data));
if (!indio_dev)
return -ENOMEM;
press_data = iio_priv(indio_dev);
- st_sensors_of_i2c_probe(client, st_press_of_match);
+
+ if (client->dev.of_node) {
+ st_sensors_of_i2c_probe(client, st_press_of_match);
+ } else if (ACPI_HANDLE(&client->dev)) {
+ ret = st_sensors_match_acpi_device(&client->dev);
+ if ((ret < 0) || (ret >= ST_PRESS_MAX))
+ return -ENODEV;
+
+ strncpy(client->name, st_press_id_table[ret].name,
+ sizeof(client->name));
+ client->name[sizeof(client->name) - 1] = '\0';
+ } else if (!id)
+ return -ENODEV;
st_sensors_i2c_configure(indio_dev, client, press_data);
- err = st_press_common_probe(indio_dev);
- if (err < 0)
- return err;
+ ret = st_press_common_probe(indio_dev);
+ if (ret < 0)
+ return ret;
return 0;
}
@@ -73,18 +105,11 @@ static int st_press_i2c_remove(struct i2c_client *client)
return 0;
}
-static const struct i2c_device_id st_press_id_table[] = {
- { LPS001WP_PRESS_DEV_NAME },
- { LPS25H_PRESS_DEV_NAME },
- { LPS331AP_PRESS_DEV_NAME },
- {},
-};
-MODULE_DEVICE_TABLE(i2c, st_press_id_table);
-
static struct i2c_driver st_press_driver = {
.driver = {
.name = "st-press-i2c",
.of_match_table = of_match_ptr(st_press_of_match),
+ .acpi_match_table = ACPI_PTR(st_press_acpi_match),
},
.probe = st_press_i2c_probe,
.remove = st_press_i2c_remove,