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

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>

authored by

Krzysztof Kozlowski and committed by
Linus Walleij
fa856a2c 3cbbb91f

+4 -4
+4 -4
drivers/pinctrl/bcm/pinctrl-cygnus-mux.c
··· 903 903 .name = "cygnus-pinmux", 904 904 .pctlops = &cygnus_pinctrl_ops, 905 905 .pmxops = &cygnus_pinmux_ops, 906 + .npins = ARRAY_SIZE(cygnus_pins), 906 907 }; 907 908 908 909 static int cygnus_mux_log_init(struct cygnus_pinctrl *pinctrl) ··· 936 935 struct cygnus_pinctrl *pinctrl; 937 936 int i, ret; 938 937 struct pinctrl_pin_desc *pins; 939 - unsigned num_pins = ARRAY_SIZE(cygnus_pins); 940 938 941 939 pinctrl = devm_kzalloc(&pdev->dev, sizeof(*pinctrl), GFP_KERNEL); 942 940 if (!pinctrl) ··· 963 963 return ret; 964 964 } 965 965 966 - pins = devm_kcalloc(&pdev->dev, num_pins, sizeof(*pins), GFP_KERNEL); 966 + pins = devm_kcalloc(&pdev->dev, ARRAY_SIZE(cygnus_pins), sizeof(*pins), 967 + GFP_KERNEL); 967 968 if (!pins) 968 969 return -ENOMEM; 969 970 970 - for (i = 0; i < num_pins; i++) { 971 + for (i = 0; i < ARRAY_SIZE(cygnus_pins); i++) { 971 972 pins[i].number = cygnus_pins[i].pin; 972 973 pins[i].name = cygnus_pins[i].name; 973 974 pins[i].drv_data = &cygnus_pins[i].gpio_mux; ··· 979 978 pinctrl->functions = cygnus_pin_functions; 980 979 pinctrl->num_functions = ARRAY_SIZE(cygnus_pin_functions); 981 980 cygnus_pinctrl_desc.pins = pins; 982 - cygnus_pinctrl_desc.npins = num_pins; 983 981 984 982 pinctrl->pctl = devm_pinctrl_register(&pdev->dev, &cygnus_pinctrl_desc, 985 983 pinctrl);