diff options
-rw-r--r-- | driver/battery/max17055.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/driver/battery/max17055.c b/driver/battery/max17055.c index db8b798a3b..07ecc473dd 100644 --- a/driver/battery/max17055.c +++ b/driver/battery/max17055.c @@ -264,8 +264,19 @@ void battery_get_params(struct batt_params *batt) { int reg = 0; - /* Reset flags */ - batt->flags = 0; + /* Reset params */ + memset(batt, 0, sizeof(struct batt_params)); + /* + * Assuming the battery is responsive as long as + * max17055 finds battery is present. + */ + batt->is_present = battery_is_present(); + + if (batt->is_present == BP_YES) + batt->flags |= BATT_FLAG_RESPONSIVE; + else if (batt->is_present == BP_NO) + /* Battery is not present, gauge won't report useful info. */ + return; if (max17055_read(REG_TEMPERATURE, ®)) batt->flags |= BATT_FLAG_BAD_TEMPERATURE; @@ -299,15 +310,6 @@ void battery_get_params(struct batt_params *batt) batt->flags |= BATT_FLAG_BAD_FULL_CAPACITY; /* - * Assuming the battery is responsive as long as - * max17055 finds battery is present. - */ - batt->is_present = battery_is_present(); - - if (batt->is_present == BP_YES) - batt->flags |= BATT_FLAG_RESPONSIVE; - - /* * Charging allowed if both desired voltage and current are nonzero * and battery isn't full (and we read them all correctly). */ |