diff mbox series

[6/7] power: supply: axp288_fuel_gauge: Take lock before updating the valid flag

Message ID 20220106110608.66231-6-hdegoede@redhat.com
State Accepted
Commit 30abb3d07929137bf72327560e1595508a692c4e
Headers show
Series None | expand

Commit Message

Hans de Goede Jan. 6, 2022, 11:06 a.m. UTC
The valid flag is protected by the mutex, so code clearing it
should take the mutex before cleating the valid flag.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/power/supply/axp288_fuel_gauge.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/drivers/power/supply/axp288_fuel_gauge.c b/drivers/power/supply/axp288_fuel_gauge.c
index f7dce029266a..53d0e82bbb3e 100644
--- a/drivers/power/supply/axp288_fuel_gauge.c
+++ b/drivers/power/supply/axp288_fuel_gauge.c
@@ -476,7 +476,9 @@  static irqreturn_t fuel_gauge_thread_handler(int irq, void *dev)
 		dev_warn(info->dev, "Spurious Interrupt!!!\n");
 	}
 
+	mutex_lock(&info->lock);
 	info->valid = 0; /* Force updating of the cached registers */
+	mutex_unlock(&info->lock);
 
 	power_supply_changed(info->bat);
 	return IRQ_HANDLED;
@@ -486,7 +488,9 @@  static void fuel_gauge_external_power_changed(struct power_supply *psy)
 {
 	struct axp288_fg_info *info = power_supply_get_drvdata(psy);
 
+	mutex_lock(&info->lock);
 	info->valid = 0; /* Force updating of the cached registers */
+	mutex_unlock(&info->lock);
 	power_supply_changed(info->bat);
 }