mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00
pinctrl: provide pinmux_generic_add_pinfunction()
Several drivers call pinmux_generic_add_function() passing it the contents of struct pinfunction as first three arguments. We can make this shorter by simply providing an interface allowing to pass the address of struct pinfunction directly when adding a new function. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Link: https://lore.kernel.org/20250709-pinctrl-gpio-pinfuncs-v2-2-b6135149c0d9@linaro.org Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
dd47155a0e
commit
431b68ae73
@ -874,14 +874,26 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
|
||||
const char * const *groups,
|
||||
const unsigned int ngroups,
|
||||
void *data)
|
||||
{
|
||||
struct pinfunction func = PINCTRL_PINFUNCTION(name, groups, ngroups);
|
||||
|
||||
return pinmux_generic_add_pinfunction(pctldev, &func, data);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(pinmux_generic_add_function);
|
||||
|
||||
/**
|
||||
* pinmux_generic_add_pinfunction() - adds a function group
|
||||
* @pctldev: pin controller device
|
||||
* @func: pinfunction structure describing the function group
|
||||
* @data: pin controller driver specific data
|
||||
*/
|
||||
int pinmux_generic_add_pinfunction(struct pinctrl_dev *pctldev,
|
||||
const struct pinfunction *func, void *data)
|
||||
{
|
||||
struct function_desc *function;
|
||||
int selector, error;
|
||||
|
||||
if (!name)
|
||||
return -EINVAL;
|
||||
|
||||
selector = pinmux_func_name_to_selector(pctldev, name);
|
||||
selector = pinmux_func_name_to_selector(pctldev, func->name);
|
||||
if (selector >= 0)
|
||||
return selector;
|
||||
|
||||
@ -891,7 +903,7 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
|
||||
if (!function)
|
||||
return -ENOMEM;
|
||||
|
||||
function->func = PINCTRL_PINFUNCTION(name, groups, ngroups);
|
||||
function->func = *func;
|
||||
function->data = data;
|
||||
|
||||
error = radix_tree_insert(&pctldev->pin_function_tree, selector, function);
|
||||
@ -902,7 +914,7 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
|
||||
|
||||
return selector;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(pinmux_generic_add_function);
|
||||
EXPORT_SYMBOL_GPL(pinmux_generic_add_pinfunction);
|
||||
|
||||
/**
|
||||
* pinmux_generic_remove_function() - removes a numbered function
|
||||
|
@ -161,6 +161,9 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
|
||||
unsigned int const ngroups,
|
||||
void *data);
|
||||
|
||||
int pinmux_generic_add_pinfunction(struct pinctrl_dev *pctldev,
|
||||
const struct pinfunction *func, void *data);
|
||||
|
||||
int pinmux_generic_remove_function(struct pinctrl_dev *pctldev,
|
||||
unsigned int selector);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user