sh-pfc: Use proper error codes
Return proper error codes instead of -1, and propagate the error codes.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c
index b4960df..c150910 100644
--- a/drivers/pinctrl/sh-pfc/pinctrl.c
+++ b/drivers/pinctrl/sh-pfc/pinctrl.c
@@ -114,18 +114,16 @@
const struct sh_pfc_pin_group *grp = &pfc->info->groups[group];
unsigned long flags;
unsigned int i;
- int ret = -EINVAL;
+ int ret = 0;
spin_lock_irqsave(&pfc->lock, flags);
for (i = 0; i < grp->nr_pins; ++i) {
- if (sh_pfc_config_mux(pfc, grp->mux[i], PINMUX_TYPE_FUNCTION))
- goto done;
+ ret = sh_pfc_config_mux(pfc, grp->mux[i], PINMUX_TYPE_FUNCTION);
+ if (ret < 0)
+ break;
}
- ret = 0;
-
-done:
spin_unlock_irqrestore(&pfc->lock, flags);
return ret;
}
@@ -144,7 +142,7 @@
const struct sh_pfc_pin *pin = &pfc->info->pins[idx];
unsigned int mark = pin->enum_id;
unsigned long flags;
- int ret = -EINVAL;
+ int ret;
spin_lock_irqsave(&pfc->lock, flags);
@@ -156,17 +154,17 @@
case PINMUX_TYPE_INPUT_PULLDOWN:
break;
default:
- goto err;
+ ret = -EINVAL;
+ goto done;
}
- if (sh_pfc_config_mux(pfc, mark, new_type) != 0)
- goto err;
+ ret = sh_pfc_config_mux(pfc, mark, new_type);
+ if (ret < 0)
+ goto done;
cfg->type = new_type;
- ret = 0;
-
-err:
+done:
spin_unlock_irqrestore(&pfc->lock, flags);
return ret;