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

pinctrl: pinmux: Return selector to the pinctrl driver

We must return the selector from pinmux_generic_add_function() so
pin controller device drivers can remove the right group if needed
for deferred probe for example. And we now must make sure that a
proper name is passed so we can use it to check if the entry already
exists.

Note that fixes are also needed for the pin controller drivers to
use the selector value.

Fixes: a76edc89 ("pinctrl: core: Add generic pinctrl functions for
managing groups")
Reported-by: default avatarH. Nikolaus Schaller <hns@goldelico.com>
Cc: Christ van Willegen <cvwillegen@gmail.com>
Cc: Haojian Zhuang <haojian.zhuang@linaro.org>
Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Sean Wang <sean.wang@mediatek.com>
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 a203728a
...@@ -307,7 +307,6 @@ static int pinmux_func_name_to_selector(struct pinctrl_dev *pctldev, ...@@ -307,7 +307,6 @@ static int pinmux_func_name_to_selector(struct pinctrl_dev *pctldev,
selector++; selector++;
} }
dev_err(pctldev->dev, "function '%s' not supported\n", function);
return -EINVAL; return -EINVAL;
} }
...@@ -774,6 +773,16 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev, ...@@ -774,6 +773,16 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
void *data) void *data)
{ {
struct function_desc *function; struct function_desc *function;
int selector;
if (!name)
return -EINVAL;
selector = pinmux_func_name_to_selector(pctldev, name);
if (selector >= 0)
return selector;
selector = pctldev->num_functions;
function = devm_kzalloc(pctldev->dev, sizeof(*function), GFP_KERNEL); function = devm_kzalloc(pctldev->dev, sizeof(*function), GFP_KERNEL);
if (!function) if (!function)
...@@ -784,12 +793,11 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev, ...@@ -784,12 +793,11 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
function->num_group_names = num_groups; function->num_group_names = num_groups;
function->data = data; function->data = data;
radix_tree_insert(&pctldev->pin_function_tree, pctldev->num_functions, radix_tree_insert(&pctldev->pin_function_tree, selector, function);
function);
pctldev->num_functions++; pctldev->num_functions++;
return 0; return selector;
} }
EXPORT_SYMBOL_GPL(pinmux_generic_add_function); EXPORT_SYMBOL_GPL(pinmux_generic_add_function);
......
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