mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pinctrl: sunxi: dt: do not accumulate npins across probe attempts
@ 2026-10-06 21:03 Pablo Mazzini
  2026-10-06 23:23 ` Andre Przywara
  0 siblings, 1 reply; 2+ messages in thread
From: Pablo Mazzini @ 2026-10-06 21:03 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Andre Przywara,
	linux-gpio, linux-arm-kernel, linux-sunxi, linux-kernel,
	Pablo Mazzini

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.

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);
 
-- 
2.52.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] pinctrl: sunxi: dt: do not accumulate npins across probe attempts
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Andre Przywara @ 2026-10-06 23:23 UTC (permalink / raw)
  To: Pablo Mazzini
  Cc: Linus Walleij, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
	linux-gpio, linux-arm-kernel, linux-sunxi, linux-kernel

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);
>  


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-06 23:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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®