linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: st_sensors: Fix the sleep time for sampling
@ 2018-11-19  6:12 Jian-Hong Pan
  2018-11-19 19:04 ` Denis CIOCCA
  0 siblings, 1 reply; 5+ messages in thread
From: Jian-Hong Pan @ 2018-11-19  6:12 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dominique Martinet
  Cc: linux-iio, linux-kernel, linux, Jian-Hong Pan

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-hong@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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH] iio: st_sensors: Fix the sleep time for sampling
  2018-11-19  6:12 [PATCH] iio: st_sensors: Fix the sleep time for sampling Jian-Hong Pan
@ 2018-11-19 19:04 ` Denis CIOCCA
  2018-11-21  5:13   ` Jian-Hong Pan
  0 siblings, 1 reply; 5+ messages in thread
From: Denis CIOCCA @ 2018-11-19 19:04 UTC (permalink / raw)
  To: Jian-Hong Pan, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Dominique Martinet
  Cc: linux-iio, linux-kernel, linux

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-owner@vger.kernel.org <linux-iio-owner@vger.kernel.org> On Behalf Of Jian-Hong Pan
Sent: Sunday, November 18, 2018 10:12 PM
To: Jonathan Cameron <jic23@kernel.org>; Hartmut Knaack <knaack.h@gmx.de>; Lars-Peter Clausen <lars@metafoo.de>; Peter Meerwald-Stadler <pmeerw@pmeerw.net>; Dominique Martinet <asmadeus@codewreck.org>
Cc: linux-iio@vger.kernel.org; linux-kernel@vger.kernel.org; linux@endlessm.com; Jian-Hong Pan <jian-hong@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-hong@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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] iio: st_sensors: Fix the sleep time for sampling
  2018-11-19 19:04 ` Denis CIOCCA
@ 2018-11-21  5:13   ` Jian-Hong Pan
  2018-11-25 13:22     ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Jian-Hong Pan @ 2018-11-21  5:13 UTC (permalink / raw)
  To: denis.ciocca
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dominique Martinet, linux-iio,
	Linux Kernel, linux

Denis CIOCCA <denis.ciocca@st.com> 於 2018年11月20日 週二 上午3:05寫道:
>
> 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.

Yes, I assume that according to the original comment.

>Maybe we can change the comment and use 'number of samples ...'.

Making the meaning more clear is better.

However, does the bootime of the measurement need as the long time to
be enabled?
If the sampling rate is 1Hz and n is 2, then they will do msleep with
2000 ms for each st_sensors_read_info_raw.

Regards,
Jian-Hong Pan

>
>
> -----Original Message-----
> From: linux-iio-owner@vger.kernel.org <linux-iio-owner@vger.kernel.org> On Behalf Of Jian-Hong Pan
> Sent: Sunday, November 18, 2018 10:12 PM
> To: Jonathan Cameron <jic23@kernel.org>; Hartmut Knaack <knaack.h@gmx.de>; Lars-Peter Clausen <lars@metafoo.de>; Peter Meerwald-Stadler <pmeerw@pmeerw.net>; Dominique Martinet <asmadeus@codewreck.org>
> Cc: linux-iio@vger.kernel.org; linux-kernel@vger.kernel.org; linux@endlessm.com; Jian-Hong Pan <jian-hong@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-hong@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
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] iio: st_sensors: Fix the sleep time for sampling
  2018-11-21  5:13   ` Jian-Hong Pan
@ 2018-11-25 13:22     ` Jonathan Cameron
  2018-11-27  7:23       ` Jian-Hong Pan
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2018-11-25 13:22 UTC (permalink / raw)
  To: Jian-Hong Pan
  Cc: denis.ciocca, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dominique Martinet, linux-iio,
	Linux Kernel, linux

On Wed, 21 Nov 2018 13:13:40 +0800
Jian-Hong Pan <jian-hong@endlessm.com> wrote:

