diff mbox series

[v2,2/3] iio: pressure: ms5611: changed hardcoded SPI speed to value limited

Message ID 20221021135827.1444793-3-mitja@lxnav.com (mailing list archive)
State Accepted
Headers show
Series ms5611 sensor value bug fix; dt-binding fix | expand

Commit Message

Mitja Špes Oct. 21, 2022, 1:58 p.m. UTC
Don't hardcode the ms5611 SPI speed, limit it instead.

Signed-off-by: Mitja Spes <mitja@lxnav.com>
---
 drivers/iio/pressure/ms5611_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marcus Folkesson Oct. 21, 2022, 3:32 p.m. UTC | #1
Hi Mitja,

On Fri, Oct 21, 2022 at 03:58:21PM +0200, Mitja Spes wrote:
> Don't hardcode the ms5611 SPI speed, limit it instead.
> 
> Signed-off-by: Mitja Spes <mitja@lxnav.com>
> ---
>  drivers/iio/pressure/ms5611_spi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/pressure/ms5611_spi.c b/drivers/iio/pressure/ms5611_spi.c
> index 432e912096f4..a0a7205c9c3a 100644
> --- a/drivers/iio/pressure/ms5611_spi.c
> +++ b/drivers/iio/pressure/ms5611_spi.c
> @@ -91,7 +91,7 @@ static int ms5611_spi_probe(struct spi_device *spi)
>  	spi_set_drvdata(spi, indio_dev);
>  
>  	spi->mode = SPI_MODE_0;
> -	spi->max_speed_hz = 20000000;
> +	spi->max_speed_hz = min(spi->max_speed_hz, 20000000U);

max_speed_hz is a limit, and the max frequency the ms5611 support is
20MHz.

Best regards,
Marcus Folkesson
Jonathan Cameron Oct. 23, 2022, 11:10 a.m. UTC | #2
On Fri, 21 Oct 2022 17:32:21 +0200
Marcus Folkesson <marcus.folkesson@gmail.com> wrote:

> Hi Mitja,
> 
> On Fri, Oct 21, 2022 at 03:58:21PM +0200, Mitja Spes wrote:
> > Don't hardcode the ms5611 SPI speed, limit it instead.
> > 
> > Signed-off-by: Mitja Spes <mitja@lxnav.com>
Please give a fixes tag for this one as well.
The driver should never have been doing this.

Jonathan

> > ---
> >  drivers/iio/pressure/ms5611_spi.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iio/pressure/ms5611_spi.c b/drivers/iio/pressure/ms5611_spi.c
> > index 432e912096f4..a0a7205c9c3a 100644
> > --- a/drivers/iio/pressure/ms5611_spi.c
> > +++ b/drivers/iio/pressure/ms5611_spi.c
> > @@ -91,7 +91,7 @@ static int ms5611_spi_probe(struct spi_device *spi)
> >  	spi_set_drvdata(spi, indio_dev);
> >  
> >  	spi->mode = SPI_MODE_0;
> > -	spi->max_speed_hz = 20000000;
> > +	spi->max_speed_hz = min(spi->max_speed_hz, 20000000U);  
> 
> max_speed_hz is a limit, and the max frequency the ms5611 support is
> 20MHz.
> 
> Best regards,
> Marcus Folkesson
Jonathan Cameron Oct. 23, 2022, 11:12 a.m. UTC | #3
On Fri, 21 Oct 2022 17:32:21 +0200
Marcus Folkesson <marcus.folkesson@gmail.com> wrote:

