diff options
author | Lucas Rangit Magasweran <lucas.magasweran@ieee.org> | 2018-07-14 15:40:18 -0700 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2018-07-24 11:22:03 +0200 |
commit | 82f2d30570b7ecdf1ce7e6376805f063ae86a7e5 (patch) | |
tree | 85558698e99f0701f9cb488ac62e403e43ee2354 /drivers/acpi | |
parent | 9d3cce1e8b8561fed5f383d22a4d6949db4eadbe (diff) | |
download | linux-82f2d30570b7ecdf1ce7e6376805f063ae86a7e5.tar.bz2 |
ACPI: battery: remove redundant old_present check on insertion
On removal battery_present changes from 1 to 0 after calling
acpi_battery_get_status() and battery->update_time is set to 0
before returning.
On insertion battery_present changes from 0 to 1 after calling
acpi_battery_get_status() and acpi_battery_get_info() is called
because battery->update_time is 0.
The old_present condition is therefore redundant.
This was added in the commit below when there was a path without
sysfs that would skip getting the newly inserted battery info.
commit 50b178512b7d ("Newly inserted battery might differ from one
just removed, so update of battery info fields is required.")
Signed-off-by: Lucas Rangit Magasweran <lucas.magasweran@ieee.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/battery.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index d79ad844c78f..78e40a9f5e18 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -918,10 +918,11 @@ static void acpi_battery_quirks(struct acpi_battery *battery) static int acpi_battery_update(struct acpi_battery *battery, bool resume) { - int result, old_present = acpi_battery_present(battery); - result = acpi_battery_get_status(battery); + int result = acpi_battery_get_status(battery); + if (result) return result; + if (!acpi_battery_present(battery)) { sysfs_remove_battery(battery); battery->update_time = 0; @@ -931,8 +932,7 @@ static int acpi_battery_update(struct acpi_battery *battery, bool resume) if (resume) return 0; - if (!battery->update_time || - old_present != acpi_battery_present(battery)) { + if (!battery->update_time) { result = acpi_battery_get_info(battery); if (result) return result; |