summaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinctrl-mcp23s08.c
diff options
context:
space:
mode:
authorMarkus Elfring <elfring@users.sourceforge.net>2017-10-30 16:03:12 +0100
committerLinus Walleij <linus.walleij@linaro.org>2017-11-29 13:51:10 +0100
commit7f6f50dfb51b141ed2de277d8239c52f15d9742b (patch)
tree4fbcf63fcb049ba4de71fa8a15363c80b71718e5 /drivers/pinctrl/pinctrl-mcp23s08.c
parentpinctrl: cannonlake: Align GPIO number space with Windows (diff)
downloadlinux-7f6f50dfb51b141ed2de277d8239c52f15d9742b.tar.xz
linux-7f6f50dfb51b141ed2de277d8239c52f15d9742b.zip
pinctrl: mcp23s08: Improve unlocking of a mutex in mcp23s08_irq()
* Add a jump target so that a call of the function "mutex_unlock" is stored only twice in this function implementation. * Replace five calls by goto statements. * Adjust five condition checks. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-mcp23s08.c')
-rw-r--r--drivers/pinctrl/pinctrl-mcp23s08.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c
index 4a6ea159c65d..e6ad36dea3e5 100644
--- a/drivers/pinctrl/pinctrl-mcp23s08.c
+++ b/drivers/pinctrl/pinctrl-mcp23s08.c
@@ -455,31 +455,22 @@ static irqreturn_t mcp23s08_irq(int irq, void *data)
defval_changed, gpio_set;
mutex_lock(&mcp->lock);
- if (mcp_read(mcp, MCP_INTF, &intf) < 0) {
- mutex_unlock(&mcp->lock);
- return IRQ_HANDLED;
- }
+ if (mcp_read(mcp, MCP_INTF, &intf))
+ goto unlock;
- if (mcp_read(mcp, MCP_INTCAP, &intcap) < 0) {
- mutex_unlock(&mcp->lock);
- return IRQ_HANDLED;
- }
+ if (mcp_read(mcp, MCP_INTCAP, &intcap))
+ goto unlock;
- if (mcp_read(mcp, MCP_INTCON, &intcon) < 0) {
- mutex_unlock(&mcp->lock);
- return IRQ_HANDLED;
- }
+ if (mcp_read(mcp, MCP_INTCON, &intcon))
+ goto unlock;
- if (mcp_read(mcp, MCP_DEFVAL, &defval) < 0) {
- mutex_unlock(&mcp->lock);
- return IRQ_HANDLED;
- }
+ if (mcp_read(mcp, MCP_DEFVAL, &defval))
+ goto unlock;
/* This clears the interrupt(configurable on S18) */
- if (mcp_read(mcp, MCP_GPIO, &gpio) < 0) {
- mutex_unlock(&mcp->lock);
- return IRQ_HANDLED;
- }
+ if (mcp_read(mcp, MCP_GPIO, &gpio))
+ goto unlock;
+
gpio_orig = mcp->cached_gpio;
mcp->cached_gpio = gpio;
mutex_unlock(&mcp->lock);
@@ -541,6 +532,10 @@ static irqreturn_t mcp23s08_irq(int irq, void *data)
}
return IRQ_HANDLED;
+
+unlock:
+ mutex_unlock(&mcp->lock);
+ return IRQ_HANDLED;
}
static void mcp23s08_irq_mask(struct irq_data *data)