Skip to contentSkip to conversation

pinctrl: sunxi: dt: do not accumulate npins across probe attempts

PATCH In review Pablo Mazzini 3 participants 3 messages Oct 7 – Oct 12

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 pinctrl: sunxi: dt: do not accumulate npins across probe attempts

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". Reset it first.

---
v2: reset npins instead of counting into a local (Andre)

 drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c +1 -0
index 50a16f3bd131..8bcd566593ae 100644
@@ -84,6 +84,7 @@ static struct sunxi_desc_pin *init_pins_table(struct device *dev,
 	 * Find the total number of pins.
 	 * Also work out how much memory we need to store all the pin names.
 	 */
+	desc->npins = 0;
 	for (i = 0; i < SUNXI_PINCTRL_MAX_BANKS; i++) {
 		desc->npins += pins_per_bank[i];
 		if (pins_per_bank[i] < 10) {
Signature · 1 line
2.52.0
Reviewed-by on v2 1/1
#1 lore raw

Hi,

Quoted 3 lines · 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". Reset it first.

Yes, thanks, this is what I had in mind. And I think it deserves some backports:

Quoted 1 line
Fixes f5e2cd34b12f ("pinctrl: sunxi: allow reading mux values from DT")

Cheers,
Andre

Quoted 18 lines

---
v2: reset npins instead of counting into a local (Andre)

  drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c | 1 +
  1 file changed, 1 insertion(+)
drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c +1 -0
index 50a16f3bd131..8bcd566593ae 100644
@@ -84,6 +84,7 @@ static struct sunxi_desc_pin *init_pins_table(struct device *dev,
  	 * Find the total number of pins.
  	 * Also work out how much memory we need to store all the pin names.
  	 */
+	desc->npins = 0;
  	for (i = 0; i < SUNXI_PINCTRL_MAX_BANKS; i++) {
  		desc->npins += pins_per_bank[i];
  		if (pins_per_bank[i] < 10) {
maintainer
#2 lore raw
In reply to Pablo Mazzini
Quoted 7 lines · 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". Reset it first.

---
v2: reset npins instead of counting into a local (Andre)

Patch applied for fixes!

Yours,
Linus Walleij