linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: ad5504: Fix setting power-down state
@ 2020-12-09 10:46 Lars-Peter Clausen
  2020-12-13 16:55 ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Lars-Peter Clausen @ 2020-12-09 10:46 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Peter Meerwald-Stadler, Alexandru Ardelean, linux-iio,
	Lars-Peter Clausen

The power-down mask of the ad5504 is actually a power-up mask. Meaning if
a bit is set the corresponding channel is powered up and if it is not set
the channel is powered down.

The driver currently has this the wrong way around, resulting in the
channel being powered up when requested to be powered down and vice versa.

Fixes: 3bbbf150ffde ("staging:iio:dac:ad5504: Use strtobool for boolean values")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
Stumbled upon this while looking at something else. It is untested, but I
think it should be right. Alex can you double check?
---
 drivers/iio/dac/ad5504.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c
index 28921b62e642..e9297c25d4ef 100644
--- a/drivers/iio/dac/ad5504.c
+++ b/drivers/iio/dac/ad5504.c
@@ -187,9 +187,9 @@ static ssize_t ad5504_write_dac_powerdown(struct iio_dev *indio_dev,
 		return ret;
 
 	if (pwr_down)
-		st->pwr_down_mask |= (1 << chan->channel);
-	else
 		st->pwr_down_mask &= ~(1 << chan->channel);
+	else
+		st->pwr_down_mask |= (1 << chan->channel);
 
 	ret = ad5504_spi_write(st, AD5504_ADDR_CTRL,
 				AD5504_DAC_PWRDWN_MODE(st->pwr_down_mode) |
-- 
2.20.1


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

* Re: [PATCH] iio: ad5504: Fix setting power-down state
  2020-12-09 10:46 [PATCH] iio: ad5504: Fix setting power-down state Lars-Peter Clausen
@ 2020-12-13 16:55 ` Jonathan Cameron
  2020-12-14  7:23   ` Alexandru Ardelean
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2020-12-13 16:55 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Peter Meerwald-Stadler, Alexandru Ardelean, linux-iio

On Wed,  9 Dec 2020 11:46:49 +0100
Lars-Peter Clausen <lars@metafoo.de> wrote:

> The power-down mask of the ad5504 is actually a power-up mask. Meaning if
> a bit is set the corresponding channel is powered up and if it is not set
> the channel is powered down.
> 
> The driver currently has this the wrong way around, resulting in the
> channel being powered up when requested to be powered down and vice versa.
> 
> Fixes: 3bbbf150ffde ("staging:iio:dac:ad5504: Use strtobool for boolean values")
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> ---
> Stumbled upon this while looking at something else. It is untested, but I
> think it should be right. Alex can you double check?

I read the datasheet as saying this fix is right but will wait for
a confirmation from Alex.

Thanks,

Jonathan

> ---
>  drivers/iio/dac/ad5504.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c
> index 28921b62e642..e9297c25d4ef 100644
> --- a/drivers/iio/dac/ad5504.c
> +++ b/drivers/iio/dac/ad5504.c
> @@ -187,9 +187,9 @@ static ssize_t ad5504_write_dac_powerdown(struct iio_dev *indio_dev,
>  		return ret;
>  
>  	if (pwr_down)
> -		st->pwr_down_mask |= (1 << chan->channel);
> -	else
>  		st->pwr_down_mask &= ~(1 << chan->channel);
> +	else
> +		st->pwr_down_mask |= (1 << chan->channel);
>  
>  	ret = ad5504_spi_write(st, AD5504_ADDR_CTRL,
>  				AD5504_DAC_PWRDWN_MODE(st->pwr_down_mode) |


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

* Re: [PATCH] iio: ad5504: Fix setting power-down state
  2020-12-13 16:55 ` Jonathan Cameron
@ 2020-12-14  7:23   ` Alexandru Ardelean
  2020-12-29 18:28     ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Alexandru Ardelean @ 2020-12-14  7:23 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Alexandru Ardelean,
	linux-iio

On Sun, Dec 13, 2020 at 8:59 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Wed,  9 Dec 2020 11:46:49 +0100
> Lars-Peter Clausen <lars@metafoo.de> wrote:
>
> > The power-down mask of the ad5504 is actually a power-up mask. Meaning if
> > a bit is set the corresponding channel is powered up and if it is not set
> > the channel is powered down.
> >
> > The driver currently has this the wrong way around, resulting in the
> > channel being powered up when requested to be powered down and vice versa.
> >
> > Fixes: 3bbbf150ffde ("staging:iio:dac:ad5504: Use strtobool for boolean values")
> > Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> > ---
> > Stumbled upon this while looking at something else. It is untested, but I
> > think it should be right. Alex can you double check?
>
> I read the datasheet as saying this fix is right but will wait for
> a confirmation from Alex.

Oh.
I see why the initial confusion existed.
Was confused a bit myself.
The thermal shutdown follows the initial/unchanged logic.
While the actual powerdown channel bits are inverted.

Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>


>
> Thanks,
>
> Jonathan
>
> > ---
> >  drivers/iio/dac/ad5504.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c
> > index 28921b62e642..e9297c25d4ef 100644
> > --- a/drivers/iio/dac/ad5504.c
> > +++ b/drivers/iio/dac/ad5504.c
> > @@ -187,9 +187,9 @@ static ssize_t ad5504_write_dac_powerdown(struct iio_dev *indio_dev,
> >               return ret;
> >
> >       if (pwr_down)
> > -             st->pwr_down_mask |= (1 << chan->channel);
> > -     else
> >               st->pwr_down_mask &= ~(1 << chan->channel);
> > +     else
> > +             st->pwr_down_mask |= (1 << chan->channel);
> >
> >       ret = ad5504_spi_write(st, AD5504_ADDR_CTRL,
> >                               AD5504_DAC_PWRDWN_MODE(st->pwr_down_mode) |
>

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

* Re: [PATCH] iio: ad5504: Fix setting power-down state
  2020-12-14  7:23   ` Alexandru Ardelean
@ 2020-12-29 18:28     ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2020-12-29 18:28 UTC (permalink / raw)
  To: Alexandru Ardelean
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Alexandru Ardelean,
	linux-iio

On Mon, 14 Dec 2020 09:23:20 +0200
Alexandru Ardelean <ardeleanalex@gmail.com> wrote:

> On Sun, Dec 13, 2020 at 8:59 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > On Wed,  9 Dec 2020 11:46:49 +0100
> > Lars-Peter Clausen <lars@metafoo.de> wrote:
> >  
> > > The power-down mask of the ad5504 is actually a power-up mask. Meaning if
> > > a bit is set the corresponding channel is powered up and if it is not set
> > > the channel is powered down.
> > >
> > > The driver currently has this the wrong way around, resulting in the
> > > channel being powered up when requested to be powered down and vice versa.
> > >
> > > Fixes: 3bbbf150ffde ("staging:iio:dac:ad5504: Use strtobool for boolean values")
> > > Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> > > ---
> > > Stumbled upon this while looking at something else. It is untested, but I
> > > think it should be right. Alex can you double check?  
> >
> > I read the datasheet as saying this fix is right but will wait for
> > a confirmation from Alex.  
> 
> Oh.
> I see why the initial confusion existed.
> Was confused a bit myself.
> The thermal shutdown follows the initial/unchanged logic.
> While the actual powerdown channel bits are inverted.
> 
> Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Applied to the fixes-togreg branch of iio.git and marked for
stable.

Thanks,

Jonathan

> 
> 
> >
> > Thanks,
> >
> > Jonathan
> >  
> > > ---
> > >  drivers/iio/dac/ad5504.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c
> > > index 28921b62e642..e9297c25d4ef 100644
> > > --- a/drivers/iio/dac/ad5504.c
> > > +++ b/drivers/iio/dac/ad5504.c
> > > @@ -187,9 +187,9 @@ static ssize_t ad5504_write_dac_powerdown(struct iio_dev *indio_dev,
> > >               return ret;
> > >
> > >       if (pwr_down)
> > > -             st->pwr_down_mask |= (1 << chan->channel);
> > > -     else
> > >               st->pwr_down_mask &= ~(1 << chan->channel);
> > > +     else
> > > +             st->pwr_down_mask |= (1 << chan->channel);
> > >
> > >       ret = ad5504_spi_write(st, AD5504_ADDR_CTRL,
> > >                               AD5504_DAC_PWRDWN_MODE(st->pwr_down_mode) |  
> >  


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

end of thread, other threads:[~2020-12-29 18:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09 10:46 [PATCH] iio: ad5504: Fix setting power-down state Lars-Peter Clausen
2020-12-13 16:55 ` Jonathan Cameron
2020-12-14  7:23   ` Alexandru Ardelean
2020-12-29 18:28     ` Jonathan Cameron

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).