diff options
author | Tony Lindgren <tony@atomide.com> | 2019-10-16 15:30:04 -0700 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2019-10-20 20:26:14 +0200 |
commit | 639c1524da3b273d20c42ff2387d08eb4b12e903 (patch) | |
tree | bf0c52edcb2be0854237a25618ae0d26490aa96b /drivers/power | |
parent | 8bc8fc088bcd9da7ff565620a2778def59902404 (diff) |
power: supply: cpcap-battery: Check voltage before orderly_poweroff
We can get the low voltage interrupt trigger sometimes way too early,
maybe because of CPU load spikes. This causes orderly_poweroff() be
called too easily.
Let's check the voltage before orderly_poweroff in case it was not
yet a permanent condition. We will be getting more interrupts anyways
if the condition persists.
Let's also show the measured voltages for low battery and battery
empty warnings since we have them.
Cc: Merlijn Wajer <merlijn@wizzup.org>
Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/supply/cpcap-battery.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c index 61d6447d1966..00a96e4a1cdc 100644 --- a/drivers/power/supply/cpcap-battery.c +++ b/drivers/power/supply/cpcap-battery.c @@ -562,12 +562,14 @@ static irqreturn_t cpcap_battery_irq_thread(int irq, void *data) switch (d->action) { case CPCAP_BATTERY_IRQ_ACTION_BATTERY_LOW: if (latest->current_ua >= 0) - dev_warn(ddata->dev, "Battery low at 3.3V!\n"); + dev_warn(ddata->dev, "Battery low at %imV!\n", + latest->voltage / 1000); break; case CPCAP_BATTERY_IRQ_ACTION_POWEROFF: - if (latest->current_ua >= 0) { + if (latest->current_ua >= 0 && latest->voltage <= 3200000) { dev_emerg(ddata->dev, - "Battery empty at 3.1V, powering off\n"); + "Battery empty at %imV, powering off\n", + latest->voltage / 1000); orderly_poweroff(true); } break; |