diff mbox series

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

Message ID 20190227142317.12503-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, 2:23 p.m. UTC
From: Thomas Weißschuh <linux@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@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:21 p.m. UTC | #1
On 27.02.19 15:23, Kai-Heng Feng wrote:
> From: Thomas Weißschuh <linux@weissschuh.net>
> 

Missing BugLink

> 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(-)
> 
> 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;
>  }
>
Kai-Heng Feng Feb. 27, 2019, 3:34 p.m. UTC | #2
> On Feb 27, 2019, at 23:21, Stefan Bader <stefan.bader@canonical.com> wrote:
> 
> On 27.02.19 15:23, Kai-Heng Feng wrote:
>> From: Thomas Weißschuh <linux@weissschuh.net>
>> 
> 
> Missing BugLink

Will send a V2.

> 
>> 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(-)
>> 
>> 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;
>> }
>> 
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
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;
 }