From: Frank Li <Frank.li@oss.nxp.com>
To: Chancel Liu <chancel.liu@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: Thu, 17 Sep 2026 17:02:34 -0400 [thread overview]
Message-ID: <aqxVas_FftE9-pTQ@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20260916030435.4089460-1-chancel.liu@oss.nxp.com>
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
> +
> static const struct pinctrl_ops mux_pinctrl_ops = {
> .get_groups_count = pinctrl_generic_get_group_count,
> .get_group_name = pinctrl_generic_get_group_name,
> @@ -157,6 +189,10 @@ static int mux_pinctrl_probe(struct platform_device *pdev)
> if (ret)
> return dev_err_probe(dev, ret, "Failed to register pinctrl.\n");
>
> + ret = mux_pinctrl_probe_dt(mpctl->pctl, dev->of_node);
> + if (ret)
> + return ret;
> +
> ret = pinctrl_enable(mpctl->pctl);
> if (ret)
> return dev_err_probe(dev, ret, "Failed to enable pinctrl.\n");
> --
> 2.50.1
>
next prev parent reply other threads:[~2026-09-17 21:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 3:04 Chancel Liu
2026-09-16 20:23 ` Frank Li
2026-09-17 2:29 ` Chancel Liu
2026-09-17 21:02 ` Frank Li [this message]
2026-09-22 10:22 ` Chancel Liu
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=aqxVas_FftE9-pTQ@lizhi-Precision-Tower-5810 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@nxp.com \
--cc=chancel.liu@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
all inboxes | Powered by JetHome®