2017-12-28 15:20:14

by Dmitry Mastykin

[permalink] [raw]
Subject: [PATCH] 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().

Signed-off-by: Dmitry Mastykin <[email protected]>
---
drivers/pinctrl/pinctrl-mcp23s08.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c
index 9c950bbf..447763a 100644
--- a/drivers/pinctrl/pinctrl-mcp23s08.c
+++ b/drivers/pinctrl/pinctrl-mcp23s08.c
@@ -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;
--
2.7.4


2018-01-02 09:10:10

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH] pinctrl: mcp23s08: fix irq setup order

On Thu, Dec 28, 2017 at 4:19 PM, Dmitry Mastykin <[email protected]> wrote:

> 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().
>
> Signed-off-by: Dmitry Mastykin <[email protected]>

Patch applied, albeit for devel.

Should it be tagged for stable or go into fixes?

Yours,
Linus Walleij

2018-01-03 12:49:35

by Dmitry Mastykin

[permalink] [raw]
Subject: Re: [PATCH] pinctrl: mcp23s08: fix irq setup order

On Tue, Jan 2, 2018 at 12:10 PM, Linus Walleij <[email protected]> wrote:
>
> 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

> On Thu, Dec 28, 2017 at 4:19 PM, Dmitry Mastykin <[email protected]> wrote:
>
>> 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().
>>
>> Signed-off-by: Dmitry Mastykin <[email protected]>

2018-01-08 05:36:03

by Phil Reid

[permalink] [raw]
Subject: Re: [PATCH] pinctrl: mcp23s08: fix irq setup order

On 2/01/2018 17:10, Linus Walleij wrote:
> On Thu, Dec 28, 2017 at 4:19 PM, Dmitry Mastykin <[email protected]> wrote:
>
>> 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().
>>
>> Signed-off-by: Dmitry Mastykin <[email protected]>
>
> 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.


--
Regards
Phil Reid