> Hi Mitja,
> 
> On Fri, Oct 21, 2022 at 03:58:21PM +0200, Mitja Spes wrote:
> > Don't hardcode the ms5611 SPI speed, limit it instead.
> > 
> > Signed-off-by: Mitja Spes <mitja@lxnav.com>
> > ---
> >  drivers/iio/pressure/ms5611_spi.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iio/pressure/ms5611_spi.c b/drivers/iio/pressure/ms5611_spi.c
> > index 432e912096f4..a0a7205c9c3a 100644
> > --- a/drivers/iio/pressure/ms5611_spi.c
> > +++ b/drivers/iio/pressure/ms5611_spi.c
> > @@ -91,7 +91,7 @@ static int ms5611_spi_probe(struct spi_device *spi)
> >  	spi_set_drvdata(spi, indio_dev);
> >  
> >  	spi->mode = SPI_MODE_0;
> > -	spi->max_speed_hz = 20000000;
> > +	spi->max_speed_hz = min(spi->max_speed_hz, 20000000U);  
> 
> max_speed_hz is a limit, and the max frequency the ms5611 support is
> 20MHz.
Hi Marcus,

I'm not following what you are commenting on.. Perhaps give more
detail?

Thanks,

Jonathan

> 
> Best regards,
> Marcus Folkesson
Mitja Špes Oct. 24, 2022, 6:46 a.m. UTC | #4
On Sun, Oct 23, 2022 at 1:09 PM Jonathan Cameron <jic23@kernel.org> wrote:
> Please give a fixes tag for this one as well.
> The driver should never have been doing this.

Fixes: c0644160a8b5 ("iio: pressure: add support for MS5611 pressure
and temperature sensor")

Kind regards,
Mitja
Marcus Folkesson Oct. 24, 2022, 9:05 a.m. UTC | #5
Hi Jonathan,

On Sun, Oct 23, 2022 at 12:12:22PM +0100, Jonathan Cameron wrote:
> On Fri, 21 Oct 2022 17:32:21 +0200
> Marcus Folkesson <marcus.folkesson@gmail.com> wrote:
> 
> > Hi Mitja,
> > 
> > On Fri, Oct 21, 2022 at 03:58:21PM +0200, Mitja Spes wrote:
> > > Don't hardcode the ms5611 SPI speed, limit it instead.
> > > 
> > > Signed-off-by: Mitja Spes <mitja@lxnav.com>
> > > ---
> > >  drivers/iio/pressure/ms5611_spi.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/iio/pressure/ms5611_spi.c b/drivers/iio/pressure/ms5611_spi.c
> > > index 432e912096f4..a0a7205c9c3a 100644
> > > --- a/drivers/iio/pressure/ms5611_spi.c
> > > +++ b/drivers/iio/pressure/ms5611_spi.c
> > > @@ -91,7 +91,7 @@ static int ms5611_spi_probe(struct spi_device *spi)
> > >  	spi_set_drvdata(spi, indio_dev);
> > >  
> > >  	spi->mode = SPI_MODE_0;
> > > -	spi->max_speed_hz = 20000000;
> > > +	spi->max_speed_hz = min(spi->max_speed_hz, 20000000U);  
> > 
> > max_speed_hz is a limit, and the max frequency the ms5611 support is
> > 20MHz.
> Hi Marcus,
> 
> I'm not following what you are commenting on.. Perhaps give more
> detail?

Sorry for being unclear.
However, I must have thought wrong, this is good as it takes the speedlimit set
in e.g. devicetree into account.


> 
> Thanks,
> 
> Jonathan
> 
> > 
> > Best regards,
> > Marcus Folkesson
> 

Best regards,
Marcus Folkesson
diff mbox series

Patch

diff --git a/drivers/iio/pressure/ms5611_spi.c b/drivers/iio/pressure/ms5611_spi.c
index 432e912096f4..a0a7205c9c3a 100644
--- a/drivers/iio/pressure/ms5611_spi.c
+++ b/drivers/iio/pressure/ms5611_spi.c
@@ -91,7 +91,7 @@  static int ms5611_spi_probe(struct spi_device *spi)
 	spi_set_drvdata(spi, indio_dev);
 
 	spi->mode = SPI_MODE_0;
-	spi->max_speed_hz = 20000000;
+	spi->max_speed_hz = min(spi->max_speed_hz, 20000000U);
 	spi->bits_per_word = 8;
 	ret = spi_setup(spi);
 	if (ret < 0)