mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Rosin <peda@lysator.liu.se>
To: Maxwell Doose <m32285159@gmail.com>
Cc: open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mux: core: Replace manual put_device() with __free(put_device)
Date: Tue, 2 Jun 2026 11:03:45 +0200	[thread overview]
Message-ID: <a4ab4a72-a41c-4322-be18-53778cb3fef2@lysator.liu.se> (raw)
In-Reply-To: <20260602043610.333426-1-m32285159@gmail.com>

Hi!

On 2026-06-02 06:36, Maxwell Doose wrote:
> The current code for returning on failure in mux_get() uses manual
> put_device() calls. Refactor and replace them with a new variable for
> the pointer to the underlying device and __free(put_device).
> 
> Signed-off-by: Maxwell Doose <m32285159@gmail.com>
> ---
>   drivers/mux/core.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/mux/core.c b/drivers/mux/core.c
> index 23538de2c91b..a31e06388588 100644
> --- a/drivers/mux/core.c
> +++ b/drivers/mux/core.c
> @@ -586,13 +586,13 @@ static struct mux_control *mux_get(struct device *dev, const char *mux_name,
>   	if (!mux_chip)
>   		return ERR_PTR(-EPROBE_DEFER);
>   
> +	struct device *mux_dev __free(put_device) = &mux_chip->dev;

This will also run put_device() on success, which IIUC is broken.
I'm not sure it makes sense to use __free() when the exit behavior
is conditional like this?

Cheers,
Peter

>   	controller = 0;
>   	if (state) {
>   		if (args.args_count > 2 || args.args_count == 0 ||
>   		    (args.args_count < 2 && mux_chip->controllers > 1)) {
>   			dev_err(dev, "%pOF: wrong #mux-state-cells for %pOF\n",
>   				np, args.np);
> -			put_device(&mux_chip->dev);
>   			return ERR_PTR(-EINVAL);
>   		}
>   
> @@ -608,7 +608,6 @@ static struct mux_control *mux_get(struct device *dev, const char *mux_name,
>   		    (!args.args_count && mux_chip->controllers > 1)) {
>   			dev_err(dev, "%pOF: wrong #mux-control-cells for %pOF\n",
>   				np, args.np);
> -			put_device(&mux_chip->dev);
>   			return ERR_PTR(-EINVAL);
>   		}
>   
> @@ -619,7 +618,6 @@ static struct mux_control *mux_get(struct device *dev, const char *mux_name,
>   	if (controller >= mux_chip->controllers) {
>   		dev_err(dev, "%pOF: bad mux controller %u specified in %pOF\n",
>   			np, controller, args.np);
> -		put_device(&mux_chip->dev);
>   		return ERR_PTR(-EINVAL);
>   	}
>   


  reply	other threads:[~2026-06-02  9:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-02  4:36 Maxwell Doose
2026-06-02  9:03 ` Peter Rosin [this message]
2026-06-02 16:17   ` Maxwell Doose

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=a4ab4a72-a41c-4322-be18-53778cb3fef2@lysator.liu.se \
    --to=peda@lysator.liu.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m32285159@gmail.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

all inboxes | Powered by JetHome®