Skip to contentSkip to conversation

iio: dac: ad5592r: Fix the missing return value.

PATCH In review Zizhuang Deng 4 participants 5 messages Mar 10, 2022 – Mar 27, 2022

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

PATCH 1/1 iio: dac: ad5592r: Fix the missing return value.

The third call to fwnode_property_read_u32 did not record the return value, resulting in channel_offstate possibly being assigned the wrong value.

---
 drivers/iio/dac/ad5592r-base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/dac/ad5592r-base.c +1 -1
index a424b7220b61..4434c1b2a322 100644
@@ -522,7 +522,7 @@ static int ad5592r_alloc_channels(struct iio_dev *iio_dev)
 		if (!ret)
 			st->channel_modes[reg] = tmp;
 
-		fwnode_property_read_u32(child, "adi,off-state", &tmp);
+		ret = fwnode_property_read_u32(child, "adi,off-state", &tmp);
 		if (!ret)
 			st->channel_offstate[reg] = tmp;
 	}
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 5 lines · On Thu, 10 Mar 2022 20:54:50 +0800 Zizhuang Deng <[email protected]> wrote:

The third call to fwnode_property_read_u32 did not record the return value, resulting in channel_offstate possibly being assigned the wrong value.

Hi,

Definitely rather odd looking and I think your conclusion is correct. +CC Paul for confirmation that this isn't doing something clever..

Quoted 17 lines
---
 drivers/iio/dac/ad5592r-base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/dac/ad5592r-base.c +1 -1
index a424b7220b61..4434c1b2a322 100644
@@ -522,7 +522,7 @@ static int ad5592r_alloc_channels(struct iio_dev *iio_dev)
 		if (!ret)
 			st->channel_modes[reg] = tmp;
 
-		fwnode_property_read_u32(child, "adi,off-state", &tmp);
+		ret = fwnode_property_read_u32(child, "adi,off-state", &tmp);
 		if (!ret)
 			st->channel_offstate[reg] = tmp;
 	}
#2 lore raw

Hi,

Quoted 7 lines · Jonathan Cameron
Quoted 4 lines · On Thu, 10 Mar 2022 20:54:50 +0800 Zizhuang Deng <[email protected]> wrote:

The third call to fwnode_property_read_u32 did not record the return value, resulting in channel_offstate possibly being assigned the wrong value.

Quoted 5 lines
Quoted 1 line

Hi,

Definitely rather odd looking and I think your conclusion is correct. +CC Paul for confirmation that this isn't doing something clever..

It's been a while, but I don't think there was anything clever going on here - so the patch is fine.

Cheers,
-Paul

Quoted 21 lines
Quoted 20 lines

---

  drivers/iio/dac/ad5592r-base.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/dac/ad5592r-base.c
b/drivers/iio/dac/ad5592r-base.c
index a424b7220b61..4434c1b2a322 100644
--- a/drivers/iio/dac/ad5592r-base.c
+++ b/drivers/iio/dac/ad5592r-base.c
@@ -522,7 +522,7 @@ static int ad5592r_alloc_channels(struct
iio_dev *iio_dev)
if (!ret)
st->channel_modes[reg] = tmp;

- fwnode_property_read_u32(child, "adi,off-state", &tmp);
+ ret = fwnode_property_read_u32(child, "adi,off-state", &tmp);
if (!ret)
st->channel_offstate[reg] = tmp;
}

maintainer
#3 lore raw
Quoted 11 lines · On Mon, 21 Mar 2022 09:28:36 +0000 Paul Cercueil <[email protected]> wrote:

Hi,

Quoted 7 lines · Jonathan Cameron
Quoted 4 lines · On Thu, 10 Mar 2022 20:54:50 +0800 Zizhuang Deng <[email protected]> wrote:

The third call to fwnode_property_read_u32 did not record the return value, resulting in channel_offstate possibly being assigned the wrong value.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Hi,

Definitely rather odd looking and I think your conclusion is correct. +CC Paul for confirmation that this isn't doing something clever..

It's been a while, but I don't think there was anything clever going on here - so the patch is fine.

Added a fixes tag (it was driver introduction) and marked for stable given this could have some weird side effects if anyone actually had a dt that hit this path. Applied to the fixes-togreg branch of iio.git but not pushed out yet as I'll be rebasing that branch on rc1 next week.

Thanks,

Jonathan

Quoted 27 lines

Cheers,
-Paul

Quoted 21 lines
Quoted 20 lines

---

  drivers/iio/dac/ad5592r-base.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/dac/ad5592r-base.c
b/drivers/iio/dac/ad5592r-base.c
index a424b7220b61..4434c1b2a322 100644
--- a/drivers/iio/dac/ad5592r-base.c
+++ b/drivers/iio/dac/ad5592r-base.c
@@ -522,7 +522,7 @@ static int ad5592r_alloc_channels(struct
iio_dev *iio_dev)
if (!ret)
st->channel_modes[reg] = tmp;

- fwnode_property_read_u32(child, "adi,off-state", &tmp);
+ ret = fwnode_property_read_u32(child, "adi,off-state", &tmp);
if (!ret)
st->channel_offstate[reg] = tmp;
}

#4 lore raw
In reply to Paul Cercueil
Quoted 9 lines · Paul Cercueil
Quoted 6 lines · Jonathan Cameron
Quoted 3 lines · On Thu, 10 Mar 2022 20:54:50 +0800 Zizhuang Deng <[email protected]> wrote:

The third call to fwnode_property_read_u32 did not record the return value, resulting in channel_offstate possibly being assigned the wrong value.

Quoted 5 lines
Quoted 2 lines

Definitely rather odd looking and I think your conclusion is correct. +CC Paul for confirmation that this isn't doing something clever..

It's been a while, but I don't think there was anything clever going on here - so the patch is fine.

Basically the question here is what value should offstate have when there is no such property. Currently it's the same value as modes (no seeing context other than in the patch).

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
             if (!ret)
                     st->channel_modes[reg] = tmp;

- fwnode_property_read_u32(child, "adi,off-state", &tmp);

 +           ret = fwnode_property_read_u32(child, "adi,off-state", &tmp);
             if (!ret)
                     st->channel_offstate[reg] = tmp;
Signature · 2 lines
With Best Regards,
Andy Shevchenko