]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
power: regulator: palmas: Cannot test unsigned for being negative
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Thu, 7 Aug 2025 16:35:20 +0000 (17:35 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 29 Aug 2025 22:45:19 +0000 (16:45 -0600)
In palmas_smps_val and palmas_ldo_val hex is an unsigned variable being
assigned the return value from a function that returns int. Change hex
to be an int so that the following test for an error as a negative value
will work as expected.

This issue was found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
drivers/power/regulator/palmas_regulator.c

index 2286eac93fbe5e850b910f7bb0c89a91d8958ae7..7212062c8c8c3b806eaae9a0865b91d8b4db8eaa 100644 (file)
@@ -115,8 +115,8 @@ static int palmas_smps_hex2volt(int hex, bool range)
 
 static int palmas_smps_val(struct udevice *dev, int op, int *uV)
 {
-       unsigned int hex, adr;
-       int ret;
+       unsigned int adr;
+       int hex, ret;
        bool range;
        struct dm_regulator_uclass_plat *uc_pdata;
 
@@ -251,8 +251,8 @@ static int palmas_ldo_hex2volt(int hex)
 
 static int palmas_ldo_val(struct udevice *dev, int op, int *uV)
 {
-       unsigned int hex, adr;
-       int ret;
+       unsigned int adr;
+       int hex, ret;
 
        struct dm_regulator_uclass_plat *uc_pdata;