Skip to content

Commit 2ac48d0

Browse files
Zhen Leilinusw
authored andcommitted
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: Zhen Lei <[email protected]> Reviewed-by: Tony Lindgren <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent d789a49 commit 2ac48d0

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

drivers/pinctrl/pinctrl-single.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
11151115
{
11161116
const char *name = "pinctrl-single,bits";
11171117
struct pcs_func_vals *vals;
1118-
int rows, *pins, found = 0, res = -ENOMEM, i, fsel, gsel;
1118+
int rows, *pins, found = 0, res = -ENOMEM, i, fsel;
11191119
int npins_in_row;
11201120
struct pcs_function *function = NULL;
11211121

@@ -1125,6 +1125,11 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
11251125
return -EINVAL;
11261126
}
11271127

1128+
if (PCS_HAS_PINCONF) {
1129+
dev_err(pcs->dev, "pinconf not supported\n");
1130+
return -ENOTSUPP;
1131+
}
1132+
11281133
npins_in_row = pcs->width / pcs->bits_per_pin;
11291134

11301135
vals = devm_kzalloc(pcs->dev,
@@ -1212,30 +1217,19 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
12121217
goto free_pins;
12131218
}
12141219

1215-
gsel = pinctrl_generic_add_group(pcs->pctl, np->name, pins, found, pcs);
1216-
if (gsel < 0) {
1217-
res = gsel;
1220+
res = pinctrl_generic_add_group(pcs->pctl, np->name, pins, found, pcs);
1221+
if (res < 0)
12181222
goto free_function;
1219-
}
12201223

12211224
(*map)->type = PIN_MAP_TYPE_MUX_GROUP;
12221225
(*map)->data.mux.group = np->name;
12231226
(*map)->data.mux.function = np->name;
12241227

1225-
if (PCS_HAS_PINCONF) {
1226-
dev_err(pcs->dev, "pinconf not supported\n");
1227-
res = -ENOTSUPP;
1228-
goto free_pingroups;
1229-
}
1230-
12311228
*num_maps = 1;
12321229
mutex_unlock(&pcs->mutex);
12331230

12341231
return 0;
12351232

1236-
free_pingroups:
1237-
pinctrl_generic_remove_group(pcs->pctl, gsel);
1238-
*num_maps = 1;
12391233
free_function:
12401234
pinmux_generic_remove_function(pcs->pctl, fsel);
12411235
free_pins:

0 commit comments

Comments
 (0)