|
Matthew Garrett |
70d2ada |
--- linux-2.6.35.x86_64/drivers/acpi/battery.c.orig 2010-12-23 10:42:09.291854595 -0500
|
|
Matthew Garrett |
70d2ada |
+++ linux-2.6.35.x86_64/drivers/acpi/battery.c 2010-12-23 10:44:30.996045838 -0500
|
|
Matthew Garrett |
70d2ada |
@@ -596,9 +596,10 @@
|
|
Matthew Garrett |
73ab1e4 |
}
|
|
Matthew Garrett |
73ab1e4 |
}
|
|
Matthew Garrett |
73ab1e4 |
|
|
Matthew Garrett |
73ab1e4 |
-static int acpi_battery_update(struct acpi_battery *battery)
|
|
Matthew Garrett |
73ab1e4 |
+static int acpi_battery_update(struct acpi_battery *battery, bool get_info)
|
|
Matthew Garrett |
73ab1e4 |
{
|
|
Matthew Garrett |
73ab1e4 |
int result, old_present = acpi_battery_present(battery);
|
|
Matthew Garrett |
73ab1e4 |
+ int old_power_unit = battery->power_unit;
|
|
Matthew Garrett |
73ab1e4 |
result = acpi_battery_get_status(battery);
|
|
Matthew Garrett |
73ab1e4 |
if (result)
|
|
Matthew Garrett |
73ab1e4 |
return result;
|
|
Matthew Garrett |
70d2ada |
@@ -621,6 +622,16 @@
|
|
Matthew Garrett |
73ab1e4 |
if (!battery->bat.dev)
|
|
Matthew Garrett |
73ab1e4 |
sysfs_add_battery(battery);
|
|
Matthew Garrett |
73ab1e4 |
#endif
|
|
Matthew Garrett |
73ab1e4 |
+ if (get_info) {
|
|
Matthew Garrett |
73ab1e4 |
+ acpi_battery_get_info(battery);
|
|
Matthew Garrett |
73ab1e4 |
+#ifdef CONFIG_ACPI_SYSFS_POWER
|
|
Matthew Garrett |
73ab1e4 |
+ if (old_power_unit != battery->power_unit) {
|
|
Matthew Garrett |
73ab1e4 |
+ /* The battery has changed its reporting units */
|
|
Matthew Garrett |
73ab1e4 |
+ sysfs_remove_battery(battery);
|
|
Matthew Garrett |
73ab1e4 |
+ sysfs_add_battery(battery);
|
|
Matthew Garrett |
73ab1e4 |
+ }
|
|
Matthew Garrett |
73ab1e4 |
+#endif
|
|
Matthew Garrett |
73ab1e4 |
+ }
|
|
Matthew Garrett |
70d2ada |
result = acpi_battery_get_state(battery);
|
|
Matthew Garrett |
70d2ada |
acpi_battery_quirks2(battery);
|
|
Matthew Garrett |
70d2ada |
return result;
|
|
Matthew Garrett |
70d2ada |
@@ -798,7 +809,7 @@
|
|
Matthew Garrett |
73ab1e4 |
static int acpi_battery_read(int fid, struct seq_file *seq)
|
|
Matthew Garrett |
73ab1e4 |
{
|
|
Matthew Garrett |
73ab1e4 |
struct acpi_battery *battery = seq->private;
|
|
Matthew Garrett |
73ab1e4 |
- int result = acpi_battery_update(battery);
|
|
Matthew Garrett |
73ab1e4 |
+ int result = acpi_battery_update(battery, false);
|
|
Matthew Garrett |
73ab1e4 |
return acpi_print_funcs[fid](seq, result);
|
|
Matthew Garrett |
73ab1e4 |
}
|
|
Matthew Garrett |
73ab1e4 |
|
|
Matthew Garrett |
70d2ada |
@@ -913,7 +924,8 @@
|
|
Matthew Garrett |
73ab1e4 |
#ifdef CONFIG_ACPI_SYSFS_POWER
|
|
Matthew Garrett |
73ab1e4 |
old = battery->bat.dev;
|
|
Matthew Garrett |
73ab1e4 |
#endif
|
|
Matthew Garrett |
73ab1e4 |
- acpi_battery_update(battery);
|
|
Matthew Garrett |
73ab1e4 |
+ acpi_battery_update(battery, (event == ACPI_BATTERY_NOTIFY_INFO ? true
|
|
Matthew Garrett |
73ab1e4 |
+ : false));
|
|
Matthew Garrett |
73ab1e4 |
acpi_bus_generate_proc_event(device, event,
|
|
Matthew Garrett |
73ab1e4 |
acpi_battery_present(battery));
|
|
Matthew Garrett |
73ab1e4 |
acpi_bus_generate_netlink_event(device->pnp.device_class,
|
|
Matthew Garrett |
70d2ada |
@@ -944,7 +956,7 @@
|
|
Matthew Garrett |
73ab1e4 |
if (ACPI_SUCCESS(acpi_get_handle(battery->device->handle,
|
|
Matthew Garrett |
73ab1e4 |
"_BIX", &handle)))
|
|
Matthew Garrett |
73ab1e4 |
set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags);
|
|
Matthew Garrett |
73ab1e4 |
- acpi_battery_update(battery);
|
|
Matthew Garrett |
73ab1e4 |
+ acpi_battery_update(battery, false);
|
|
Matthew Garrett |
73ab1e4 |
#ifdef CONFIG_ACPI_PROCFS_POWER
|
|
Matthew Garrett |
73ab1e4 |
result = acpi_battery_add_fs(device);
|
|
Matthew Garrett |
73ab1e4 |
#endif
|
|
Matthew Garrett |
70d2ada |
@@ -987,7 +999,7 @@
|
|
Matthew Garrett |
73ab1e4 |
return -EINVAL;
|
|
Matthew Garrett |
73ab1e4 |
battery = acpi_driver_data(device);
|
|
Matthew Garrett |
73ab1e4 |
battery->update_time = 0;
|
|
Matthew Garrett |
73ab1e4 |
- acpi_battery_update(battery);
|
|
Matthew Garrett |
73ab1e4 |
+ acpi_battery_update(battery, true);
|
|
Matthew Garrett |
73ab1e4 |
return 0;
|
|
Matthew Garrett |
73ab1e4 |
}
|
|
Matthew Garrett |
73ab1e4 |
|