Commit 2ac48d0d authored by Zhen Lei's avatar Zhen Lei Committed by Linus Walleij

pinctrl: single: Move test PCS_HAS_PINCONF in pcs_parse_bits_in_pinctrl_entry() to the beginning

The value of pcs->flags is not overwritten in function
pcs_parse_bits_in_pinctrl_entry() and its subfunctions, so moving this
check to the beginning of the function eliminates unnecessary rollback
operations.
Signed-off-by: default avatarZhen Lei <thunder.leizhen@huawei.com>
Reviewed-by: default avatarTony Lindgren <tony@atomide.com>
Link: https://lore.kernel.org/r/20210722033930.4034-3-thunder.leizhen@huawei.comSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent d789a490
...@@ -1115,7 +1115,7 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs, ...@@ -1115,7 +1115,7 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
{ {
const char *name = "pinctrl-single,bits"; const char *name = "pinctrl-single,bits";
struct pcs_func_vals *vals; struct pcs_func_vals *vals;
int rows, *pins, found = 0, res = -ENOMEM, i, fsel, gsel; int rows, *pins, found = 0, res = -ENOMEM, i, fsel;
int npins_in_row; int npins_in_row;
struct pcs_function *function = NULL; struct pcs_function *function = NULL;
...@@ -1125,6 +1125,11 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs, ...@@ -1125,6 +1125,11 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
return -EINVAL; return -EINVAL;
} }
if (PCS_HAS_PINCONF) {
dev_err(pcs->dev, "pinconf not supported\n");
return -ENOTSUPP;
}
npins_in_row = pcs->width / pcs->bits_per_pin; npins_in_row = pcs->width / pcs->bits_per_pin;
vals = devm_kzalloc(pcs->dev, vals = devm_kzalloc(pcs->dev,
...@@ -1212,30 +1217,19 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs, ...@@ -1212,30 +1217,19 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
goto free_pins; goto free_pins;
} }
gsel = pinctrl_generic_add_group(pcs->pctl, np->name, pins, found, pcs); res = pinctrl_generic_add_group(pcs->pctl, np->name, pins, found, pcs);
if (gsel < 0) { if (res < 0)
res = gsel;
goto free_function; goto free_function;
}
(*map)->type = PIN_MAP_TYPE_MUX_GROUP; (*map)->type = PIN_MAP_TYPE_MUX_GROUP;
(*map)->data.mux.group = np->name; (*map)->data.mux.group = np->name;
(*map)->data.mux.function = np->name; (*map)->data.mux.function = np->name;
if (PCS_HAS_PINCONF) {
dev_err(pcs->dev, "pinconf not supported\n");
res = -ENOTSUPP;
goto free_pingroups;
}
*num_maps = 1; *num_maps = 1;
mutex_unlock(&pcs->mutex); mutex_unlock(&pcs->mutex);
return 0; return 0;
free_pingroups:
pinctrl_generic_remove_group(pcs->pctl, gsel);
*num_maps = 1;
free_function: free_function:
pinmux_generic_remove_function(pcs->pctl, fsel); pinmux_generic_remove_function(pcs->pctl, fsel);
free_pins: free_pins:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment