Skip to contentSkip to conversation

iio: st_sensors: rely on odr mask to know if odr can be set

PATCH Applied [email protected] 2 participants 2 messages Apr 11, 2020 – Apr 12, 2020 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: st_sensors: rely on odr mask to know if odr can be set

Indeed, relying on addr being not 0 cannot work because some device have their register to set odr at address 0. As a matter of fact, if the odr can be set, then there is a mask.

Sensors with ODR register at address 0 are: lsm303dlh, lsm303dlhc, lsm303dlm

Fixes 7d245172675a ("iio: common: st_sensors: check odr address value in st_sensors_set_odr()")
---
 drivers/iio/common/st_sensors/st_sensors_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/common/st_sensors/st_sensors_core.c +1 -1
index a0c2cbd60c6f..cccd4c26dfa4 100644
@@ -79,7 +79,7 @@ int st_sensors_set_odr(struct iio_dev *indio_dev, unsigned int odr)
 	struct st_sensor_odr_avl odr_out = {0, 0};
 	struct st_sensor_data *sdata = iio_priv(indio_dev);
 
-	if (!sdata->sensor_settings->odr.addr)
+	if (!sdata->sensor_settings->odr.mask)
 		return 0;
 
 	err = st_sensors_match_odr(sdata->sensor_settings, odr, &odr_out);
Signature · 1 line
2.26.0
maintainer Applied
#1 lore raw
Quoted 8 lines · On Sat, 11 Apr 2020 17:16:06 +0200 (CEST) [email protected] wrote:

Indeed, relying on addr being not 0 cannot work because some device have their register to set odr at address 0. As a matter of fact, if the odr can be set, then there is a mask.

Sensors with ODR register at address 0 are: lsm303dlh, lsm303dlhc, lsm303dlm

Fixes 7d245172675a ("iio: common: st_sensors: check odr address value in st_sensors_set_odr()")

Applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks,

Jonathan

Quoted 17 lines
---
 drivers/iio/common/st_sensors/st_sensors_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/common/st_sensors/st_sensors_core.c +1 -1
index a0c2cbd60c6f..cccd4c26dfa4 100644
@@ -79,7 +79,7 @@ int st_sensors_set_odr(struct iio_dev *indio_dev, unsigned int odr)
 	struct st_sensor_odr_avl odr_out = {0, 0};
 	struct st_sensor_data *sdata = iio_priv(indio_dev);
 
-	if (!sdata->sensor_settings->odr.addr)
+	if (!sdata->sensor_settings->odr.mask)
 		return 0;
 
 	err = st_sensors_match_odr(sdata->sensor_settings, odr, &odr_out);