diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2021-04-14 22:54:50 +0300 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2021-05-17 15:54:22 +0300 |
commit | 38934daf7b5c1b35a01748cb7d4272282cc3a890 (patch) | |
tree | 8517f4bcc204974cf60e5c477b414b013b7c7b0c /drivers/iio | |
parent | dffdd75678745e9eccf31ad16e4849b663645e3b (diff) | |
download | linux-38934daf7b5c1b35a01748cb7d4272282cc3a890.tar.xz |
iio: magnetometer: st_magn: Provide default platform data
Provide default platform data for magnetometer in case it supports DRDY.
One case is LSM9DS0 IMU, on which it is the case. Since accelerometer
is using INT1, default magnetometer to INT2.
While at it, update description of the drdy_int_pin field.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210414195454.84183-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/magnetometer/st_magn_core.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index 71faebd07feb..55357f266b8b 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -383,6 +383,11 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = { }, }; +/* Default magn DRDY is available on INT2 pin */ +static const struct st_sensors_platform_data default_magn_pdata = { + .drdy_int_pin = 2, +}; + static int st_magn_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *ch, int *val, int *val2, long mask) @@ -490,6 +495,7 @@ EXPORT_SYMBOL(st_magn_get_settings); int st_magn_common_probe(struct iio_dev *indio_dev) { struct st_sensor_data *mdata = iio_priv(indio_dev); + struct st_sensors_platform_data *pdata = dev_get_platdata(mdata->dev); int err; indio_dev->modes = INDIO_DIRECT_MODE; @@ -510,7 +516,10 @@ int st_magn_common_probe(struct iio_dev *indio_dev) mdata->current_fullscale = &mdata->sensor_settings->fs.fs_avl[0]; mdata->odr = mdata->sensor_settings->odr.odr_avl[0].hz; - err = st_sensors_init_sensor(indio_dev, NULL); + if (!pdata) + pdata = (struct st_sensors_platform_data *)&default_magn_pdata; + + err = st_sensors_init_sensor(indio_dev, pdata); if (err < 0) goto st_magn_power_off; |