diff options
author | Alexey Starikovskiy <aystarik@gmail.com> | 2008-11-21 09:41:01 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2008-11-26 17:23:10 -0500 |
commit | 558073dd56707864f09d563b64e7c37c021e89d2 (patch) | |
tree | 0dcf13ad7676da7ac229b58a758546a70849cbe0 /drivers | |
parent | 7b4d469228a92a00e412675817cedd60133de38a (diff) |
ACPI: battery: Convert discharge energy rate to current properly
ACPI battery interface reports its state either in mW or in mA, and
discharge rate in your case is reported in mW. power_supply interface
does not have such a parameter, so current_now parameter is used
for all cases. But in case of mW, reported discharge should
be converted into mA.
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Tested-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/acpi/battery.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 1423b0c0cd2e..a0a178dd189c 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -174,6 +174,15 @@ static int acpi_battery_get_property(struct power_supply *psy, | |||
174 | break; | 174 | break; |
175 | case POWER_SUPPLY_PROP_CURRENT_NOW: | 175 | case POWER_SUPPLY_PROP_CURRENT_NOW: |
176 | val->intval = battery->current_now * 1000; | 176 | val->intval = battery->current_now * 1000; |
177 | /* if power units are mW, convert to mA by | ||
178 | dividing by current voltage (mV/1000) */ | ||
179 | if (!battery->power_unit) { | ||
180 | if (battery->voltage_now) { | ||
181 | val->intval /= battery->voltage_now; | ||
182 | val->intval *= 1000; | ||
183 | } else | ||
184 | val->intval = -1; | ||
185 | } | ||
177 | break; | 186 | break; |
178 | case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: | 187 | case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: |
179 | case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: | 188 | case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: |