]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
power: power_i2c: ret is uninitialised if not DM_I2C
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Thu, 7 Aug 2025 14:28:58 +0000 (15:28 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 29 Aug 2025 22:44:46 +0000 (16:44 -0600)
In pmic_reg_read ret is only assigned to inside #if
CONFIG_IS_ENABLED(DM_I2C) so move the test and return ret inside as well
and also guard the declaration of ret with CONFIG_IS_ENABLED(DM_I2C) to
prevent a warning about an unused variable.

This issue was found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
drivers/power/power_i2c.c

index c2fc1c6b42f31ef1db6d51c5663fb4af27b36d6b..58289ecce67db4f8d6f73aaebc4430aec9c31ede 100644 (file)
@@ -75,7 +75,7 @@ int pmic_reg_read(struct pmic *p, u32 reg, u32 *val)
 {
        unsigned char buf[4] = { 0 };
        u32 ret_val = 0;
-       int ret;
+       int __maybe_unused ret;
 
        if (check_reg(p, reg))
                return -EINVAL;
@@ -91,9 +91,9 @@ int pmic_reg_read(struct pmic *p, u32 reg, u32 *val)
                return -ENXIO;
        }
        ret = dm_i2c_read(dev, reg, buf, pmic_i2c_tx_num);
-#endif
        if (ret)
                return ret;
+#endif
 
        switch (pmic_i2c_tx_num) {
        case 3: