]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/acpi/battery.c
ACPI: battery: Convert discharge energy rate to current properly
[linux-2.6-omap-h63xx.git] / drivers / acpi / battery.c
index 1423b0c0cd2eecc6e3c7b2f5c78746cee5fac4eb..a0a178dd189c3259fcc82f323b6c4011fe1442a4 100644 (file)
@@ -174,6 +174,15 @@ static int acpi_battery_get_property(struct power_supply *psy,
                break;
        case POWER_SUPPLY_PROP_CURRENT_NOW:
                val->intval = battery->current_now * 1000;
+               /* if power units are mW, convert to mA by
+                  dividing by current voltage (mV/1000) */
+               if (!battery->power_unit) {
+                       if (battery->voltage_now) {
+                               val->intval /= battery->voltage_now;
+                               val->intval *= 1000;
+                       } else
+                               val->intval = -1;
+               }
                break;
        case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
        case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: