re-create ACPI battery sysfs files on resume from suspend
Fixes the upstream changes to the dropped acpi-update-battery-information-on-notification-0x81.patch.
This commit is contained in:
		
							parent
							
								
									e8c0dae39e
								
							
						
					
					
						commit
						1121f6ddf0
					
				| @ -0,0 +1,89 @@ | |||||||
|  | From lenb@kernel.org Wed Mar 23 03:07:45 2011 | ||||||
|  | From: Len Brown <lenb@kernel.org> | ||||||
|  | To: linux-acpi@vger.kernel.org | ||||||
|  | Cc: Kyle McMartin <kyle@redhat.com>, Len Brown <len.brown@intel.com> | ||||||
|  | Subject: [PATCH 35/42] ACPI battery: fribble sysfs files from a resume notifier | ||||||
|  | Date: Wed, 23 Mar 2011 02:42:48 -0400 | ||||||
|  | 
 | ||||||
|  | From: Kyle McMartin <kyle@redhat.com> | ||||||
|  | 
 | ||||||
|  | Commit da8aeb92 re-poked the battery on resume, but Linus reports that | ||||||
|  | it broke his eee and partially reverted it in b23fffd7. Unfortunately | ||||||
|  | this also results in my x201s giving crack values until the sysfs files | ||||||
|  | are poked again. In the revert message, it was suggested that we poke it | ||||||
|  | from a PM notifier, so let's do that. | ||||||
|  | 
 | ||||||
|  | With this in place, I haven't noticed the units going nutty on my | ||||||
|  | gnome-power-manager across a dozen suspends or so... | ||||||
|  | 
 | ||||||
|  | Signed-off-by: Kyle McMartin <kyle@redhat.com> | ||||||
|  | Acked-by: Rafael J. Wysocki <rjw@sisk.pl> | ||||||
|  | Signed-off-by: Len Brown <len.brown@intel.com> | ||||||
|  | ---
 | ||||||
|  |  drivers/acpi/battery.c |   22 ++++++++++++++++++++++ | ||||||
|  |  1 files changed, 22 insertions(+), 0 deletions(-) | ||||||
|  | 
 | ||||||
|  | diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
 | ||||||
|  | index ac1a599..fcc13ac 100644
 | ||||||
|  | --- a/drivers/acpi/battery.c
 | ||||||
|  | +++ b/drivers/acpi/battery.c
 | ||||||
|  | @@ -33,6 +33,7 @@
 | ||||||
|  |  #include <linux/async.h> | ||||||
|  |  #include <linux/dmi.h> | ||||||
|  |  #include <linux/slab.h> | ||||||
|  | +#include <linux/suspend.h>
 | ||||||
|  |   | ||||||
|  |  #ifdef CONFIG_ACPI_PROCFS_POWER | ||||||
|  |  #include <linux/proc_fs.h> | ||||||
|  | @@ -102,6 +103,7 @@ struct acpi_battery {
 | ||||||
|  |  	struct mutex lock; | ||||||
|  |  	struct power_supply bat; | ||||||
|  |  	struct acpi_device *device; | ||||||
|  | +	struct notifier_block pm_nb;
 | ||||||
|  |  	unsigned long update_time; | ||||||
|  |  	int rate_now; | ||||||
|  |  	int capacity_now; | ||||||
|  | @@ -940,6 +942,21 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event)
 | ||||||
|  |  		power_supply_changed(&battery->bat); | ||||||
|  |  } | ||||||
|  |   | ||||||
|  | +static int battery_notify(struct notifier_block *nb,
 | ||||||
|  | +			       unsigned long mode, void *_unused)
 | ||||||
|  | +{
 | ||||||
|  | +	struct acpi_battery *battery = container_of(nb, struct acpi_battery,
 | ||||||
|  | +						    pm_nb);
 | ||||||
|  | +	switch (mode) {
 | ||||||
|  | +	case PM_POST_SUSPEND:
 | ||||||
|  | +		sysfs_remove_battery(battery);
 | ||||||
|  | +		sysfs_add_battery(battery);
 | ||||||
|  | +		break;
 | ||||||
|  | +	}
 | ||||||
|  | +
 | ||||||
|  | +	return 0;
 | ||||||
|  | +}
 | ||||||
|  | +
 | ||||||
