Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d08e699 authored by Kiran Gunda's avatar Kiran Gunda
Browse files

power: qpnp-fg-gen4: Fix maintenance SOC reporting logic



Some times the SOC value reported as increasing even though
there is no charger connected to the device. Fix it by correcting
maintenance SOC reporting logic.

Change-Id: I0fb897616c72467f68b9be9a193c28a9008765ea
Signed-off-by: default avatarKiran Gunda <kgunda@codeaurora.org>
parent d76cd6ca
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
 */

#define pr_fmt(fmt)	"FG: %s: " fmt, __func__
@@ -2745,14 +2745,14 @@ static int fg_gen4_update_maint_soc(struct fg_dev *fg)
		goto out;
	}

	if (msoc > fg->maint_soc) {
	if (msoc >= fg->maint_soc) {
		/*
		 * When the monotonic SOC goes above maintenance SOC, we should
		 * stop showing the maintenance SOC.
		 */
		fg->delta_soc = 0;
		fg->maint_soc = 0;
	} else if (fg->maint_soc && msoc <= fg->last_msoc) {
	} else if (fg->maint_soc && msoc < fg->last_msoc) {
		/* MSOC is decreasing. Decrease maintenance SOC as well */
		fg->maint_soc -= 1;
		if (!(msoc % 10)) {