mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 10:01:39 -05:00
pinctrl: make struct pinfunction a pointer in struct function_desc
We currently duplicate the entire struct pinfunction object in pinmux_generic_add_pinfunction(). While this is inevitable when the arguments come in split through pinmux_generic_add_function(), users of pinmux_generic_add_pinfunction() will typically pass addresses of structures in .rodata, meaning we can try to avoid the duplication with the help from kmemdup_const(). To that end: don't wrap the entire struct pinfunction in struct function_desc but rather just store the address. Tested-by: Neil Armstrong <neil.armstrong@linaro.org> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
committed by
Linus Walleij
parent
fbba4a9e36
commit
d57b7979ea
@@ -266,7 +266,7 @@ static int imx_pmx_set(struct pinctrl_dev *pctldev, unsigned selector,
|
||||
npins = grp->grp.npins;
|
||||
|
||||
dev_dbg(ipctl->dev, "enable function %s group %s\n",
|
||||
func->func.name, grp->grp.name);
|
||||
func->func->name, grp->grp.name);
|
||||
|
||||
for (i = 0; i < npins; i++) {
|
||||
/*
|
||||
|
||||
@@ -2456,7 +2456,7 @@ static int airoha_pinmux_set_mux(struct pinctrl_dev *pctrl_dev,
|
||||
return -EINVAL;
|
||||
|
||||
dev_dbg(pctrl_dev->dev, "enable function %s group %s\n",
|
||||
desc->func.name, grp->grp.name);
|
||||
desc->func->name, grp->grp.name);
|
||||
|
||||
func = desc->data;
|
||||
for (i = 0; i < func->group_size; i++) {
|
||||
|
||||
@@ -56,7 +56,7 @@ static int mtk_pinmux_set_mux(struct pinctrl_dev *pctldev,
|
||||
return -EINVAL;
|
||||
|
||||
dev_dbg(pctldev->dev, "enable function %s group %s\n",
|
||||
func->func.name, grp->grp.name);
|
||||
func->func->name, grp->grp.name);
|
||||
|
||||
for (i = 0; i < grp->grp.npins; i++) {
|
||||
const struct mtk_pin_desc *desc;
|
||||
|
||||
@@ -4015,7 +4015,7 @@ static int ingenic_pinmux_set_mux(struct pinctrl_dev *pctldev,
|
||||
return -EINVAL;
|
||||
|
||||
dev_dbg(pctldev->dev, "enable function %s group %s\n",
|
||||
func->func.name, grp->grp.name);
|
||||
func->func->name, grp->grp.name);
|
||||
|
||||
mode = (uintptr_t)grp->data;
|
||||
if (mode <= 3) {
|
||||
|
||||
@@ -810,7 +810,7 @@ pinmux_generic_get_function_name(struct pinctrl_dev *pctldev,
|
||||
if (!function)
|
||||
return NULL;
|
||||
|
||||
return function->func.name;
|
||||
return function->func->name;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(pinmux_generic_get_function_name);
|
||||
|
||||
@@ -835,8 +835,8 @@ int pinmux_generic_get_function_groups(struct pinctrl_dev *pctldev,
|
||||
__func__, selector);
|
||||
return -EINVAL;
|
||||
}
|
||||
*groups = function->func.groups;
|
||||
*ngroups = function->func.ngroups;
|
||||
*groups = function->func->groups;
|
||||
*ngroups = function->func->ngroups;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -903,7 +903,17 @@ int pinmux_generic_add_pinfunction(struct pinctrl_dev *pctldev,
|
||||
if (!function)
|
||||
return -ENOMEM;
|
||||
|
||||
function->func = *func;
|
||||
/*
|
||||
* FIXME: It's generally a bad idea to use devres in subsystem core
|
||||
* code - managed interfaces are aimed at drivers - but pinctrl already
|
||||
* uses it all over the place so it's a larger piece of technical debt
|
||||
* to fix.
|
||||
*/
|
||||
function->func = devm_kmemdup_const(pctldev->dev, func,
|
||||
sizeof(*func), GFP_KERNEL);
|
||||
if (!function->func)
|
||||
return -ENOMEM;
|
||||
|
||||
function->data = data;
|
||||
|
||||
error = radix_tree_insert(&pctldev->pin_function_tree, selector, function);
|
||||
|
||||
@@ -137,7 +137,7 @@ static inline void pinmux_init_device_debugfs(struct dentry *devroot,
|
||||
* @data: pin controller driver specific data
|
||||
*/
|
||||
struct function_desc {
|
||||
struct pinfunction func;
|
||||
const struct pinfunction *func;
|
||||
void *data;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user