Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: Chancel Liu <chancel.liu@oss.nxp.com>
To: Frank Li <Frank.li@oss.nxp.com>
Cc: linusw@kernel.org, Frank.Li@nxp.com, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pinctrl: pinctrl-generic-mux: Fix provider resource leak on re-parse
Date: Tue, 22 Sep 2026 18:22:43 +0800	[thread overview]
Message-ID: <e1b7f681-3b4f-4163-afc0-9ad0c2bb4adb@oss.nxp.com> (raw)
In-Reply-To: <aqxVas_FftE9-pTQ@lizhi-Precision-Tower-5810>

On 9/18/2026 5:02 AM, Frank Li wrote:
> On Wed, Sep 16, 2026 at 12:04:35PM +0900, Chancel Liu wrote:
>> From: Chancel Liu <chancel.liu@nxp.com>
>>
> ...
>>
>> +static int mux_pinctrl_probe_dt(struct pinctrl_dev *pctldev,
>> +				struct device_node *np)
>> +{
>> +	struct device *dev = pctldev->dev;
>> +
>> +	for_each_available_child_of_node_scoped(np, grp) {
>> +		struct mux_pin_function *function;
>> +		const char **group_names;
>> +		int ret;
>> +
>> +		function = devm_kzalloc(dev, sizeof(*function), GFP_KERNEL);
>> +		if (!function)
>> +			return -ENOMEM;
>> +
>> +		group_names = devm_kcalloc(dev, 1, sizeof(*group_names), GFP_KERNEL);
>> +		if (!group_names)
>> +			return -ENOMEM;
>> +
>> +		group_names[0] = grp->name;
>> +
>> +		function->mux_state = devm_mux_state_get_from_np(dev, NULL, grp);
>> +		if (IS_ERR(function->mux_state))
>> +			return dev_err_probe(dev, PTR_ERR(function->mux_state),
>> +					     "failed to get mux-state for %pOFn\n",
>> +					     grp);
>> +
>> +		ret = pinctrl_generic_add_group(pctldev, grp->name, NULL, 0, NULL);
>> +		if (ret < 0)
>> +			return dev_err_probe(dev, ret,
>> +					     "failed to add group %pOFn\n", grp);
>> +
>> +		ret = pinmux_generic_add_function(pctldev, grp->name, group_names,
>> +						  1, function);
>> +		if (ret < 0)
>> +			return dev_err_probe(dev, ret,
>> +					     "failed to add function %pOFn\n", grp);
>> +	}
>> +
>> +	return 0;
>> +}
> 
> This method also works, slice difference, if some pin have not used by
> consumer,  old method may save some memory.
> 
> leave to linus to decide which is better way, this one or add free() at
> .dt_free_map()
> 
> Frank

IMHO, the groups and functions of a board-level mux are static and fully
described by the devicetree, so probe time is the natural place to build
them, and dt_node_to_map() can then focus on mapping. Happy to go with
whichever Linus prefers.

Regards,
Chancel Liu


  reply	other threads:[~2026-09-22 10:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16  3:04 [PATCH] pinctrl: pinctrl-generic-mux: Fix provider resource leak on re-parse Chancel Liu
2026-09-16 20:23 ` Frank Li
2026-09-17  2:29   ` Chancel Liu
2026-09-17 21:02 ` Frank Li
2026-09-22 10:22   ` Chancel Liu [this message]
2026-10-01  7:30 ` Linus Walleij

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=e1b7f681-3b4f-4163-afc0-9ad0c2bb4adb@oss.nxp.com \
    --to=chancel.liu@oss.nxp.com \
    --cc=Frank.Li@nxp.com \
    --cc=Frank.li@oss.nxp.com \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.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