]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
power: supply: sbs-battery: Fix a signedness bug in sbs_get_battery_capacity()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 25 Sep 2019 11:01:28 +0000 (14:01 +0300)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 22 May 2020 20:19:26 +0000 (21:19 +0100)
commit eb368de6de32925c65a97c1e929a31cae2155aee upstream.

The "mode" variable is an enum and in this context GCC treats it as an
unsigned int so the error handling is never triggered.

Fixes: 51d075660457 ("bq20z75: Add support for charge properties")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
[bwh: Backported to 3.16: adjust filename, context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/power/sbs-battery.c

index b5f2a76b6cdf9539a9a905c8f9f7bda9479c4a7b..32553c23d4676b44a0d988224bb994e40a9ee412 100644 (file)
@@ -400,7 +400,7 @@ static int sbs_get_battery_capacity(struct i2c_client *client,
                mode = BATTERY_MODE_AMPS;
 
        mode = sbs_set_battery_mode(client, mode);
-       if (mode < 0)
+       if ((int)mode < 0)
                return mode;
 
        ret = sbs_read_word_data(client, sbs_data[reg_offset].addr);