]> err.no Git - linux-2.6/commitdiff
ACPI: SBS: Return rate in mW if capacity in mWh
authorAlexey Starikovskiy <astarikovskiy@suse.de>
Sat, 8 Dec 2007 10:02:46 +0000 (13:02 +0300)
committerLen Brown <len.brown@intel.com>
Fri, 14 Dec 2007 20:14:23 +0000 (15:14 -0500)
klaptopd assumes rate to be in same units as capacity.

http://bugzilla.kernel.org/show_bug.cgi?id=9362

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
drivers/acpi/sbs.c

index 813ef328f743201a6597fc712cc7133937fe14d5..22cb95b349e49835be4b28599b23864634b13221 100644 (file)
@@ -533,7 +533,7 @@ static struct proc_dir_entry *acpi_battery_dir = NULL;
 
 static inline char *acpi_battery_units(struct acpi_battery *battery)
 {
-       return acpi_battery_mode(battery) ? " mWh" : " mAh";
+       return acpi_battery_mode(battery) ? " mW" : " mA";
 }
 
 
@@ -550,10 +550,10 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
        if (!battery->present)
                goto end;
 
-       seq_printf(seq, "design capacity:         %i%s\n",
+       seq_printf(seq, "design capacity:         %i%sh\n",
                   battery->design_capacity * acpi_battery_scale(battery),
                   acpi_battery_units(battery));
-       seq_printf(seq, "last full capacity:      %i%s\n",
+       seq_printf(seq, "last full capacity:      %i%sh\n",
                   battery->full_charge_capacity * acpi_battery_scale(battery),
                   acpi_battery_units(battery));
        seq_printf(seq, "battery technology:      rechargeable\n");
@@ -584,7 +584,7 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
 {
        struct acpi_battery *battery = seq->private;
        struct acpi_sbs *sbs = battery->sbs;
-       int result = 0;
+       int rate;
 
        mutex_lock(&sbs->lock);
        seq_printf(seq, "present:                 %s\n",
@@ -598,9 +598,12 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
        seq_printf(seq, "charging state:          %s\n",
                   (battery->current_now < 0) ? "discharging" :
                   ((battery->current_now > 0) ? "charging" : "charged"));
-       seq_printf(seq, "present rate:            %d mA\n",
-                  abs(battery->current_now) * acpi_battery_ipscale(battery));
-       seq_printf(seq, "remaining capacity:      %i%s\n",
+       rate = abs(battery->current_now) * acpi_battery_ipscale(battery);
+       rate *= (acpi_battery_mode(battery))?(battery->voltage_now *
+                       acpi_battery_vscale(battery)/1000):1;
+       seq_printf(seq, "present rate:            %d%s\n", rate,
+                  acpi_battery_units(battery));
+       seq_printf(seq, "remaining capacity:      %i%sh\n",
                   battery->capacity_now * acpi_battery_scale(battery),
                   acpi_battery_units(battery));
        seq_printf(seq, "present voltage:         %i mV\n",
@@ -608,7 +611,7 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
 
       end:
        mutex_unlock(&sbs->lock);
-       return result;
+       return 0;
 }
 
 static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
@@ -632,7 +635,7 @@ static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
        acpi_battery_get_alarm(battery);
        seq_printf(seq, "alarm:                   ");
        if (battery->alarm_capacity)
-               seq_printf(seq, "%i%s\n",
+               seq_printf(seq, "%i%sh\n",
                           battery->alarm_capacity *
                           acpi_battery_scale(battery),
                           acpi_battery_units(battery));