power: supply: axp288_fuel_gauge: Fix fuel_gauge_reg_readb return on error
authorHans de Goede <hdegoede@redhat.com>
Wed, 14 Dec 2016 16:38:50 +0000 (17:38 +0100)
committerSebastian Reichel <sre@kernel.org>
Wed, 4 Jan 2017 20:59:08 +0000 (21:59 +0100)
If reading the register fails, return the actual error code, instead
of the uninitialized val variable;

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
drivers/power/supply/axp288_fuel_gauge.c

index 539eb41504bb8140c91f1b76991d59f00ba70bdd..86bb4d08b23668158a4f70ece432836c8f152fb9 100644 (file)
@@ -169,8 +169,10 @@ static int fuel_gauge_reg_readb(struct axp288_fg_info *info, int reg)
                        break;
        }
 
-       if (ret < 0)
+       if (ret < 0) {
                dev_err(&info->pdev->dev, "axp288 reg read err:%d\n", ret);
+               return ret;
+       }
 
        return val;
 }