All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add CHARGE_NOW support to cw2015_battery.c
@ 2021-01-26 21:39 Martin Ashby
  2021-02-16 15:08 ` Tobias Schramm
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Ashby @ 2021-01-26 21:39 UTC (permalink / raw)
  To: t.schramm, linux-pm; +Cc: Martin Ashby

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(+)

diff --git a/drivers/power/supply/cw2015_battery.c b/drivers/power/supply/cw2015_battery.c
index 0146f1bfc..d11059774 100644
--- a/drivers/power/supply/cw2015_battery.c
+++ b/drivers/power/supply/cw2015_battery.c
@@ -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,
 };
 
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add CHARGE_NOW support to cw2015_battery.c
  2021-01-26 21:39 [PATCH] Add CHARGE_NOW support to cw2015_battery.c Martin Ashby
@ 2021-02-16 15:08 ` Tobias Schramm
  2021-02-16 15:30   ` Tobias Schramm
  0 siblings, 1 reply; 5+ messages in thread
From: Tobias Schramm @ 2021-02-16 15:08 UTC (permalink / raw)
  To: Martin Ashby, Sebastian Reichel; +Cc: linux-pm, linux-kernel, t.schramm

Hi Martin,

thanks for the patch. Looks good and tests fine.

> 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(+)
> 
> diff --git a/drivers/power/supply/cw2015_battery.c b/drivers/power/supply/cw2015_battery.c
> index 0146f1bfc..d11059774 100644
> --- a/drivers/power/supply/cw2015_battery.c
> +++ b/drivers/power/supply/cw2015_battery.c
> @@ -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,
>   };
>   
> 

Reviewed-by: Tobias Schramm <t.schramm@manjaro.org>
Tested-by: Tobias Schramm <t.schramm@manjaro.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add CHARGE_NOW support to cw2015_battery.c
  2021-02-16 15:08 ` Tobias Schramm
@ 2021-02-16 15:30   ` Tobias Schramm
  0 siblings, 0 replies; 5+ messages in thread
From: Tobias Schramm @ 2021-02-16 15:30 UTC (permalink / raw)
  To: Martin Ashby, Sebastian Reichel; +Cc: linux-pm, linux-kernel, Tobias Schramm

Hi Martin,

> 
> 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`.

>> 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.
>> ---
>>   drivers/power/supply/cw2015_battery.c | 6 ++++++
>>   1 file changed, 6 insertions(+)
[ ... ]
> 
> Reviewed-by: Tobias Schramm <t.schramm@manjaro.org>
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add CHARGE_NOW support to cw2015_battery.c
  2021-02-16 19:32 Martin Ashby
@ 2021-02-18 12:22 ` Tobias Schramm
  0 siblings, 0 replies; 5+ messages in thread
From: Tobias Schramm @ 2021-02-18 12:22 UTC (permalink / raw)
  To: Martin Ashby, t.schramm, linux-pm

Hi Martin,

thanks for the updated patch.

I just noticed that the patch subject is not ideal. Please have a look 
at the git log of cw2015_battery.c. You will see that the commit subject 
always starts with prefix "power: supply: cw2015:". That makes it a lot 
easier to grasp which subsystem a certain commit is about. Would you 
mind sending a v2 of your patch that does that, too?

Cheers,
Tobias

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Add CHARGE_NOW support to cw2015_battery.c
@ 2021-02-16 19:32 Martin Ashby
  2021-02-18 12:22 ` Tobias Schramm
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Ashby @ 2021-02-16 19:32 UTC (permalink / raw)
  To: t.schramm, linux-pm; +Cc: Martin Ashby

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

Signed-off-by: Martin Ashby <martin@ashbysoft.com>
---
 drivers/power/supply/cw2015_battery.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/power/supply/cw2015_battery.c b/drivers/power/supply/cw2015_battery.c
index 0146f1bfc..aa1f1771b 100644
--- a/drivers/power/supply/cw2015_battery.c
+++ b/drivers/power/supply/cw2015_battery.c
@@ -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,
 };
 
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-18 13:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-26 21:39 [PATCH] Add CHARGE_NOW support to cw2015_battery.c Martin Ashby
2021-02-16 15:08 ` Tobias Schramm
2021-02-16 15:30   ` Tobias Schramm
2021-02-16 19:32 Martin Ashby
2021-02-18 12:22 ` Tobias Schramm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.