mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fabio <development@redaril.me>
To: "Alvin Šipraga" <alvin.sipraga@analog.com>,
	"Fabio Forni" <development@redaril.me>
Cc: Peter Rosin <peda@lysator.liu.se>,
	Linus Walleij <linusw@kernel.org>,
	linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
	xu.yang_2@nxp.com
Subject: Re: [PATCH v2] mux: convert to use fwnode interface
Date: Sat, 26 Sep 2026 12:00:03 +0200	[thread overview]
Message-ID: <b16be8d9-eadf-47df-86b6-4a982c665f9f@redaril.me> (raw)
In-Reply-To: <araS8BpKyYI-nkxM@analog.com>

>> @@ -566,39 +569,40 @@ static struct mux_control *mux_get(struct device *dev, const char *mux_name,
>>   	}
>>   
>>   	if (state)
>> -		ret = of_parse_phandle_with_args(np,
>> -						 "mux-states", "#mux-state-cells",
>> -						 index, &args);
>> +		ret = fwnode_property_get_reference_args(fwnode, "mux-states",
>> +							 "#mux-state-cells", 0,
>> +							 index, &args);
>>   	else
>> -		ret = of_parse_phandle_with_args(np,
>> -						 "mux-controls", "#mux-control-cells",
>> -						 index, &args);
>> +		ret = fwnode_property_get_reference_args(fwnode,
>> +							 "mux-controls", "#mux-control-cells",
>> +							 0, index, &args);
>> +
>>   	if (ret) {
>>   		if (optional && ret == -ENOENT)
>>   			return NULL;
>>   
>> -		dev_err(dev, "%pOF: failed to get mux-%s %s(%i)\n",
>> -			np, state ? "state" : "control",
>> -			mux_name ?: "", index);
>> +		dev_err(dev, "%pfw: failed to get mux-%s %s(%i)\n",
>> +			fwnode, state ? "state" : "control", mux_name ?: "",
>> +			index);
>>   		return ERR_PTR(ret);
>>   	}
>>   
>> -	mux_chip = of_find_mux_chip_by_node(args.np);
>> -	of_node_put(args.np);
>> +	mux_chip = mux_chip_find_by_fwnode(args.fwnode);
>> +	fwnode_handle_put(args.fwnode);
> 
> I'm actually not sure why there was an of_node_put() here in the first
> place. It seems wrong to me. Any idea what it's for?
> 
> I want to give a Reviewed-by here for the rest of the code, but if the
> above _put() erroneous, it might be better to add a patch before this
> one to remove it (and cc the stable list with that patch).

I don't think it's wrong, because fwnode_property_get_reference_args() documents that:

     The caller is responsible for calling fwnode_handle_put() on the returned
     @args->fwnode pointer.

What is wrong though, is passing args.fwnode to the dev_err() calls below after it was freed.
Or that's what I'm inclined to say; I doubt put() would free everything but fwnode's name.
If I had to guess, fwnode_handle_put is (erroneously) where it is to avoid gotos/calling mux_chip_find_by_fwnode()
in the sad path.

If you agree with the above, I'll be happy to write a patch to fix it.

Regards,
Fabio.



  reply	other threads:[~2026-09-26 10:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 17:26 Fabio Forni via B4 Relay
2026-09-23 21:24 ` Fabio
2026-09-25 15:37 ` Alvin Šipraga
2026-09-26 10:00   ` Fabio [this message]
2026-09-29  7:59     ` Alvin Šipraga

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=b16be8d9-eadf-47df-86b6-4a982c665f9f@redaril.me \
    --to=development@redaril.me \
    --cc=alvin.sipraga@analog.com \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peda@lysator.liu.se \
    --cc=xu.yang_2@nxp.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®