diff mbox series

[2/7] power: supply: cpcap-battery: Fix low battery check

Message ID 20190407181254.64537-3-tony@atomide.com (mailing list archive)
State New, archived
Headers show
Series Some fixes and improvments for cpcap battery and charger | expand

Commit Message

Tony Lindgren April 7, 2019, 6:12 p.m. UTC
We need to check current instead of the charge counter to see if
a charger is connected. The charge counter shows the cumulated value
instead of the current charge current and can be negative or positive.

Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/power/supply/cpcap-battery.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Pavel Machek May 5, 2019, 7:14 p.m. UTC | #1
On Sun 2019-04-07 11:12:49, Tony Lindgren wrote:
> We need to check current instead of the charge counter to see if
> a charger is connected. The charge counter shows the cumulated value
> instead of the current charge current and can be negative or positive.
> 

Acked-by: Pavel Machek <pavel@ucw.cz>

> Signed-off-by: Tony Lindgren <tony@atomide.com>


> ---
>  drivers/power/supply/cpcap-battery.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c
> --- a/drivers/power/supply/cpcap-battery.c
> +++ b/drivers/power/supply/cpcap-battery.c
> @@ -562,11 +562,11 @@ static irqreturn_t cpcap_battery_irq_thread(int irq, void *data)
>  
>  	switch (d->action) {
>  	case CPCAP_BATTERY_IRQ_ACTION_BATTERY_LOW:
> -		if (latest->counter_uah >= 0)
> +		if (latest->current_ua >= 0)
>  			dev_warn(ddata->dev, "Battery low at 3.3V!\n");
>  		break;
>  	case CPCAP_BATTERY_IRQ_ACTION_POWEROFF:
> -		if (latest->counter_uah >= 0) {
> +		if (latest->current_ua >= 0) {
>  			dev_emerg(ddata->dev,
>  				  "Battery empty at 3.1V, powering off\n");
>  			orderly_poweroff(true);
diff mbox series

Patch

diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c
--- a/drivers/power/supply/cpcap-battery.c
+++ b/drivers/power/supply/cpcap-battery.c
@@ -562,11 +562,11 @@  static irqreturn_t cpcap_battery_irq_thread(int irq, void *data)
 
 	switch (d->action) {
 	case CPCAP_BATTERY_IRQ_ACTION_BATTERY_LOW:
-		if (latest->counter_uah >= 0)
+		if (latest->current_ua >= 0)
 			dev_warn(ddata->dev, "Battery low at 3.3V!\n");
 		break;
 	case CPCAP_BATTERY_IRQ_ACTION_POWEROFF:
-		if (latest->counter_uah >= 0) {
+		if (latest->current_ua >= 0) {
 			dev_emerg(ddata->dev,
 				  "Battery empty at 3.1V, powering off\n");
 			orderly_poweroff(true);