[PATCH 1/1] platform/x86: thinkpad_acpi: Fix multi-battery bug

Kai-Heng Feng kai.heng.feng at canonical.com
Wed Feb 27 14:23:17 UTC 2019


From: Thomas Weißschuh <linux at weissschuh.net>

The struct containing the supported operations for all batteries is
being zeroed on each battery probe.  This prevents all other batteries
except the lastly probed one from being configured.

Signed-off-by: Thomas Weißschuh <linux at weissschuh.net>
Signed-off-by: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
(backported from commit d22296d9c38fd29a96bb5079fb8d17cee278f40e)
Signed-off-by: Kai-Heng Feng <kai.heng.feng at canonical.com>
---
 drivers/platform/x86/thinkpad_acpi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index cae9b0595692..11ac3db7039a 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -9365,7 +9365,9 @@ static int tpacpi_battery_probe(int battery)
 {
 	int ret = 0;
 
-	memset(&battery_info, 0, sizeof(struct tpacpi_battery_driver_data));
+	memset(&battery_info.batteries[battery], 0,
+		sizeof(battery_info.batteries[battery]));
+
 	/*
 	 * 1) Get the current start threshold
 	 * 2) Check for support
@@ -9598,6 +9600,8 @@ static struct acpi_battery_hook battery_hook = {
 
 static int __init tpacpi_battery_init(struct ibm_init_struct *ibm)
 {
+	memset(&battery_info, 0, sizeof(battery_info));
+
 	battery_hook_register(&battery_hook);
 	return 0;
 }
-- 
2.17.1




More information about the kernel-team mailing list