blob: 04c52a5eab02e5c27505df1efa553bba40df4cf4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
From patchwork Thu Jun 4 19:56:58 2020
From: Mathew King <mathewk@chromium.org>
To: linux-kernel@vger.kernel.org
Cc: Mathew King <mathewk@chromium.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Len Brown <lenb@kernel.org>, linux-acpi@vger.kernel.org
Subject: [PATCH] acpi: battery: Always read fresh battery state on update
Date: Thu, 4 Jun 2020 13:56:58 -0600
Message-Id: <20200604195658.66201-1-mathewk@chromium.org>
List-ID: <linux-acpi.vger.kernel.org>
X-Mailing-List: linux-acpi@vger.kernel.org
When the ACPI battery receives a notification event it should always
read the battery state fresh from the ACPI device and not use the cached
state. Currently the cached state stays valid and the new state may not
be read when a notification occurs. This can lead to a udev event
showing that the battery has changed but the sysfs state will still have
the cached state values. This change invalidates the update time forcing
the state to be updated before notifying the power_supply subsystem of
the change.
Signed-off-by: Mathew King <mathewk@chromium.org>
---
drivers/acpi/battery.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 366c389175d8..ab7fa4879fbe 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -981,6 +981,7 @@ static int acpi_battery_update(struct acpi_battery *battery, bool resume)
acpi_battery_init_alarm(battery);
}
+ battery->update_time = 0;
result = acpi_battery_get_state(battery);
if (result)
return result;
|