[PATCH v2] power: supply: pf1550: enable charging when battery profile exists

raoxu posted 1 patch 11 hours ago
drivers/power/supply/pf1550-charger.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] power: supply: pf1550: enable charging when battery profile exists
Posted by raoxu 11 hours ago
From: Xu Rao <raoxu@uniontech.com>

PF1550 starts in charger mode 1, where charging is disabled. The driver
comment says that mode 2 should be selected for applications using a
battery, but the condition is inverted: PF1550_CHG_BAT_ON is written only
when power_supply_get_battery_info() fails.

Consequently, a board with a valid monitored-battery profile is left in
the default charger-off mode, while a board without battery information
enables charging with fallback settings.

Select mode 2 when battery information is available.

Fixes: 4b6b6433a97d ("power: supply: pf1550: add battery charger support")
Cc: stable@vger.kernel.org
Signed-off-by: Xu Rao <raoxu@uniontech.com>
---
Changes in v2:
- Drop power_supply_put_battery_info() calls because static battery
  profiles are not devm allocated.
- Leave the pre-existing handling of an unspecified constant charge
  voltage for a separate fix.

 drivers/power/supply/pf1550-charger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/pf1550-charger.c b/drivers/power/supply/pf1550-charger.c
index 41036f4cb64a..38cac156d2e6 100644
--- a/drivers/power/supply/pf1550-charger.c
+++ b/drivers/power/supply/pf1550-charger.c
@@ -514,7 +514,7 @@ static int pf1550_reg_init(struct pf1550_charger *chg)
 	 * a battery. The other supported mode is mode 2, the charger is turned
 	 * on to charge a battery when present.
 	 */
-	if (power_supply_get_battery_info(chg->charger, &info)) {
+	if (!power_supply_get_battery_info(chg->charger, &info)) {
 		ret = regmap_write(chg->pf1550->regmap,
 				   PF1550_CHARG_REG_CHG_OPER,
 				   PF1550_CHG_BAT_ON);
--
2.50.1
Re: [PATCH v2] power: supply: pf1550: enable charging when battery profile exists
Posted by Frank Li 6 hours ago
On Fri, Jul 24, 2026 at 05:54:37PM +0800, raoxu wrote:
> [You don't often get email from raoxu@uniontech.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> From: Xu Rao <raoxu@uniontech.com>
>
> PF1550 starts in charger mode 1, where charging is disabled. The driver
> comment says that mode 2 should be selected for applications using a
> battery, but the condition is inverted: PF1550_CHG_BAT_ON is written only
> when power_supply_get_battery_info() fails.
>
> Consequently, a board with a valid monitored-battery profile is left in
> the default charger-off mode, while a board without battery information
> enables charging with fallback settings.
>
> Select mode 2 when battery information is available.
>
> Fixes: 4b6b6433a97d ("power: supply: pf1550: add battery charger support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Xu Rao <raoxu@uniontech.com>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

> Changes in v2:
> - Drop power_supply_put_battery_info() calls because static battery
>   profiles are not devm allocated.
> - Leave the pre-existing handling of an unspecified constant charge
>   voltage for a separate fix.
>
>  drivers/power/supply/pf1550-charger.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/power/supply/pf1550-charger.c b/drivers/power/supply/pf1550-charger.c
> index 41036f4cb64a..38cac156d2e6 100644
> --- a/drivers/power/supply/pf1550-charger.c
> +++ b/drivers/power/supply/pf1550-charger.c
> @@ -514,7 +514,7 @@ static int pf1550_reg_init(struct pf1550_charger *chg)
>          * a battery. The other supported mode is mode 2, the charger is turned
>          * on to charge a battery when present.
>          */
> -       if (power_supply_get_battery_info(chg->charger, &info)) {
> +       if (!power_supply_get_battery_info(chg->charger, &info)) {
>                 ret = regmap_write(chg->pf1550->regmap,
>                                    PF1550_CHARG_REG_CHG_OPER,
>                                    PF1550_CHG_BAT_ON);
> --
> 2.50.1
>