pinctrl: bcm: cygnus-mux: Move fixed assignments to 'pinctrl_desc' definition
Assign 'struct pinctrl_desc' .npins member in definition to make clear that number of pins is fixed and have less code in the probe. Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/20250611-pinctrl-const-desc-v2-8-b11c1d650384@linaro.org Signed-off-by: Linus Walleij <linus.walleij@linaro.org>pull/1320/head
parent
3cbbb91f11
commit
fa856a2c3f
|
|
@ -903,6 +903,7 @@ static struct pinctrl_desc cygnus_pinctrl_desc = {
|
|||
.name = "cygnus-pinmux",
|
||||
.pctlops = &cygnus_pinctrl_ops,
|
||||
.pmxops = &cygnus_pinmux_ops,
|
||||
.npins = ARRAY_SIZE(cygnus_pins),
|
||||
};
|
||||
|
||||
static int cygnus_mux_log_init(struct cygnus_pinctrl *pinctrl)
|
||||
|
|
@ -935,7 +936,6 @@ static int cygnus_pinmux_probe(struct platform_device *pdev)
|
|||
struct cygnus_pinctrl *pinctrl;
|
||||
int i, ret;
|
||||
struct pinctrl_pin_desc *pins;
|
||||
unsigned num_pins = ARRAY_SIZE(cygnus_pins);
|
||||
|
||||
pinctrl = devm_kzalloc(&pdev->dev, sizeof(*pinctrl), GFP_KERNEL);
|
||||
if (!pinctrl)
|
||||
|
|
@ -963,11 +963,12 @@ static int cygnus_pinmux_probe(struct platform_device *pdev)
|
|||
return ret;
|
||||
}
|
||||
|
||||
pins = devm_kcalloc(&pdev->dev, num_pins, sizeof(*pins), GFP_KERNEL);
|
||||
pins = devm_kcalloc(&pdev->dev, ARRAY_SIZE(cygnus_pins), sizeof(*pins),
|
||||
GFP_KERNEL);
|
||||
if (!pins)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < num_pins; i++) {
|
||||
for (i = 0; i < ARRAY_SIZE(cygnus_pins); i++) {
|
||||
pins[i].number = cygnus_pins[i].pin;
|
||||
pins[i].name = cygnus_pins[i].name;
|
||||
pins[i].drv_data = &cygnus_pins[i].gpio_mux;
|
||||
|
|
@ -978,7 +979,6 @@ static int cygnus_pinmux_probe(struct platform_device *pdev)
|
|||
pinctrl->functions = cygnus_pin_functions;
|
||||
pinctrl->num_functions = ARRAY_SIZE(cygnus_pin_functions);
|
||||
cygnus_pinctrl_desc.pins = pins;
|
||||
cygnus_pinctrl_desc.npins = num_pins;
|
||||
|
||||
pinctrl->pctl = devm_pinctrl_register(&pdev->dev, &cygnus_pinctrl_desc,
|
||||
pinctrl);
|
||||
|
|
|
|||
Loading…
Reference in New Issue