> Denis CIOCCA <denis.ciocca@st.com> 於 2018年11月20日 週二 上午3:05寫道:
> >
> > 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.  
> 
> Yes, I assume that according to the original comment.
> 
> >Maybe we can change the comment and use 'number of samples ...'.  
> 
> Making the meaning more clear is better.
> 
> However, does the bootime of the measurement need as the long time to
> be enabled?
> If the sampling rate is 1Hz and n is 2, then they will do msleep with
> 2000 ms for each st_sensors_read_info_raw.

Superficially that seems correct as we need to be sure that a reading
has occurred.  If you want it to be quicker than the ODR should be set
faster so that the reading shows up reasonably quickly. At 1Hz and
you want to drop 2 samples, it will indeed take 2 seconds.

I'm not understanding why this is unexpected?

Jonathan

> 
> Regards,
> Jian-Hong Pan
> 
> >
> >
> > -----Original Message-----
> > From: linux-iio-owner@vger.kernel.org <linux-iio-owner@vger.kernel.org> On Behalf Of Jian-Hong Pan
> > Sent: Sunday, November 18, 2018 10:12 PM
> > To: Jonathan Cameron <jic23@kernel.org>; Hartmut Knaack <knaack.h@gmx.de>; Lars-Peter Clausen <lars@metafoo.de>; Peter Meerwald-Stadler <pmeerw@pmeerw.net>; Dominique Martinet <asmadeus@codewreck.org>
> > Cc: linux-iio@vger.kernel.org; linux-kernel@vger.kernel.org; linux@endlessm.com; Jian-Hong Pan <jian-hong@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-hong@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
> >  


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] iio: st_sensors: Fix the sleep time for sampling
  2018-11-25 13:22     ` Jonathan Cameron
@ 2018-11-27  7:23       ` Jian-Hong Pan
  0 siblings, 0 replies; 5+ messages in thread
From: Jian-Hong Pan @ 2018-11-27  7:23 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Denis Ciocca, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dominique Martinet, linux-iio,
	Linux Kernel, linux

Jonathan Cameron <jic23@kernel.org> 於 2018年11月25日 週日 下午9:23寫道:
>
> On Wed, 21 Nov 2018 13:13:40 +0800
> Jian-Hong Pan <jian-hong@endlessm.com> wrote:
>
> > Denis CIOCCA <denis.ciocca@st.com> 於 2018年11月20日 週二 上午3:05寫道:
> > >
> > > 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.
> >
> > Yes, I assume that according to the original comment.
> >
> > >Maybe we can change the comment and use 'number of samples ...'.
> >
> > Making the meaning more clear is better.
> >
> > However, does the bootime of the measurement need as the long time to
> > be enabled?
> > If the sampling rate is 1Hz and n is 2, then they will do msleep with
> > 2000 ms for each st_sensors_read_info_raw.
>
> Superficially that seems correct as we need to be sure that a reading
> has occurred.  If you want it to be quicker than the ODR should be set
> faster so that the reading shows up reasonably quickly. At 1Hz and
> you want to drop 2 samples, it will indeed take 2 seconds.

Now, I understand with the description.  Thank you.

Jian-Hong Pan

> > > -----Original Message-----
> > > From: linux-iio-owner@vger.kernel.org <linux-iio-owner@vger.kernel.org> On Behalf Of Jian-Hong Pan
> > > Sent: Sunday, November 18, 2018 10:12 PM
> > > To: Jonathan Cameron <jic23@kernel.org>; Hartmut Knaack <knaack.h@gmx.de>; Lars-Peter Clausen <lars@metafoo.de>; Peter Meerwald-Stadler <pmeerw@pmeerw.net>; Dominique Martinet <asmadeus@codewreck.org>
> > > Cc: linux-iio@vger.kernel.org; linux-kernel@vger.kernel.org; linux@endlessm.com; Jian-Hong Pan <jian-hong@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-hong@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
> > >
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-11-27  7:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-19  6:12 [PATCH] iio: st_sensors: Fix the sleep time for sampling Jian-Hong Pan
2018-11-19 19:04 ` Denis CIOCCA
2018-11-21  5:13   ` Jian-Hong Pan
2018-11-25 13:22     ` Jonathan Cameron
2018-11-27  7:23       ` Jian-Hong Pan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).