aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/magnetometer/st_magn_i2c.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/iio/magnetometer/st_magn_i2c.c')
-rw-r--r--drivers/iio/magnetometer/st_magn_i2c.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c
index 892e0feeb5c1..689250058442 100644
--- a/drivers/iio/magnetometer/st_magn_i2c.c
+++ b/drivers/iio/magnetometer/st_magn_i2c.c
@@ -18,6 +18,27 @@
18#include <linux/iio/common/st_sensors_i2c.h> 18#include <linux/iio/common/st_sensors_i2c.h>
19#include "st_magn.h" 19#include "st_magn.h"
20 20
21#ifdef CONFIG_OF
22static const struct of_device_id st_magn_of_match[] = {
23 {
24 .compatible = "st,lsm303dlhc-magn",
25 .data = LSM303DLHC_MAGN_DEV_NAME,
26 },
27 {
28 .compatible = "st,lsm303dlm-magn",
29 .data = LSM303DLM_MAGN_DEV_NAME,
30 },
31 {
32 .compatible = "st,lis3mdl-magn",
33 .data = LIS3MDL_MAGN_DEV_NAME,
34 },
35 {},
36};
37MODULE_DEVICE_TABLE(of, st_magn_of_match);
38#else
39#define st_magn_of_match NULL
40#endif
41
21static int st_magn_i2c_probe(struct i2c_client *client, 42static int st_magn_i2c_probe(struct i2c_client *client,
22 const struct i2c_device_id *id) 43 const struct i2c_device_id *id)
23{ 44{
@@ -31,6 +52,7 @@ static int st_magn_i2c_probe(struct i2c_client *client,
31 52
32 mdata = iio_priv(indio_dev); 53 mdata = iio_priv(indio_dev);
33 mdata->dev = &client->dev; 54 mdata->dev = &client->dev;
55 st_sensors_of_i2c_probe(client, st_magn_of_match);
34 56
35 st_sensors_i2c_configure(indio_dev, client, mdata); 57 st_sensors_i2c_configure(indio_dev, client, mdata);
36 58
@@ -61,6 +83,7 @@ static struct i2c_driver st_magn_driver = {
61 .driver = { 83 .driver = {
62 .owner = THIS_MODULE, 84 .owner = THIS_MODULE,
63 .name = "st-magn-i2c", 85 .name = "st-magn-i2c",
86 .of_match_table = of_match_ptr(st_magn_of_match),
64 }, 87 },
65 .probe = st_magn_i2c_probe, 88 .probe = st_magn_i2c_probe,
66 .remove = st_magn_i2c_remove, 89 .remove = st_magn_i2c_remove,