pmic_reg_read returns a negative value if an error occurs. This
commit adds a missing check after calling pmic_reg_read.

Signed-off-by: Francois Berder <[email protected]>
---
 drivers/power/regulator/pfuze100.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/power/regulator/pfuze100.c 
b/drivers/power/regulator/pfuze100.c
index 77c82a00b65..57af16cfbb9 100644
--- a/drivers/power/regulator/pfuze100.c
+++ b/drivers/power/regulator/pfuze100.c
@@ -550,6 +550,8 @@ static int pfuze100_regulator_val(struct udevice *dev, int 
op, int *uV)
                        return -EINVAL;
                }
                val = pmic_reg_read(dev->parent, desc->vsel_reg);
+               if (val < 0)
+                       return val;
                if (desc->high_volt_mask && (val & desc->high_volt_mask)) {
                        min_uV = desc->high_volt_desc->min_uV;
                        uV_step = desc->high_volt_desc->uV_step;
-- 
2.43.0

Reply via email to