From: Conor Dooley <conor@kernel.org>
To: Frank Li <Frank.Li@nxp.com>
Cc: "Peter Rosin" <peda@axentia.se>,
"Linus Walleij" <linusw@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Rafał Miłecki" <rafal@milecki.pl>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
devicetree@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
"Haibo Chen" <haibo.chen@nxp.com>
Subject: Re: [PATCH v4 3/7] pinctrl: extract pinctrl_generic_to_map() from pinctrl_generic_pins_function_dt_node_to_map()
Date: Thu, 26 Mar 2026 18:55:01 +0000 [thread overview]
Message-ID: <20260326-poncho-expanse-d30a9eded8e2@spud> (raw)
In-Reply-To: <20260326-concur-eel-3e0b3d91e00a@spud>
[-- Attachment #1: Type: text/plain, Size: 4792 bytes --]
On Thu, Mar 26, 2026 at 06:52:12PM +0000, Conor Dooley wrote:
> On Wed, Mar 25, 2026 at 07:04:12PM -0400, Frank Li wrote:
>
> > diff --git a/drivers/pinctrl/pinctrl-generic.c b/drivers/pinctrl/pinctrl-generic.c
> > index efb39c6a670331775855efdc8566102b5c6202ef..20a216ae63e91b69985ea4cfcd0b57103c6ca950 100644
> > --- a/drivers/pinctrl/pinctrl-generic.c
> > +++ b/drivers/pinctrl/pinctrl-generic.c
> > @@ -17,29 +17,18 @@
> > #include "pinctrl-utils.h"
> > #include "pinmux.h"
> >
> > -static int pinctrl_generic_pins_function_dt_subnode_to_map(struct pinctrl_dev *pctldev,
>
> > +int
> > +pinctrl_generic_to_map(struct pinctrl_dev *pctldev, struct device_node *parent,
>
> Can you drop this stylistic change please? The
Whoops, cut myself off. To be clear, what I am asking for is to keep the
"int" etc on the same line as the function name. This function is new,
but you did it for the existing function too and the comparison is here.
>
> > + struct device_node *np, struct pinctrl_map **maps,
> > + unsigned int *num_maps, unsigned int *num_reserved_maps,
> > + const char **group_names, unsigned int ngroups,
> > + const char **functions, unsigned int *pins)
> > {
> > struct device *dev = pctldev->dev;
> > - const char **functions;
> > + int npins, ret, reserve = 1;
> > + unsigned int num_configs;
> > const char *group_name;
> > unsigned long *configs;
> > - unsigned int num_configs, pin, *pins;
> > - int npins, ret, reserve = 1;
> > -
> > - npins = of_property_count_u32_elems(np, "pins");
> > -
> > - if (npins < 1) {
> > - dev_err(dev, "invalid pinctrl group %pOFn.%pOFn %d\n",
> > - parent, np, npins);
> > - return npins;
> > - }
> >
> > group_name = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", parent, np);
> > if (!group_name)
> > @@ -51,22 +40,6 @@ static int pinctrl_generic_pins_function_dt_subnode_to_map(struct pinctrl_dev *p
> > if (!pins)
> > return -ENOMEM;
>
> This looks suspect. You've left the pins allocation behind:
> pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
> if (!pins)
> return -ENOMEM;
> but pinctrl_generic_pins_function_dt_subnode_to_map() has already
> populated this array before calling the function.
>
> Also, this should probably be
> Suggested-by: Conor Dooley <conor.dooley@microchip.com>
>
> Cheers,
> Conor.
>
> >
> > - functions = devm_kcalloc(dev, npins, sizeof(*functions), GFP_KERNEL);
> > - if (!functions)
> > - return -ENOMEM;
> > -
> > - for (int i = 0; i < npins; i++) {
> > - ret = of_property_read_u32_index(np, "pins", i, &pin);
> > - if (ret)
> > - return ret;
> > -
> > - pins[i] = pin;
> > -
> > - ret = of_property_read_string(np, "function", &functions[i]);
> > - if (ret)
> > - return ret;
> > - }
> > -
> > ret = pinctrl_utils_reserve_map(pctldev, maps, num_reserved_maps, num_maps, reserve);
> > if (ret)
> > return ret;
> > @@ -103,6 +76,54 @@ static int pinctrl_generic_pins_function_dt_subnode_to_map(struct pinctrl_dev *p
> > return 0;
> > };
> >
> > +static int
> > +pinctrl_generic_pins_function_dt_subnode_to_map(struct pinctrl_dev *pctldev,
> > + struct device_node *parent,
> > + struct device_node *np,
> > + struct pinctrl_map **maps,
> > + unsigned int *num_maps,
> > + unsigned int *num_reserved_maps,
> > + const char **group_names,
> > + unsigned int ngroups)
> > +{
> > + struct device *dev = pctldev->dev;
> > + unsigned int pin, *pins;
> > + const char **functions;
> > + int npins, ret;
> > +
> > + npins = of_property_count_u32_elems(np, "pins");
> > +
> > + if (npins < 1) {
> > + dev_err(dev, "invalid pinctrl group %pOFn.%pOFn %d\n",
> > + parent, np, npins);
> > + return npins;
> > + }
> > +
> > + pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
> > + if (!pins)
> > + return -ENOMEM;
> > +
> > + functions = devm_kcalloc(dev, npins, sizeof(*functions), GFP_KERNEL);
> > + if (!functions)
> > + return -ENOMEM;
> > +
> > + for (int i = 0; i < npins; i++) {
> > + ret = of_property_read_u32_index(np, "pins", i, &pin);
> > + if (ret)
> > + return ret;
> > +
> > + pins[i] = pin;
> > +
> > + ret = of_property_read_string(np, "function", &functions[i]);
> > + if (ret)
> > + return ret;
> > + }
> > +
> > + return pinctrl_generic_to_map(pctldev, parent, np, maps, num_maps,
> > + num_reserved_maps, group_names, ngroups,
> > + functions, pins);
> > +}
> > +
> > /*
> > * For platforms that do not define groups or functions in the driver, but
> > * instead use the devicetree to describe them. This function will, unlike
> >
> > --
> > 2.43.0
> >
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-03-26 18:55 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-25 23:04 [PATCH v4 0/7] pinctrl: Add generic pinctrl for board-level mux chips Frank Li
2026-03-25 23:04 ` [PATCH v4 1/7] mux: add devm_mux_control_get_from_np() to get mux from child node Frank Li
2026-03-25 23:04 ` [PATCH v4 2/7] dt-bindings: pinctrl: Add generic pinctrl for board-level mux chips Frank Li
2026-03-25 23:04 ` [PATCH v4 3/7] pinctrl: extract pinctrl_generic_to_map() from pinctrl_generic_pins_function_dt_node_to_map() Frank Li
2026-03-26 18:52 ` Conor Dooley
2026-03-26 18:55 ` Conor Dooley [this message]
2026-03-26 19:47 ` Frank Li
2026-03-27 0:06 ` Conor Dooley
2026-03-27 0:09 ` Conor Dooley
2026-03-27 16:54 ` Frank Li
2026-03-27 17:14 ` Conor Dooley
2026-03-25 23:04 ` [PATCH v4 4/7] pinctrl: add optional .release_mux() callback Frank Li
2026-03-25 23:04 ` [PATCH v4 5/7] pinctrl: add generic board-level pinctrl driver using mux framework Frank Li
2026-03-25 23:04 ` [PATCH v4 6/7] arm64: dts: imx8mp-evk: add board-level mux for CAN2 and MICFIL Frank Li
2026-03-25 23:04 ` [PATCH v4 7/7] arm64: dts: imx8mp-evk: add flexcan2 overlay file Frank Li
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=20260326-poncho-expanse-d30a9eded8e2@spud \
--to=conor@kernel.org \
--cc=Frank.Li@nxp.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=haibo.chen@nxp.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peda@axentia.se \
--cc=rafal@milecki.pl \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
/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