power: supply: charger-manager: fix the wrong status of health
diff mbox series

Message ID 20210116114120.3531-1-angkery@163.com
State Accepted
Commit 95b78d53706d3866c232e4f4819ad38a88f148d4
Headers show
Series
  • power: supply: charger-manager: fix the wrong status of health
Related show

Commit Message

angkery Jan. 16, 2021, 11:41 a.m. UTC
From: Junlin Yang <yangjunlin@yulong.com>

cm->emergency_stop will only be the value in the enumeration,
and can not be less than zero, it will get an exception value.
So replace it with the corresponding value.

Signed-off-by: Junlin Yang <yangjunlin@yulong.com>
---
 drivers/power/supply/charger-manager.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Sebastian Reichel Jan. 16, 2021, 2:03 p.m. UTC | #1
Hi,

On Sat, Jan 16, 2021 at 07:41:20PM +0800, angkery wrote:
> From: Junlin Yang <yangjunlin@yulong.com>
> 
> cm->emergency_stop will only be the value in the enumeration,
> and can not be less than zero, it will get an exception value.
> So replace it with the corresponding value.
> 
> Signed-off-by: Junlin Yang <yangjunlin@yulong.com>
> ---

Thanks, queued.

-- Sebastian

>  drivers/power/supply/charger-manager.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c
> index 6fcebe4..0d28741 100644
> --- a/drivers/power/supply/charger-manager.c
> +++ b/drivers/power/supply/charger-manager.c
> @@ -723,9 +723,9 @@ static int charger_get_property(struct power_supply *psy,
>  		val->intval = cm->battery_status;
>  		break;
>  	case POWER_SUPPLY_PROP_HEALTH:
> -		if (cm->emergency_stop > 0)
> +		if (cm->emergency_stop == CM_BATT_OVERHEAT)
>  			val->intval = POWER_SUPPLY_HEALTH_OVERHEAT;
> -		else if (cm->emergency_stop < 0)
> +		else if (cm->emergency_stop == CM_BATT_COLD)
>  			val->intval = POWER_SUPPLY_HEALTH_COLD;
>  		else
>  			val->intval = POWER_SUPPLY_HEALTH_GOOD;
> -- 
> 1.9.1
> 
>

Patch
diff mbox series

diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c
index 6fcebe4..0d28741 100644
--- a/drivers/power/supply/charger-manager.c
+++ b/drivers/power/supply/charger-manager.c
@@ -723,9 +723,9 @@  static int charger_get_property(struct power_supply *psy,
 		val->intval = cm->battery_status;
 		break;
 	case POWER_SUPPLY_PROP_HEALTH:
-		if (cm->emergency_stop > 0)
+		if (cm->emergency_stop == CM_BATT_OVERHEAT)
 			val->intval = POWER_SUPPLY_HEALTH_OVERHEAT;
-		else if (cm->emergency_stop < 0)
+		else if (cm->emergency_stop == CM_BATT_COLD)
 			val->intval = POWER_SUPPLY_HEALTH_COLD;
 		else
 			val->intval = POWER_SUPPLY_HEALTH_GOOD;