Re: [PATCH v5 3/8] power: ip5xxx_power: Allow for more parameters to be configured

From: Csókás Bence
Date: Sun Dec 08 2024 - 08:01:05 EST


Hi,

On 2024. 12. 06. 20:51, Kees Bakker wrote:
Op 19-11-2024 om 19:07 schreef Csókás, Bence:
Other parts such as IP5306 may support other battery voltages and
have different constants for input voltage regulation. Allow these
to be passed from `struct ip5xxx_regfield_config`.

Signed-off-by: Csókás, Bence <csokas.bence@xxxxxxxxx>
---
  drivers/power/supply/ip5xxx_power.c | 43 ++++++++++++++++++++++++++---
  1 file changed, 39 insertions(+), 4 deletions(-)

diff --git a/drivers/power/supply/ip5xxx_power.c b/drivers/power/supply/ip5xxx_power.c
index 41d91504eb32..a939dbfe8d23 100644
--- a/drivers/power/supply/ip5xxx_power.c
+++ b/drivers/power/supply/ip5xxx_power.c
[...]
  /*
@@ -328,6 +348,9 @@ static int ip5xxx_battery_get_voltage_max(struct ip5xxx *ip5xxx, int *val)
      if (ret)
          return ret;
+    if (*val > ip5xxx->vbat_max)
+        return -EINVAL;
This is introducing the read of an uninitialized variable.
You have to check all the callers of ip5xxx_battery_get_voltage_max()
and what variable *val is pointing to. For example in
ip5xxx_battery_get_property() the variable vmax is not initialized,
while its address is passed to ip5xxx_battery_get_voltage_max()

But maybe the intention was to check rval instead of *val?
[...]

That was supposed to go in set_voltage_max()... I'll send a fix shortly.

Bence