reform2-lpc: Charge current is not reported, discharge current reported as charge current
According to https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-power current_now
reports negative values for discharging battery current, and positive values for charging battery current, but looking at
https://source.mnt.re/reform/reform-tools/-/blob/main/lpc/reform2_lpc.c?ref_type=heads#L490-494 charging current is not reported at all.
Not sure if that will break backward compatibility with battery monitor work, but in my understanding current should be reported in following way:
diff --git a/lpc/reform2_lpc.c b/lpc/reform2_lpc.c
index c4f2fac..28e9786 100644
--- a/lpc/reform2_lpc.c
+++ b/lpc/reform2_lpc.c
@@ -487,10 +487,13 @@ static int get_bat_property(struct power_supply *psy,
if (milliamp < -20000 || milliamp >= 20000)
return -EBUSY;
- /* negative current, battery is charging
- reporting a negative value is out of spec */
- if (milliamp < 0)
- milliamp = 0;
+ /* negative current reported, battery is charging
+ * positive current reported, battery is discharging
+ *
+ * power-supply sysfs ABI requires charging battery to
+ * be reported as positive current and discharging battery
+ * to be reported as negative current */
+ milliamp = -milliamp;
val->intval = milliamp * 1000;
break;