Skip to content

Commit c0792c9

Browse files
committed
power: supply: ln8411: Fixes ln8411_get_status() behavior
Initializes the charging status to unknown in the event of an early return and corrects logical error in the state comparison. Change-Id: Ia0d00a40b652a4e8d9ce32e51071a89877991d10 Signed-off-by: Ricardo Rivera-Matos <[email protected]>
1 parent bf65671 commit c0792c9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/power/supply/ln8411_charger.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,18 @@ static int ln8411_get_status(struct ln8411_device *ln8411)
293293
unsigned int reg_code;
294294
int ret;
295295

296+
ln8411->state.charging_status = POWER_SUPPLY_STATUS_UNKNOWN;
297+
296298
ret = regmap_read(ln8411->regmap, LN8411_SYS_STS, &reg_code);
297299
if (ret)
298300
return ret;
299301

300-
if (reg_code & LN8411_ACTIVE_STS & (ln8411->state.mode < LN8411_REV1TO4))
302+
if (reg_code & LN8411_ACTIVE_STS && (ln8411->state.mode < LN8411_REV1TO4))
301303
ln8411->state.charging_status = POWER_SUPPLY_STATUS_CHARGING;
302-
else if ((reg_code & LN8411_ACTIVE_STS) & (ln8411->state.mode > LN8411_FWD1TO1))
304+
else if (reg_code & LN8411_SHUTDOWN_STS)
303305
ln8411->state.charging_status = POWER_SUPPLY_STATUS_DISCHARGING;
304306
else if (reg_code & LN8411_STANDBY_STS)
305307
ln8411->state.charging_status = POWER_SUPPLY_STATUS_NOT_CHARGING;
306-
else
307-
ln8411->state.charging_status = POWER_SUPPLY_STATUS_UNKNOWN;
308308

309309
return ret;
310310
}

0 commit comments

Comments
 (0)