[PATCH v2] pinctrl: single: parse gpio-range as a raw array (O(N^2) -> O(N))
Anshul Dalal
anshuld at ti.com
Thu Jul 9 08:31:02 CEST 2026
On Thu, 25 Jun 2026 19:41:21 +0200, Jordi Trepat Mur <yordy1902 at gmail.com> wrote:
> diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
> index 42980e097e0d..0029a7e1a279 100644
> --- a/drivers/pinctrl/pinctrl-single.c
> +++ b/drivers/pinctrl/pinctrl-single.c
> @@ -509,29 +509,74 @@ static int single_add_gpio_func(struct udevice *dev)
> [ ... skip 17 lines ... ]
> + * The original loop called ofnode_parse_phandle_with_args() once per
> + * entry. On a flat DT each call resolves the phandle, which scans the
> + * whole tree, so the repeated parse is quadratic in the number of
> + * entries and proportional to the tree size. This is very slow
> + * pre-relocation with caches off.
> + *
Nit- Why reference the prior code in the comment, it would just be confusing for
people reading it in the future.
> + * The phandle target is not used here (only the argument cells are
> + * stored), so resolve it only for the first entry to learn the
> + * per-entry cell count, then read the argument cells directly. This
> + * follows the existing pinctrl-single,gpio-range usage observed in
> + * current DTs, where entries use the same provider and therefore a
> + * uniform per-entry cell count.
> + */
> + ret = ofnode_parse_phandle_with_args(node, propname, cellname, 0, 0,
> + &gpiospec);
> + if (ret)
> + return 0;
> + if (gpiospec.args_count != 3)
> + return 0;
This could just be if (ret || gpiospec.args_count != 3)
Otherwise the patch looks good to me.
--
Anshul Dalal <anshuld at ti.com>
More information about the U-Boot
mailing list