Commit dc4003d2 authored by Tony Lindgren's avatar Tony Lindgren Committed by Linus Walleij

pinctrl: rza1: Fix selector use for groups and functions

We must use a mutex around the generic_add functions and save the
function and group selector in case we need to remove them. Otherwise
the selector use will be racy for deferred probe at least.

Fixes: 5a49b644 ("pinctrl: Renesas RZ/A1 pin and gpio controller")
Reported-by: default avatarH. Nikolaus Schaller <hns@goldelico.com>
Cc: Christ van Willegen <cvwillegen@gmail.com>
Cc: Haojian Zhuang <haojian.zhuang@linaro.org>
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Sean Wang <sean.wang@mediatek.com>
Acked-by: default avatarJacopo Mondi <jacopo@jmondi.org>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
Tested-By: default avatarH. Nikolaus Schaller <hns@goldelico.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent a4ab1086
...@@ -1006,6 +1006,7 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev, ...@@ -1006,6 +1006,7 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev,
const char *grpname; const char *grpname;
const char **fngrps; const char **fngrps;
int ret, npins; int ret, npins;
int gsel, fsel;
npins = rza1_dt_node_pin_count(np); npins = rza1_dt_node_pin_count(np);
if (npins < 0) { if (npins < 0) {
...@@ -1055,18 +1056,19 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev, ...@@ -1055,18 +1056,19 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev,
fngrps[0] = grpname; fngrps[0] = grpname;
mutex_lock(&rza1_pctl->mutex); mutex_lock(&rza1_pctl->mutex);
ret = pinctrl_generic_add_group(pctldev, grpname, grpins, npins, gsel = pinctrl_generic_add_group(pctldev, grpname, grpins, npins,
NULL); NULL);
if (ret) { if (gsel < 0) {
mutex_unlock(&rza1_pctl->mutex); mutex_unlock(&rza1_pctl->mutex);
return ret; return gsel;
} }
ret = pinmux_generic_add_function(pctldev, grpname, fngrps, 1, fsel = pinmux_generic_add_function(pctldev, grpname, fngrps, 1,
mux_confs); mux_confs);
if (ret) if (fsel < 0) {
ret = fsel;
goto remove_group; goto remove_group;
mutex_unlock(&rza1_pctl->mutex); }
dev_info(rza1_pctl->dev, "Parsed function and group %s with %d pins\n", dev_info(rza1_pctl->dev, "Parsed function and group %s with %d pins\n",
grpname, npins); grpname, npins);
...@@ -1083,15 +1085,15 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev, ...@@ -1083,15 +1085,15 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev,
(*map)->data.mux.group = np->name; (*map)->data.mux.group = np->name;
(*map)->data.mux.function = np->name; (*map)->data.mux.function = np->name;
*num_maps = 1; *num_maps = 1;
mutex_unlock(&rza1_pctl->mutex);
return 0; return 0;
remove_function: remove_function:
mutex_lock(&rza1_pctl->mutex); pinmux_generic_remove_function(pctldev, fsel);
pinmux_generic_remove_last_function(pctldev);
remove_group: remove_group:
pinctrl_generic_remove_last_group(pctldev); pinctrl_generic_remove_group(pctldev, gsel);
mutex_unlock(&rza1_pctl->mutex); mutex_unlock(&rza1_pctl->mutex);
dev_info(rza1_pctl->dev, "Unable to parse function and group %s\n", dev_info(rza1_pctl->dev, "Unable to parse function and group %s\n",
......
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