Hi Rosen,
On Wed, 27 May 2026 at 22:23, Rosen Penev <[email protected]> wrote:
> Turn the separately allocated pinctrl_pin_desc array into a flexible
> array member of struct rza2_pinctrl_priv, annotated with
> __counted_by(npins). The pin count is now computed before allocation so
> struct_size() can size the combined object, collapsing two allocations
> into one.
>
> Change npins to unsigned int to avoid potential overflow/underflow
> errors.
>
> Assisted-by: Claude:Opus-4.7
> Signed-off-by: Rosen Penev <[email protected]>
> ---
> v2: use unsigned inr
Thanks for your patch!
> --- a/drivers/pinctrl/renesas/pinctrl-rza2.c
> +++ b/drivers/pinctrl/renesas/pinctrl-rza2.c
> @@ -289,21 +289,17 @@ static int rza2_gpio_register(struct rza2_pinctrl_priv
> *priv)
>
> static int rza2_pinctrl_register(struct rza2_pinctrl_priv *priv)
> {
> - struct pinctrl_pin_desc *pins;
> + struct pinctrl_pin_desc *pin;
I will drop pin...
> unsigned int i;
> int ret;
>
> - pins = devm_kcalloc(priv->dev, priv->npins, sizeof(*pins),
> GFP_KERNEL);
> - if (!pins)
> - return -ENOMEM;
> -
> - priv->pins = pins;
> - priv->desc.pins = pins;
> + priv->desc.pins = priv->pins;
> priv->desc.npins = priv->npins;
>
> for (i = 0; i < priv->npins; i++) {
> - pins[i].number = i;
> - pins[i].name = rza2_gpio_names[i];
> + pin = &priv->pins[i];
> + pin->number = i;
> + pin->name = rza2_gpio_names[i];
... and simplify this to
priv->pins[i].number = i;
priv->pins[i].name = rza2_gpio_names[i];
while applying.
> }
>
> ret = devm_pinctrl_register_and_init(priv->dev, &priv->desc, priv,
Reviewed-by: Geert Uytterhoeven <[email protected]>
i.e. will queue in renesas-pinctrl for v7.3, with the above fixed.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds