[1/4] power: supply: axp288_fuel_gauge: Fix fuel_gauge_reg_readb return on error
diff mbox

Message ID 20161214163853.454-1-hdegoede@redhat.com
State Not Applicable
Headers show

Commit Message

Hans de Goede Dec. 14, 2016, 4:38 p.m. UTC
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>
---
 drivers/power/supply/axp288_fuel_gauge.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Wolfram Sang Dec. 14, 2016, 5:01 p.m. UTC | #1
On Wed, Dec 14, 2016 at 05:38:50PM +0100, Hans de Goede wrote:
> If reading the register fails, return the actual error code, instead
> of the uninitialized val variable;

Please don't CC the linux-i2c list for i2c client drivers unless you
have specific i2c related questions. It makes focussing on the core
parts harder.

Thanks,

   Wolfram

Patch
diff mbox

diff --git a/drivers/power/supply/axp288_fuel_gauge.c b/drivers/power/supply/axp288_fuel_gauge.c
index 5bdde69..f62f9df 100644
--- a/drivers/power/supply/axp288_fuel_gauge.c
+++ b/drivers/power/supply/axp288_fuel_gauge.c
@@ -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;
 }