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

pinctrl: bcm: cygnus-ns2: 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-9-b11c1d650384@linaro.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Krzysztof Kozlowski and committed by
Linus Walleij
9b2ae7ca fa856a2c

+4 -4
+4 -4
drivers/pinctrl/bcm/pinctrl-ns2-mux.c
··· 971 971 .pctlops = &ns2_pinctrl_ops, 972 972 .pmxops = &ns2_pinmux_ops, 973 973 .confops = &ns2_pinconf_ops, 974 + .npins = ARRAY_SIZE(ns2_pins), 974 975 }; 975 976 976 977 static int ns2_mux_log_init(struct ns2_pinctrl *pinctrl) ··· 1027 1026 struct resource *res; 1028 1027 int i, ret; 1029 1028 struct pinctrl_pin_desc *pins; 1030 - unsigned int num_pins = ARRAY_SIZE(ns2_pins); 1031 1029 1032 1030 pinctrl = devm_kzalloc(&pdev->dev, sizeof(*pinctrl), GFP_KERNEL); 1033 1031 if (!pinctrl) ··· 1060 1060 return ret; 1061 1061 } 1062 1062 1063 - pins = devm_kcalloc(&pdev->dev, num_pins, sizeof(*pins), GFP_KERNEL); 1063 + pins = devm_kcalloc(&pdev->dev, ARRAY_SIZE(ns2_pins), sizeof(*pins), 1064 + GFP_KERNEL); 1064 1065 if (!pins) 1065 1066 return -ENOMEM; 1066 1067 1067 - for (i = 0; i < num_pins; i++) { 1068 + for (i = 0; i < ARRAY_SIZE(ns2_pins); i++) { 1068 1069 pins[i].number = ns2_pins[i].pin; 1069 1070 pins[i].name = ns2_pins[i].name; 1070 1071 pins[i].drv_data = &ns2_pins[i]; ··· 1076 1075 pinctrl->functions = ns2_pin_functions; 1077 1076 pinctrl->num_functions = ARRAY_SIZE(ns2_pin_functions); 1078 1077 ns2_pinctrl_desc.pins = pins; 1079 - ns2_pinctrl_desc.npins = num_pins; 1080 1078 1081 1079 pinctrl->pctl = pinctrl_register(&ns2_pinctrl_desc, &pdev->dev, 1082 1080 pinctrl);