|  |  static int acpi_battery_add(struct acpi_device *device) | ||||||
|  |  { | ||||||
|  |  	int result = 0; | ||||||
|  | @@ -972,6 +989,10 @@ static int acpi_battery_add(struct acpi_device *device)
 | ||||||
|  |  #endif | ||||||
|  |  		kfree(battery); | ||||||
|  |  	} | ||||||
|  | +
 | ||||||
|  | +	battery->pm_nb.notifier_call = battery_notify;
 | ||||||
|  | +	register_pm_notifier(&battery->pm_nb);
 | ||||||
|  | +
 | ||||||
|  |  	return result; | ||||||
|  |  } | ||||||
|  |   | ||||||
|  | @@ -982,6 +1003,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
 | ||||||
|  |  	if (!device || !acpi_driver_data(device)) | ||||||
|  |  		return -EINVAL; | ||||||
|  |  	battery = acpi_driver_data(device); | ||||||
|  | +	unregister_pm_notifier(&battery->pm_nb);
 | ||||||
|  |  #ifdef CONFIG_ACPI_PROCFS_POWER | ||||||
|  |  	acpi_battery_remove_fs(device); | ||||||
|  |  #endif | ||||||
|  | -- 
 | ||||||
|  | 1.7.4.1.343.ga91df | ||||||
|  | 
 | ||||||
| @ -640,6 +640,7 @@ Patch390: linux-2.6-defaults-acpi-video.patch | |||||||
| Patch391: linux-2.6-acpi-video-dos.patch | Patch391: linux-2.6-acpi-video-dos.patch | ||||||
| Patch393: acpi-ec-add-delay-before-write.patch | Patch393: acpi-ec-add-delay-before-write.patch | ||||||
| Patch394: linux-2.6-acpi-debug-infinite-loop.patch | Patch394: linux-2.6-acpi-debug-infinite-loop.patch | ||||||
|  | Patch399: acpi_battery-fribble-sysfs-files-from-a-resume-notifier.patch | ||||||
| 
 | 
 | ||||||
| Patch450: linux-2.6-input-kill-stupid-messages.patch | Patch450: linux-2.6-input-kill-stupid-messages.patch | ||||||
| Patch452: linux-2.6.30-no-pcspkr-modalias.patch | Patch452: linux-2.6.30-no-pcspkr-modalias.patch | ||||||
| @ -1215,6 +1216,7 @@ ApplyPatch linux-2.6-defaults-acpi-video.patch | |||||||
| ApplyPatch linux-2.6-acpi-video-dos.patch | ApplyPatch linux-2.6-acpi-video-dos.patch | ||||||
| ApplyPatch acpi-ec-add-delay-before-write.patch | ApplyPatch acpi-ec-add-delay-before-write.patch | ||||||
| ApplyPatch linux-2.6-acpi-debug-infinite-loop.patch | ApplyPatch linux-2.6-acpi-debug-infinite-loop.patch | ||||||
|  | ApplyPatch acpi_battery-fribble-sysfs-files-from-a-resume-notifier.patch | ||||||
| 
 | 
 | ||||||
| # Various low-impact patches to aid debugging. | # Various low-impact patches to aid debugging. | ||||||
| ApplyPatch linux-2.6-debug-sizeof-structs.patch | ApplyPatch linux-2.6-debug-sizeof-structs.patch | ||||||
| @ -1954,6 +1956,11 @@ fi | |||||||
| # and build. | # and build. | ||||||
| 
 | 
 | ||||||
| %changelog | %changelog | ||||||
|  | * Wed Mar 23 2011 Kyle McMartin <kmcmartin@redhat.com> | ||||||
|  | - Re-create ACPI battery sysfs files on resume from suspend, fixes the | ||||||
|  |   upstream changes to the dropped | ||||||
|  |   acpi-update-battery-information-on-notification-0x81.patch. | ||||||
|  | 
 | ||||||
| * Wed Mar 23 2011 Kyle McMartin <kmcmartin@redhat.com> | * Wed Mar 23 2011 Kyle McMartin <kmcmartin@redhat.com> | ||||||
| - Update to 2.6.38-git12 | - Update to 2.6.38-git12 | ||||||
| - Enable I2C_DIOLAN_U2C USB i2c adapter [all], I2C_PXA [i686]. | - Enable I2C_DIOLAN_U2C USB i2c adapter [all], I2C_PXA [i686]. | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user