Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pinctrl: berlin: Make use of struct pinfunction

Since pin control provides a generic data type for the pin function,
use it in the driver.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20240530085745.1539925-2-andy.shevchenko@gmail.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Andy Shevchenko and committed by
Linus Walleij
5d421ff5 a8f25485

+9 -18
+9 -12
drivers/pinctrl/berlin/berlin.c
··· 27 27 struct regmap *regmap; 28 28 struct device *dev; 29 29 const struct berlin_pinctrl_desc *desc; 30 - struct berlin_pinctrl_function *functions; 30 + struct pinfunction *functions; 31 31 unsigned nfunctions; 32 32 struct pinctrl_dev *pctrl_dev; 33 33 }; ··· 120 120 static int berlin_pinmux_get_function_groups(struct pinctrl_dev *pctrl_dev, 121 121 unsigned function, 122 122 const char * const **groups, 123 - unsigned * const num_groups) 123 + unsigned * const ngroups) 124 124 { 125 125 struct berlin_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrl_dev); 126 126 127 127 *groups = pctrl->functions[function].groups; 128 - *num_groups = pctrl->functions[function].ngroups; 128 + *ngroups = pctrl->functions[function].ngroups; 129 129 130 130 return 0; 131 131 } ··· 153 153 { 154 154 struct berlin_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrl_dev); 155 155 const struct berlin_desc_group *group_desc = pctrl->desc->groups + group; 156 - struct berlin_pinctrl_function *func = pctrl->functions + function; 156 + struct pinfunction *func = pctrl->functions + function; 157 157 struct berlin_desc_function *function_desc = 158 158 berlin_pinctrl_find_function_by_name(pctrl, group_desc, 159 159 func->name); ··· 180 180 static int berlin_pinctrl_add_function(struct berlin_pinctrl *pctrl, 181 181 const char *name) 182 182 { 183 - struct berlin_pinctrl_function *function = pctrl->functions; 183 + struct pinfunction *function = pctrl->functions; 184 184 185 185 while (function->name) { 186 186 if (!strcmp(function->name, name)) { ··· 214 214 } 215 215 216 216 /* we will reallocate later */ 217 - pctrl->functions = kcalloc(max_functions, 218 - sizeof(*pctrl->functions), GFP_KERNEL); 217 + pctrl->functions = kcalloc(max_functions, sizeof(*pctrl->functions), GFP_KERNEL); 219 218 if (!pctrl->functions) 220 219 return -ENOMEM; 221 220 ··· 241 242 desc_function = desc_group->functions; 242 243 243 244 while (desc_function->name) { 244 - struct berlin_pinctrl_function 245 - *function = pctrl->functions; 245 + struct pinfunction *function = pctrl->functions; 246 246 const char **groups; 247 247 bool found = false; 248 248 ··· 262 264 function->groups = 263 265 devm_kcalloc(&pdev->dev, 264 266 function->ngroups, 265 - sizeof(char *), 267 + sizeof(*function->groups), 266 268 GFP_KERNEL); 267 - 268 269 if (!function->groups) { 269 270 kfree(pctrl->functions); 270 271 return -ENOMEM; 271 272 } 272 273 } 273 274 274 - groups = function->groups; 275 + groups = (const char **)function->groups; 275 276 while (*groups) 276 277 groups++; 277 278
-6
drivers/pinctrl/berlin/berlin.h
··· 28 28 unsigned ngroups; 29 29 }; 30 30 31 - struct berlin_pinctrl_function { 32 - const char *name; 33 - const char **groups; 34 - unsigned ngroups; 35 - }; 36 - 37 31 #define BERLIN_PINCTRL_GROUP(_name, _offset, _width, _lsb, ...) \ 38 32 { \ 39 33 .name = _name, \