Oneiric SRU: Phantom battery appears after resume from suspend

Submitted by Tim Gardner on Nov. 18, 2011, 2:18 p.m.

Details

Message ID 20111118141849.87B92F88D3@lochsa.rtg.net
State New
Headers show

Commit Message

Tim Gardner Nov. 18, 2011, 2:18 p.m.
From 67d3ca0df4bf7cb82d8459417e0b99090bbc0c92 Mon Sep 17 00:00:00 2001
From: Lan Tianyu <tianyu.lan@intel.com>
Date: Thu, 30 Jun 2011 11:33:58 +0800
Subject: [PATCH] ACPI / Battery: Add the check before refresh sysfs in the battery_notify()

BugLink: http://bugs.launchpad.net/bugs/852406

In the commit 25be5821, add the refresh sysfs when system resumes
from suspending. But it didn't check that the battery exists. This
will cause battery sysfs files added when the battery doesn't exist.
This patch add the check before refreshing.

	https://bugzilla.kernel.org/show_bug.cgi?id=35642

Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
(cherry picked from commit 6e17fb6aa1a67afa1827ae317c3594040f055730)

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 drivers/acpi/battery.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

Comments

Herton Ronaldo Krzesinski Nov. 18, 2011, 3:03 p.m.
On Fri, Nov 18, 2011 at 07:18:49AM -0700, Tim Gardner wrote:
> From 67d3ca0df4bf7cb82d8459417e0b99090bbc0c92 Mon Sep 17 00:00:00 2001
> From: Lan Tianyu <tianyu.lan@intel.com>
> Date: Thu, 30 Jun 2011 11:33:58 +0800
> Subject: [PATCH] ACPI / Battery: Add the check before refresh sysfs in the battery_notify()
> 
> BugLink: http://bugs.launchpad.net/bugs/852406
> 
> In the commit 25be5821, add the refresh sysfs when system resumes
> from suspending. But it didn't check that the battery exists. This
> will cause battery sysfs files added when the battery doesn't exist.
> This patch add the check before refreshing.
> 
> 	https://bugzilla.kernel.org/show_bug.cgi?id=35642
> 
> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
> Signed-off-by: Len Brown <len.brown@intel.com>
> (cherry picked from commit 6e17fb6aa1a67afa1827ae317c3594040f055730)
> 
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>

Acked-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>

> ---
>  drivers/acpi/battery.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index 929f5e8..1cf8434 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -949,8 +949,10 @@ static int battery_notify(struct notifier_block *nb,
>  						    pm_nb);
>  	switch (mode) {
>  	case PM_POST_SUSPEND:
> -		sysfs_remove_battery(battery);
> -		sysfs_add_battery(battery);
> +		if (battery->bat.dev) {
> +			sysfs_remove_battery(battery);
> +			sysfs_add_battery(battery);
> +		}
>  		break;
>  	}
>  
> -- 
> 1.7.0.4
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
>
Seth Forshee Nov. 18, 2011, 3:49 p.m.
On Fri, Nov 18, 2011 at 07:18:49AM -0700, Tim Gardner wrote:
> From 67d3ca0df4bf7cb82d8459417e0b99090bbc0c92 Mon Sep 17 00:00:00 2001
> From: Lan Tianyu <tianyu.lan@intel.com>
> Date: Thu, 30 Jun 2011 11:33:58 +0800
> Subject: [PATCH] ACPI / Battery: Add the check before refresh sysfs in the battery_notify()
> 
> BugLink: http://bugs.launchpad.net/bugs/852406
> 
> In the commit 25be5821, add the refresh sysfs when system resumes
> from suspending. But it didn't check that the battery exists. This
> will cause battery sysfs files added when the battery doesn't exist.
> This patch add the check before refreshing.
> 
> 	https://bugzilla.kernel.org/show_bug.cgi?id=35642
> 
> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
> Signed-off-by: Len Brown <len.brown@intel.com>
> (cherry picked from commit 6e17fb6aa1a67afa1827ae317c3594040f055730)
> 
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>

Acked-by: Seth Forshee <seth.forshee@canonical.com>

> ---
>  drivers/acpi/battery.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index 929f5e8..1cf8434 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -949,8 +949,10 @@ static int battery_notify(struct notifier_block *nb,
>  						    pm_nb);
>  	switch (mode) {
>  	case PM_POST_SUSPEND:
> -		sysfs_remove_battery(battery);
> -		sysfs_add_battery(battery);
> +		if (battery->bat.dev) {
> +			sysfs_remove_battery(battery);
> +			sysfs_add_battery(battery);
> +		}
>  		break;
>  	}
>  
> -- 
> 1.7.0.4
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
Tim Gardner Nov. 18, 2011, 3:58 p.m.
On 11/18/2011 09:18 AM, Tim Gardner wrote:
>  From 67d3ca0df4bf7cb82d8459417e0b99090bbc0c92 Mon Sep 17 00:00:00 2001
> From: Lan Tianyu<tianyu.lan@intel.com>
> Date: Thu, 30 Jun 2011 11:33:58 +0800
> Subject: [PATCH] ACPI / Battery: Add the check before refresh sysfs in the battery_notify()
>
> BugLink: http://bugs.launchpad.net/bugs/852406
>
> In the commit 25be5821, add the refresh sysfs when system resumes
> from suspending. But it didn't check that the battery exists. This
> will cause battery sysfs files added when the battery doesn't exist.
> This patch add the check before refreshing.
>
> 	https://bugzilla.kernel.org/show_bug.cgi?id=35642
>
> Signed-off-by: Lan Tianyu<tianyu.lan@intel.com>
> Signed-off-by: Len Brown<len.brown@intel.com>
> (cherry picked from commit 6e17fb6aa1a67afa1827ae317c3594040f055730)
>
> Signed-off-by: Tim Gardner<tim.gardner@canonical.com>
> ---
>   drivers/acpi/battery.c |    6 ++++--
>   1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index 929f5e8..1cf8434 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -949,8 +949,10 @@ static int battery_notify(struct notifier_block *nb,
>   						    pm_nb);
>   	switch (mode) {
>   	case PM_POST_SUSPEND:
> -		sysfs_remove_battery(battery);
> -		sysfs_add_battery(battery);
> +		if (battery->bat.dev) {
> +			sysfs_remove_battery(battery);
> +			sysfs_add_battery(battery);
> +		}
>   		break;
>   	}
>

Patch hide | download patch | download mbox

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 929f5e8..1cf8434 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -949,8 +949,10 @@  static int battery_notify(struct notifier_block *nb,
 						    pm_nb);
 	switch (mode) {
 	case PM_POST_SUSPEND:
-		sysfs_remove_battery(battery);
-		sysfs_add_battery(battery);
+		if (battery->bat.dev) {
+			sysfs_remove_battery(battery);
+			sysfs_add_battery(battery);
+		}
 		break;
 	}