Hi Jian, Not clear to me why should be + instead of *.
ODR is expressed in Hz, so (1/Hz) = period in seconds (1 sample sampling time) [s] 1000 * (1/Hz) = period in milliseconds (1 sample sampling time) [ms] n * 1000 * (1/Hz) = n times period in milliseconds (n times sample sampling time) [ms] In your case you assume bootime is in milliseconds. Maybe we can change the comment and use 'number of samples ...'. Br, Denis -----Original Message----- From: linux-iio-ow...@vger.kernel.org <linux-iio-ow...@vger.kernel.org> On Behalf Of Jian-Hong Pan Sent: Sunday, November 18, 2018 10:12 PM To: Jonathan Cameron <ji...@kernel.org>; Hartmut Knaack <knaac...@gmx.de>; Lars-Peter Clausen <l...@metafoo.de>; Peter Meerwald-Stadler <pme...@pmeerw.net>; Dominique Martinet <asmad...@codewreck.org> Cc: linux-...@vger.kernel.org; linux-kernel@vger.kernel.org; li...@endlessm.com; Jian-Hong Pan <jian-h...@endlessm.com> Subject: [PATCH] iio: st_sensors: Fix the sleep time for sampling According to the description of st_sensor_settings and st_sensor_data structures' comments: - bootime: samples to discard when sensor passing from power-down to power-up. - odr: Output data rate of the sensor [Hz]. The sleep time should be sdata->sensor_settings->bootime + 1000 / sdata->odr ms. Signed-off-by: Jian-Hong Pan <jian-h...@endlessm.com> --- drivers/iio/common/st_sensors/st_sensors_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 26fbd1bd9413..6b87ea657a92 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -594,7 +594,7 @@ int st_sensors_read_info_raw(struct iio_dev *indio_dev, if (err < 0) goto out; - msleep((sdata->sensor_settings->bootime * 1000) / sdata->odr); + msleep(sdata->sensor_settings->bootime + 1000 / sdata->odr); err = st_sensors_read_axis_data(indio_dev, ch, val); if (err < 0) goto out; -- 2.11.0