platform/x86: thinkpad_acpi: Fix multi-battery bug
authorThomas Weißschuh <linux@weissschuh.net>
Wed, 1 Aug 2018 22:24:18 +0000 (00:24 +0200)
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 15 Aug 2018 09:55:32 +0000 (12:55 +0300)
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@weissschuh.net>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
drivers/platform/x86/thinkpad_acpi.c

index fd49855..0a118f4 100644 (file)
@@ -9374,7 +9374,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
@@ -9620,6 +9622,8 @@ static const struct tpacpi_quirk battery_quirk_table[] __initconst = {
 
 static int __init tpacpi_battery_init(struct ibm_init_struct *ibm)
 {
+       memset(&battery_info, 0, sizeof(battery_info));
+
        tp_features.battery_force_primary = tpacpi_check_quirks(
                                        battery_quirk_table,
                                        ARRAY_SIZE(battery_quirk_table));