Skip to contentSkip to conversation

Add CHARGE_NOW support to cw2015_battery.c

PATCH In review Martin Ashby 2 participants 3 messages Jan 27, 2021 – Feb 16, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add CHARGE_NOW support to cw2015_battery.c

CHARGE_NOW is expected by some user software (such as waybar) instead of 'CAPACITY', in order to correctly calculate remaining battery life.

---
 drivers/power/supply/cw2015_battery.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/power/supply/cw2015_battery.c +6 -0
index 0146f1bfc..d11059774 100644
@@ -511,6 +511,11 @@ static int cw_battery_get_property(struct power_supply *psy,
 			val->intval = 0;
 		break;
 
+	case POWER_SUPPLY_PROP_CHARGE_NOW:
+		val->intval = cw_bat->battery.charge_full_design_uah;
+		val->intval = val->intval * cw_bat->soc / 100;
+		break;
+
 	case POWER_SUPPLY_PROP_CURRENT_NOW:
 		if (cw_battery_valid_time_to_empty(cw_bat) &&
 		    cw_bat->battery.charge_full_design_uah > 0) {
@@ -542,6 +547,7 @@ static enum power_supply_property cw_battery_properties[] = {
 	POWER_SUPPLY_PROP_CHARGE_COUNTER,
 	POWER_SUPPLY_PROP_CHARGE_FULL,
 	POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
+	POWER_SUPPLY_PROP_CHARGE_NOW,
 	POWER_SUPPLY_PROP_CURRENT_NOW,
 };
 
Signature · 1 line
2.30.0
maintainer Reviewed-by Tested-by on v1 1/1
#1 lore raw

Hi Martin,

thanks for the patch. Looks good and tests fine.

Quoted 26 lines

CHARGE_NOW is expected by some user software (such as waybar) instead of 'CAPACITY', in order to correctly calculate remaining battery life.

---
  drivers/power/supply/cw2015_battery.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/power/supply/cw2015_battery.c +5 -0
index 0146f1bfc..d11059774 100644
@@ -511,6 +511,11 @@ static int cw_battery_get_property(struct power_supply *psy,
  			val->intval = 0;
  		break;
 
+	case POWER_SUPPLY_PROP_CHARGE_NOW:
+		val->intval = cw_bat->battery.charge_full_design_uah;
+		val->intval = val->intval * cw_bat->soc / 100;
+		break;
+
  	case POWER_SUPPLY_PROP_CURRENT_NOW:
  		if (cw_battery_valid_time_to_empty(cw_bat) &&
  		    cw_bat->battery.charge_full_design_uah > 0) {

drivers/power/supply/cw2015_battery.c static enum power_supply_property cw_battery_properties[] = { · line 553

Quoted 7 lines
drivers/power/supply/cw2015_battery.c +1 -0
@@ -542,6 +547,7 @@ static enum power_supply_property cw_battery_properties[] = {
  	POWER_SUPPLY_PROP_CHARGE_COUNTER,
  	POWER_SUPPLY_PROP_CHARGE_FULL,
  	POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
+	POWER_SUPPLY_PROP_CHARGE_NOW,
  	POWER_SUPPLY_PROP_CURRENT_NOW,
  };
 
maintainer
#2 lore raw

Hi Martin,

Quoted 3 lines

thanks for the patch. Looks good and tests fine.

eh, scratch that. Didn't have my cup of morning coffee yet. The patch is fine as far as the code change goes. However it is missing a "Signed-off-by" line, certifying your authorship. git can generate that automagically for you with git commit --signoff.

Quoted 4 lines
Quoted 4 lines

CHARGE_NOW is expected by some user software (such as waybar) instead of 'CAPACITY', in order to correctly calculate remaining battery life.

There needs to be a "Signed-off-by" line right here.

Quoted 3 lines
Quoted 3 lines

---
  drivers/power/supply/cw2015_battery.c | 6 ++++++

  1 file changed, 6 insertions(+)

[ ... ]

Quoted 2 lines

Review retracted.

Please resend the patch with the "Signed-off-by" line included. Then I can mark it as reviewed.

Sorry for the confusion,

Tobias Schramm