Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=cd1ebcc0ef620e8e7c5e399bf9e123135e4f24a4
Commit:     cd1ebcc0ef620e8e7c5e399bf9e123135e4f24a4
Parent:     804b3f9a16e446cb023417faec58b6506c834052
Author:     Anton Vorontsov <[EMAIL PROTECTED]>
AuthorDate: Fri Oct 5 01:04:59 2007 +0400
Committer:  Anton Vorontsov <[EMAIL PROTECTED]>
CommitDate: Fri Oct 5 01:04:59 2007 +0400

    apm_power: fix obviously wrong logic for time reporting
    
    Prior to this patch, apm_power was unable to report "to empty"/"to full"
    time for batteries that hardware-report these values, such as
    Apple PMU batteries.
    
    Signed-off-by: Anton Vorontsov <[EMAIL PROTECTED]>
---
 drivers/power/apm_power.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/power/apm_power.c b/drivers/power/apm_power.c
index 39a90a6..32ebfd7 100644
--- a/drivers/power/apm_power.c
+++ b/drivers/power/apm_power.c
@@ -200,19 +200,17 @@ static void apm_battery_apm_get_power_status(struct 
apm_power_info *info)
        info->units = APM_UNITS_MINS;
 
        if (status.intval == POWER_SUPPLY_STATUS_CHARGING) {
-               if (MPSY_PROP(TIME_TO_FULL_AVG, &time_to_full)) {
-                       if (MPSY_PROP(TIME_TO_FULL_NOW, &time_to_full))
-                               info->time = calculate_time(status.intval);
-                       else
-                               info->time = time_to_full.intval / 60;
-               }
+               if (!MPSY_PROP(TIME_TO_FULL_AVG, &time_to_full) ||
+                               !MPSY_PROP(TIME_TO_FULL_NOW, &time_to_full))
+                       info->time = time_to_full.intval / 60;
+               else
+                       info->time = calculate_time(status.intval);
        } else {
-               if (MPSY_PROP(TIME_TO_EMPTY_AVG, &time_to_empty)) {
-                       if (MPSY_PROP(TIME_TO_EMPTY_NOW, &time_to_empty))
-                               info->time = calculate_time(status.intval);
-                       else
-                               info->time = time_to_empty.intval / 60;
-               }
+               if (!MPSY_PROP(TIME_TO_EMPTY_AVG, &time_to_empty) ||
+                               !MPSY_PROP(TIME_TO_EMPTY_NOW, &time_to_empty))
+                       info->time = time_to_empty.intval / 60;
+               else
+                       info->time = calculate_time(status.intval);
        }
 
        up(&power_supply_class->sem);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to