diff mbox series

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

Message ID ea-mime-5e85eb6b-6be-7ee474a6@www-2.mailo.com (mailing list archive)
State New, archived
Headers show
Series iio: st_sensors: rely on odr mask to know if odr can be set | expand

Commit Message

yarl-baudig@mailoo.org April 2, 2020, 1:40 p.m. UTC
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.

Signed-off-by: Lary Gibaud <yarl-baudig@mailoo.org>
---
 drivers/iio/common/st_sensors/st_sensors_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jonathan Cameron April 5, 2020, 11:57 a.m. UTC | #1
On Thu,  2 Apr 2020 15:40:59 +0200 (CEST)
yarl-baudig@mailoo.org 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.

Hi Lary,

Which sensor has ODR in the register at address 0?

I see it's a few of the magnetometers from a quick grep, but please state
it in the cover letter.  Also please add a suitable Fixes tag
as we will want this backported if appropriate.

Thanks,

Jonathan

> 
> Signed-off-by: Lary Gibaud <yarl-baudig@mailoo.org>
> ---
>  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 a0c2cbd60c6f..cccd4c26dfa4 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_core.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_core.c
> @@ -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);
yarl-baudig@mailoo.org April 9, 2020, 11:24 a.m. UTC | #2
Oh, sorry, just saw your answer. Ok I can list such sensors.
Please tell me what I should do about Fixes tag. That's the first time I send a patch I'm not sure What I should put in it.
Is it :
Fixes: 4358be137952 (MAINTAINERS: Add Syed Nayyar Waris to ACCES 104-QUAD-8 driver)
? Thank you.
---- Message d'origine ----
> De : Jonathan Cameron <jic23@kernel.org>
> À : yarl-baudig@mailoo.org
> Sujet : Re: [PATCH] iio: st_sensors: rely on odr mask to know if odr can be set
> Date : 05/04/2020 13:57:02 Europe/Paris
> Copie à : linux-iio@vger.kernel.org;
>       Hartmut Knaack <knaack.h@gmx.de>;
>       Lars-Peter Clausen <lars@metafoo.de>;
>       Peter Meerwald-Stadler <pmeerw@pmeerw.net>;
>       Denis Ciocca <denis.ciocca@st.com>
> 
> On Thu,  2 Apr 2020 15:40:59 +0200 (CEST)
> yarl-baudig@mailoo.org 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.
> 
> Hi Lary,
> 
> Which sensor has ODR in the register at address 0?
> 
> I see it's a few of the magnetometers from a quick grep, but please state
> it in the cover letter.  Also please add a suitable Fixes tag
> as we will want this backported if appropriate.
> 
> Thanks,
> 
> Jonathan
> 
> > 
> > Signed-off-by: Lary Gibaud <yarl-baudig@mailoo.org>
> > ---
> >  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 a0c2cbd60c6f..cccd4c26dfa4 100644
> > --- a/drivers/iio/common/st_sensors/st_sensors_core.c
> > +++ b/drivers/iio/common/st_sensors/st_sensors_core.c
> > @@ -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);
> 
>
diff mbox series

Patch

diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index a0c2cbd60c6f..cccd4c26dfa4 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -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);