Re: [PATCH 03/15] power: supply: cpcap-battery: Fix battery low status reporting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Arthur Demchenkov <spinal.by@xxxxxxxxx> [200315 15:15]:
> If we hit battery low once, we should stick on reporting it until the
> charger is connected. This way low->counter_uah will be updated
> properly, and that will allow us to get more accurate charge_full value.
> 
> Signed-off-by: Arthur Demchenkov <spinal.by@xxxxxxxxx>
> ---
>  drivers/power/supply/cpcap-battery.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c
> index 52f03a2662a5..8a58ad943960 100644
> --- a/drivers/power/supply/cpcap-battery.c
> +++ b/drivers/power/supply/cpcap-battery.c
> @@ -421,11 +421,14 @@ static bool cpcap_battery_full(struct cpcap_battery_ddata *ddata)
>  static bool cpcap_battery_low(struct cpcap_battery_ddata *ddata)
>  {
>  	struct cpcap_battery_state_data *state = cpcap_battery_latest(ddata);
> +	static bool is_low;
>  
> -	if (state->current_ua && state->voltage <= 3300000)
> -		return true;
> +	if (state->current_ua > 0 && (state->voltage <= 3300000 || is_low))
> +		is_low = true;
> +	else
> +		is_low = false;
>  
> -	return false;
> +	return is_low;
>  }

Please set up bitmask in ddata for unsigned int battery_low:1; instead of
using a static variable here. If we ever had two instances of cpcap on the
same device the static variable here would not work :)

Regards,

Tony




[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux