Skip to contentSkip to conversation

pinctrl: mcp23s08: fix irq setup order

PATCH In review Dmitry Mastykin 3 participants 4 messages Dec 28, 2017 – Jan 8, 2018

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

PATCH 1/1 pinctrl: mcp23s08: fix irq setup order

When using mcp23s08 module with gpio-keys, often (50% of boots) it fails to get irq numbers with message:
"gpio-keys keys: Unable to get irq number for GPIO 0, error -6". Seems that irqs must be setup before devm_gpiochip_add_data().

---
 drivers/pinctrl/pinctrl-mcp23s08.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pinctrl/pinctrl-mcp23s08.c +4 -4
index 9c950bbf..447763a 100644
@@ -891,16 +891,16 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
 			goto fail;
 	}
 
-	ret = devm_gpiochip_add_data(dev, &mcp->chip, mcp);
-	if (ret < 0)
-		goto fail;
-
 	if (mcp->irq && mcp->irq_controller) {
 		ret = mcp23s08_irq_setup(mcp);
 		if (ret)
 			goto fail;
 	}
 
+	ret = devm_gpiochip_add_data(dev, &mcp->chip, mcp);
+	if (ret < 0)
+		goto fail;
+
 	mcp->pinctrl_desc.name = "mcp23xxx-pinctrl";
 	mcp->pinctrl_desc.pctlops = &mcp_pinctrl_ops;
 	mcp->pinctrl_desc.confops = &mcp_pinconf_ops;
Signature · 1 line
2.7.4
#1 lore raw
Quoted 6 lines · Dmitry Mastykin

When using mcp23s08 module with gpio-keys, often (50% of boots) it fails to get irq numbers with message:
"gpio-keys keys: Unable to get irq number for GPIO 0, error -6". Seems that irqs must be setup before devm_gpiochip_add_data().

Patch applied, albeit for devel.

Should it be tagged for stable or go into fixes?

Yours,
Linus Walleij

#2 lore raw
Quoted 5 lines · Linus Walleij

Patch applied, albeit for devel.

Should it be tagged for stable or go into fixes?

Thank you very much, Linus!
About tags, please do as it convenient for you.

Kind regards,
Dmitry

Quoted 8 lines · Dmitry Mastykin
Quoted 7 lines

When using mcp23s08 module with gpio-keys, often (50% of boots) it fails to get irq numbers with message:
"gpio-keys keys: Unable to get irq number for GPIO 0, error -6". Seems that irqs must be setup before devm_gpiochip_add_data().

#3 lore raw
In reply to Linus Walleij
Quoted 7 lines · Linus Walleij
Quoted 5 lines · Dmitry Mastykin

When using mcp23s08 module with gpio-keys, often (50% of boots) it fails to get irq numbers with message:
"gpio-keys keys: Unable to get irq number for GPIO 0, error -6". Seems that irqs must be setup before devm_gpiochip_add_data().

Quoted 6 lines
Quoted 1 line

Patch applied, albeit for devel.

Should it be tagged for stable or go into fixes?

I'm no expert on this one, but looking at other drivers they're using a mixture of ordering for irq setup and devm_gpiochip_add_data() calls.

But should probably go into stable if it is the fix.

Signature · 2 lines
Regards
Phil Reid