diff options
author | Marco Felsch <m.felsch@pengutronix.de> | 2018-10-02 04:06:46 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2018-10-10 08:36:35 -0400 |
commit | f259f896f2348f0302f6f88d4382378cf9d23a7e (patch) | |
tree | ecea64683b1e6d765739ddbec161c810cd8dd641 | |
parent | 0238df646e6224016a45505d2c111a24669ebe21 (diff) |
pinctrl: mcp23s08: fix irq and irqchip setup order
Since 'commit 02e389e63e35 ("pinctrl: mcp23s08: fix irq setup order")' the
irq request isn't the last devm_* allocation. Without a deeper look at
the irq and testing this isn't a good solution. Since this driver relies
on the devm mechanism, requesting a interrupt should be the last thing
to avoid memory corruptions during unbinding.
'Commit 02e389e63e35 ("pinctrl: mcp23s08: fix irq setup order")' fixed the
order for the interrupt-controller use case only. The
mcp23s08_irq_setup() must be split into two to fix it for the
interrupt-controller use case and to register the irq at last. So the
irq will be freed first during unbind.
Cc: stable@vger.kernel.org
Cc: Jan Kundrát <jan.kundrat@cesnet.cz>
Cc: Dmitry Mastykin <mastichi@gmail.com>
Cc: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Fixes: 82039d244f87 ("pinctrl: mcp23s08: add pinconf support")
Fixes: 02e389e63e35 ("pinctrl: mcp23s08: fix irq setup order")
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Tested-by: Phil Reid <preid@electromag.com.au>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/pinctrl/pinctrl-mcp23s08.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c index 4a8a8efadefa..cf73a403d22d 100644 --- a/drivers/pinctrl/pinctrl-mcp23s08.c +++ b/drivers/pinctrl/pinctrl-mcp23s08.c | |||
@@ -636,6 +636,14 @@ static int mcp23s08_irq_setup(struct mcp23s08 *mcp) | |||
636 | return err; | 636 | return err; |
637 | } | 637 | } |
638 | 638 | ||
639 | return 0; | ||
640 | } | ||
641 | |||
642 | static int mcp23s08_irqchip_setup(struct mcp23s08 *mcp) | ||
643 | { | ||
644 | struct gpio_chip *chip = &mcp->chip; | ||
645 | int err; | ||
646 | |||
639 | err = gpiochip_irqchip_add_nested(chip, | 647 | err = gpiochip_irqchip_add_nested(chip, |
640 | &mcp23s08_irq_chip, | 648 | &mcp23s08_irq_chip, |
641 | 0, | 649 | 0, |
@@ -912,7 +920,7 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, | |||
912 | } | 920 | } |
913 | 921 | ||
914 | if (mcp->irq && mcp->irq_controller) { | 922 | if (mcp->irq && mcp->irq_controller) { |
915 | ret = mcp23s08_irq_setup(mcp); | 923 | ret = mcp23s08_irqchip_setup(mcp); |
916 | if (ret) | 924 | if (ret) |
917 | goto fail; | 925 | goto fail; |
918 | } | 926 | } |
@@ -944,6 +952,9 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, | |||
944 | goto fail; | 952 | goto fail; |
945 | } | 953 | } |
946 | 954 | ||
955 | if (mcp->irq) | ||
956 | ret = mcp23s08_irq_setup(mcp); | ||
957 | |||
947 | fail: | 958 | fail: |
948 | if (ret < 0) | 959 | if (ret < 0) |
949 | dev_dbg(dev, "can't setup chip %d, --> %d\n", addr, ret); | 960 | dev_dbg(dev, "can't setup chip %d, --> %d\n", addr, ret); |