Linux Power Management development
 help / color / mirror / Atom feed
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>,
	Sebastian Reichel <sre@kernel.org>,
	Marcus Cooper <codekipper@gmail.com>
Cc: linux-pm@vger.kernel.org
Subject: Re: [PATCH 2/2] power: supply: ab8500: Exit maintenance if too low voltage
Date: Tue, 19 Apr 2022 12:44:35 +0300	[thread overview]
Message-ID: <c57fa9fd-0cdf-4392-50e8-f02671032365@gmail.com> (raw)
In-Reply-To: <36001b47-99fc-1b49-49e7-018f81b717c4@gmail.com>

On 4/19/22 12:26, Matti Vaittinen wrote:

>> --- a/drivers/power/supply/ab8500_chargalg.c
>> +++ b/drivers/power/supply/ab8500_chargalg.c
>> @@ -1514,6 +1514,14 @@ static void ab8500_chargalg_algorithm(struct 
>> ab8500_chargalg *di)
>>               ab8500_chargalg_stop_maintenance_timer(di);
>>               ab8500_chargalg_state_to(di, STATE_MAINTENANCE_B_INIT);
>>           }
>> +        /*
>> +         * This happens if the voltage drops too quickly during
>> +         * maintenance charging, especially in older batteries.
>> +         */
>> +        if (ab8500_chargalg_time_to_restart(di)) {
>> +            ab8500_chargalg_state_to(di, STATE_NORMAL_INIT);
>> +            dev_info(di->dev, "restarted charging from maintenance 
>> state A - battery getting old?\n");
>> +        }
>>           break;
>>       case STATE_MAINTENANCE_B_INIT:
>> @@ -1538,6 +1546,14 @@ static void ab8500_chargalg_algorithm(struct 
>> ab8500_chargalg *di)
>>               ab8500_chargalg_stop_maintenance_timer(di);
>>               ab8500_chargalg_state_to(di, STATE_NORMAL_INIT);
>>           }
>> +        /*
>> +         * This happens if the voltage drops too quickly during
>> +         * maintenance charging, especially in older batteries.
>> +         */
>> +        if (ab8500_chargalg_time_to_restart(di)) {
>> +            ab8500_chargalg_state_to(di, STATE_NORMAL_INIT);
>> +            dev_info(di->dev, "restarted charging from maintenance 
>> state B - battery getting old?\n");
>> +        }
>>           break;
>>       case STATE_TEMP_LOWHIGH_INIT:
> 
> 
> Probably just a matter of taste (like underscores in private function 
> names ;] ) - I would prefer combining the cases for INITs to something 
> like:
> 
>      case STATE_MAINTENANCE_A_INIT:
>      case STATE_MAINTENANCE_B_INIT:
> 
>          mt = power_supply_get_maintenance_charging_setting(bi,
>              (di->charge_state == STATE_MAINTENANCE_B_INIT));
> 
> ...
>          ab8500_chargalg_state_to(di, di->charge_state + 1);
> 
>      break;
> 
> That would slightly reduce the code although at the cost of additional 
> arithmetics. I'm leaving this to you though.

Oh. I was misreading the code. There is fallthrough and not break as the 
actual 'maintenance states' are handled directly after the 'maintenance 
init states'. Well, it seems to me also the actual maintenance states 
could be combined into one case though. But as I wrote - your decision :)

Best Regards
	-- Matti

  reply	other threads:[~2022-04-19  9:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-15 20:36 [PATCH 1/2] power: supply: ab8500: Respect charge_restart_voltage_uv Linus Walleij
2022-04-15 20:36 ` [PATCH 2/2] power: supply: ab8500: Exit maintenance if too low voltage Linus Walleij
2022-04-19  9:26   ` Matti Vaittinen
2022-04-19  9:44     ` Matti Vaittinen [this message]
2022-05-05 20:22     ` Linus Walleij
2022-04-19  8:50 ` [PATCH 1/2] power: supply: ab8500: Respect charge_restart_voltage_uv Vaittinen, Matti
2022-05-05 20:17   ` Linus Walleij
2022-05-06  5:38     ` Vaittinen, Matti
2022-05-09 10:33       ` Linus Walleij
2022-05-09 13:27         ` Vaittinen, Matti
2022-05-20 21:36 ` Linus Walleij
2022-06-09 20:12   ` Sebastian Reichel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c57fa9fd-0cdf-4392-50e8-f02671032365@gmail.com \
    --to=mazziesaccount@gmail.com \
    --cc=codekipper@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox