Skip to contentSkip to conversation

iio: ad5504: Fix setting power-down state

PATCH Applied Lars-Peter Clausen 3 participants 4 messages Dec 9, 2020 – Dec 29, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: ad5504: Fix setting power-down state

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

---
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(-)
drivers/iio/dac/ad5504.c +2 -2
index 28921b62e642..e9297c25d4ef 100644
@@ -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) |
Signature · 1 line
2.20.1
maintainer
#1 lore raw
Quoted 4 lines · On Wed, 9 Dec 2020 11:46:49 +0100 Lars-Peter Clausen <[email protected]> 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.

Quoted 8 lines

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

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

Quoted 20 lines
---
 drivers/iio/dac/ad5504.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/dac/ad5504.c +2 -2
index 28921b62e642..e9297c25d4ef 100644
@@ -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 lore raw
Quoted 11 lines · Jonathan Cameron
Quoted 7 lines · On Wed, 9 Dec 2020 11:46:49 +0100 Lars-Peter Clausen <[email protected]> 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.

Quoted 8 lines
Quoted 5 lines
Fixes 3bbbf150ffde ("staging:iio:dac:ad5504: Use strtobool for boolean values")

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

Quoted 26 lines

Thanks,

Jonathan

Quoted 20 lines
---
 drivers/iio/dac/ad5504.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/dac/ad5504.c +2 -2
index 28921b62e642..e9297c25d4ef 100644
@@ -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) |
maintainer Applied
#3 lore raw
Quoted 21 lines · On Mon, 14 Dec 2020 09:23:20 +0200 Alexandru Ardelean <[email protected]>…
Quoted 11 lines · Jonathan Cameron
Quoted 7 lines · On Wed, 9 Dec 2020 11:46:49 +0100 Lars-Peter Clausen <[email protected]> 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.

Quoted 8 lines
Quoted 5 lines
Fixes 3bbbf150ffde ("staging:iio:dac:ad5504: Use strtobool for boolean values")

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

Quoted 7 lines

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.

Applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks,

Jonathan

Quoted 28 lines
Quoted 28 lines

Thanks,

Jonathan

Quoted 20 lines
---
 drivers/iio/dac/ad5504.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/dac/ad5504.c +2 -2
index 28921b62e642..e9297c25d4ef 100644
@@ -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) |