Skip to content

Commit

Permalink
power: supply: axp288_fuel_gauge: Take lock before updating the valid…
Browse files Browse the repository at this point in the history
… flag

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>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
  • Loading branch information
Hans de Goede authored and Sebastian Reichel committed Feb 1, 2022
1 parent 05972f5 commit 30abb3d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/power/supply/axp288_fuel_gauge.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down

0 comments on commit 30abb3d

Please sign in to comment.