power: supply: document current direction
authorSebastian Reichel <sebastian.reichel@collabora.com>
Thu, 27 Aug 2020 14:02:48 +0000 (16:02 +0200)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Sat, 3 Oct 2020 10:46:22 +0000 (12:46 +0200)
Currently the sign for CURRENT_NOW and CURRENT_AVG is a bit
of a mess. There are basically 3 different ways battery fuel
gauges report the current:

1. uses negative values for discharging and positive values
   for charging
2. uses positive values for discharging and negative values
   for discharging (opposit of 1)
3. only uses positive values

As a result userspace currently cannot use the sign at all in
a generic way. Let's solve the issue by documenting a canonical
way for reporting the data and ensure new drivers follow this
way. Then existing drivers can be fixed on a case-by-case basis.

The 'negative value = battery discharging' has been choosen,
since there are only very few drivers doing it the other way
around.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Documentation/ABI/testing/sysfs-class-power

index 651599f..dbccb2f 100644 (file)
@@ -108,7 +108,8 @@ Description:
                which they average readings to smooth out the reported value.
 
                Access: Read
-               Valid values: Represented in microamps
+               Valid values: Represented in microamps. Negative values are used
+               for discharging batteries, positive values for charging batteries.
 
 What:          /sys/class/power_supply/<supply_name>/current_max
 Date:          October 2010
@@ -127,7 +128,8 @@ Description:
                This value is not averaged/smoothed.
 
                Access: Read
-               Valid values: Represented in microamps
+               Valid values: Represented in microamps. Negative values are used
+               for discharging batteries, positive values for charging batteries.
 
 What:          /sys/class/power_supply/<supply_name>/charge_control_limit
 Date:          Oct 2012