Skip to content

Commit

Permalink
ACPI battery: only refresh the sysfs files when pertinent information…
Browse files Browse the repository at this point in the history
… changes

We only need to regenerate the sysfs files when the capacity units
change, avoid the update otherwise.

The origin of this issue is dates way back to 2.6.38:
da8aeb9
(ACPI / Battery: Update information on info notification and resume)

cc: <stable@vger.kernel.org>
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Tested-by: Ralf Jung <post@ralfj.de>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Andy Whitcroft authored and Len Brown committed May 8, 2012
1 parent febb72a commit c597145
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/acpi/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,11 +643,19 @@ static int acpi_battery_update(struct acpi_battery *battery)

static void acpi_battery_refresh(struct acpi_battery *battery)
{
int power_unit;

if (!battery->bat.dev)
return;

power_unit = battery->power_unit;

acpi_battery_get_info(battery);
/* The battery may have changed its reporting units. */

if (power_unit == battery->power_unit)
return;

/* The battery has changed its reporting units. */
sysfs_remove_battery(battery);
sysfs_add_battery(battery);
}
Expand Down

0 comments on commit c597145

Please sign in to comment.