Skip to content

Commit

Permalink
pinctrl: pinmux: Return selector to the pinctrl driver
Browse files Browse the repository at this point in the history
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: a76edc8 ("pinctrl: core: Add generic pinctrl functions for
managing groups")
Reported-by: H. Nikolaus Schaller <[email protected]>
Cc: Christ van Willegen <[email protected]>
Cc: Haojian Zhuang <[email protected]>
Cc: Jacopo Mondi <[email protected]>
Cc: Paul Cercueil <[email protected]>
Cc: Sean Wang <[email protected]>
Signed-off-by: Tony Lindgren <[email protected]>
Tested-By: H. Nikolaus Schaller <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
  • Loading branch information
tmlind authored and linusw committed Jul 17, 2018
1 parent a203728 commit f913cfc
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions drivers/pinctrl/pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ static int pinmux_func_name_to_selector(struct pinctrl_dev *pctldev,
selector++;
}

dev_err(pctldev->dev, "function '%s' not supported\n", function);
return -EINVAL;
}

Expand Down Expand Up @@ -774,6 +773,16 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
void *data)
{
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);
if (!function)
Expand All @@ -784,12 +793,11 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
function->num_group_names = num_groups;
function->data = data;

radix_tree_insert(&pctldev->pin_function_tree, pctldev->num_functions,
function);
radix_tree_insert(&pctldev->pin_function_tree, selector, function);

pctldev->num_functions++;

return 0;
return selector;
}
EXPORT_SYMBOL_GPL(pinmux_generic_add_function);

Expand Down

0 comments on commit f913cfc

Please sign in to comment.