public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Waqar Hameed <waqar.hameed@axis.com>
Cc: kernel@axis.com, linux-pm@vger.kernel.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] power: supply: wm97xx: Use devm_power_supply_register()
Date: Mon, 12 Jan 2026 02:36:46 +0100	[thread overview]
Message-ID: <aWRPvn_BtqTb768i@venus> (raw)
In-Reply-To: <883bfa991f977dcda20f9ee6b82782850a0ab100.1766270196.git.waqar.hameed@axis.com>

[-- Attachment #1: Type: text/plain, Size: 1789 bytes --]

Hi,

On Sat, Dec 20, 2025 at 11:46:24PM +0100, Waqar Hameed wrote:
> Instead of handling the registration manually, use the automatic
> `devres` variant `devm_power_supply_register()`. This is less error
> prone and cleaner.
> 
> Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
> ---
>  drivers/power/supply/wm97xx_battery.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/power/supply/wm97xx_battery.c b/drivers/power/supply/wm97xx_battery.c
> index f00722c88c6fe..e91467dcab19c 100644
> --- a/drivers/power/supply/wm97xx_battery.c
> +++ b/drivers/power/supply/wm97xx_battery.c
> @@ -223,7 +223,7 @@ static int wm97xx_bat_probe(struct platform_device *dev)
>  	bat_psy_desc.properties = prop;
>  	bat_psy_desc.num_properties = props;
>  
> -	bat_psy = power_supply_register(&dev->dev, &bat_psy_desc, &cfg);
> +	bat_psy = devm_power_supply_register(&dev->dev, &bat_psy_desc, &cfg);
>  	if (!IS_ERR(bat_psy)) {
>  		schedule_work(&bat_work);
>  	} else {
> @@ -237,15 +237,12 @@ static int wm97xx_bat_probe(struct platform_device *dev)
>  		if (ret) {
>  			dev_err_probe(&dev->dev, ret,
>  				      "failed to request GPIO irq\n");
> -			goto unregister;
> +			goto free;
>  		}
>  	}
>  
>  	return 0;
>  
> -unregister:
> -	power_supply_unregister(bat_psy);
> -
>  free:
>  	kfree(prop);
>  
> @@ -257,7 +254,6 @@ static void wm97xx_bat_remove(struct platform_device *dev)
>  	if (charge_gpiod)
>  		free_irq(gpiod_to_irq(charge_gpiod), dev);
>  	cancel_work_sync(&bat_work);
> -	power_supply_unregister(bat_psy);
>  	kfree(prop);
>  }

This free's prop before bat_psy. You fix that in the next patch, but
to be bisectable those two patches must be swapped.

Greetings,

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2026-01-12  1:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-20 22:46 [PATCH 0/3] power: supply: wm97xx: Fix NULL pointer dereference in power_supply_changed() Waqar Hameed
2025-12-20 22:46 ` [PATCH 1/3] " Waqar Hameed
2025-12-20 22:46 ` [PATCH 2/3] power: supply: wm97xx: Use devm_power_supply_register() Waqar Hameed
2026-01-12  1:36   ` Sebastian Reichel [this message]
2026-01-14 10:51     ` Waqar Hameed
2025-12-20 22:46 ` [PATCH 3/3] power: supply: wm97xx: Use devm_kcalloc() Waqar Hameed
2026-01-12  1:56 ` (subset) [PATCH 0/3] power: supply: wm97xx: Fix NULL pointer dereference in power_supply_changed() 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=aWRPvn_BtqTb768i@venus \
    --to=sebastian.reichel@collabora.com \
    --cc=kernel@axis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=waqar.hameed@axis.com \
    /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