Skip to content

Commit

Permalink
gpio-adnp: Use common error handling code in adnp_gpio_dbg_show()
Browse files Browse the repository at this point in the history
Add a jump target so that a bit of exception handling can be better reused
at the end of this function.

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>
  • Loading branch information
Markus Elfring authored and Linus Walleij committed Oct 31, 2017
1 parent 5a24d4b commit 5ac9d2d
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions drivers/gpio/gpio-adnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,28 +192,20 @@ static void adnp_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
mutex_lock(&adnp->i2c_lock);

err = adnp_read(adnp, GPIO_DDR(adnp) + i, &ddr);
if (err < 0) {
mutex_unlock(&adnp->i2c_lock);
return;
}
if (err < 0)
goto unlock;

err = adnp_read(adnp, GPIO_PLR(adnp) + i, &plr);
if (err < 0) {
mutex_unlock(&adnp->i2c_lock);
return;
}
if (err < 0)
goto unlock;

err = adnp_read(adnp, GPIO_IER(adnp) + i, &ier);
if (err < 0) {
mutex_unlock(&adnp->i2c_lock);
return;
}
if (err < 0)
goto unlock;

err = adnp_read(adnp, GPIO_ISR(adnp) + i, &isr);
if (err < 0) {
mutex_unlock(&adnp->i2c_lock);
return;
}
if (err < 0)
goto unlock;

mutex_unlock(&adnp->i2c_lock);

Expand All @@ -240,6 +232,11 @@ static void adnp_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
direction, level, interrupt, pending);
}
}

return;

unlock:
mutex_unlock(&adnp->i2c_lock);
}

static int adnp_gpio_setup(struct adnp *adnp, unsigned int num_gpios)
Expand Down

0 comments on commit 5ac9d2d

Please sign in to comment.