diff mbox series

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

Message ID 20190227153556.13317-2-kai.heng.feng@canonical.com
State New
Headers show
Series Fix battery charge threshold writing on Thinkpads | expand

Commit Message

Kai-Heng Feng Feb. 27, 2019, 3:35 p.m. UTC
From: Thomas Weißschuh <linux@weissschuh.net>

BugLink: https://bugs.launchpad.net/bugs/1812099

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>
(backported from commit d22296d9c38fd29a96bb5079fb8d17cee278f40e)
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/platform/x86/thinkpad_acpi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Stefan Bader Feb. 27, 2019, 3:44 p.m. UTC | #1
On 27.02.19 16:35, Kai-Heng Feng wrote:
> From: Thomas Weißschuh <linux@weissschuh.net>
> 
> BugLink: https://bugs.launchpad.net/bugs/1812099
> 
> 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>
> (backported from commit d22296d9c38fd29a96bb5079fb8d17cee278f40e)
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Acked-by: Stefan Bader <stefan.bader@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;
>  }
>
diff mbox series

Patch

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;
 }