From: Andre Przywara <andre.przywara@arm.com>
To: Pablo Mazzini <pmazzini@gmail.com>
Cc: Linus Walleij <linusw@kernel.org>, Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pinctrl: sunxi: dt: do not accumulate npins across probe attempts
Date: Wed, 7 Oct 2026 01:23:37 +0200 [thread overview]
Message-ID: <20261007012337.6765eae7@ryzen.lan> (raw)
In-Reply-To: <20261006210313.43163-1-pmazzini@gmail.com>
On Tue, 6 Oct 2026 22:03:13 +0100
Pablo Mazzini <pmazzini@gmail.com> wrote:
Hi Pablo,
> init_pins_table() adds to npins in the driver's static descriptor, so
> after a probe deferral the count doubles and the next probe fails with
> "pin 0 already registered". Count into a local instead.
Can't we just initialise desc->npins to 0, at the beginning of
init_pins_table? I think Sashiko suggested that even...
Cheers,
Andre
>
> Signed-off-by: Pablo Mazzini <pmazzini@gmail.com>
> ---
> drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c b/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c
> index 50a16f3bd131..1c1888394cf1 100644
> --- a/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c
> +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c
> @@ -75,7 +75,7 @@ static struct sunxi_desc_pin *init_pins_table(struct device *dev,
> struct sunxi_pinctrl_desc *desc)
> {
> struct sunxi_desc_pin *pins, *cur_pin;
> - int name_size = 0;
> + int name_size = 0, npins = 0;
> int port_base = desc->pin_base / PINS_PER_BANK;
> char *pin_names, *cur_name;
> int i, j;
> @@ -85,7 +85,7 @@ static struct sunxi_desc_pin *init_pins_table(struct device *dev,
> * Also work out how much memory we need to store all the pin names.
> */
> for (i = 0; i < SUNXI_PINCTRL_MAX_BANKS; i++) {
> - desc->npins += pins_per_bank[i];
> + npins += pins_per_bank[i];
> if (pins_per_bank[i] < 10) {
> /* 4 bytes for "PXy\0" */
> name_size += pins_per_bank[i] * 4;
> @@ -98,12 +98,14 @@ static struct sunxi_desc_pin *init_pins_table(struct device *dev,
> }
> }
>
> - if (desc->npins == 0) {
> + if (npins == 0) {
> dev_err(dev, "no ports defined\n");
> return ERR_PTR(-EINVAL);
> }
>
> - pins = devm_kcalloc(dev, desc->npins, sizeof(*pins), GFP_KERNEL);
> + desc->npins = npins;
> +
> + pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
> if (!pins)
> return ERR_PTR(-ENOMEM);
>
next prev parent reply other threads:[~2026-10-06 23:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 21:03 [PATCH] pinctrl: sunxi: dt: do not accumulate npins across probe attempts Pablo Mazzini
2026-10-06 23:23 ` Andre Przywara [this message]
2026-10-07 5:58 ` Pablo Mazzini
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=20261007012337.6765eae7@ryzen.lan \
--to=andre.przywara@arm.com \
--cc=jernej.skrabec@gmail.com \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=pmazzini@gmail.com \
--cc=samuel@sholland.org \
--cc=wens@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.