]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
pinctrl: bcm: cygnus-ns2: Move fixed assignments to 'pinctrl_desc' definition
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Wed, 11 Jun 2025 06:13:41 +0000 (08:13 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 18 Jun 2025 11:26:36 +0000 (13:26 +0200)
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>
drivers/pinctrl/bcm/pinctrl-ns2-mux.c

index 04f4fca854cc05c6ccc75fbcb640b18fcfd37453..23ab3ab064b6f2b0aaa15afd6b9c582f1a1256b2 100644 (file)
@@ -971,6 +971,7 @@ static struct pinctrl_desc ns2_pinctrl_desc = {
        .pctlops = &ns2_pinctrl_ops,
        .pmxops = &ns2_pinmux_ops,
        .confops = &ns2_pinconf_ops,
+       .npins = ARRAY_SIZE(ns2_pins),
 };
 
 static int ns2_mux_log_init(struct ns2_pinctrl *pinctrl)
@@ -1026,7 +1027,6 @@ static int ns2_pinmux_probe(struct platform_device *pdev)
        struct resource *res;
        int i, ret;
        struct pinctrl_pin_desc *pins;
-       unsigned int num_pins = ARRAY_SIZE(ns2_pins);
 
        pinctrl = devm_kzalloc(&pdev->dev, sizeof(*pinctrl), GFP_KERNEL);
        if (!pinctrl)
@@ -1060,11 +1060,12 @@ static int ns2_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(ns2_pins), sizeof(*pins),
+                           GFP_KERNEL);
        if (!pins)
                return -ENOMEM;
 
-       for (i = 0; i < num_pins; i++) {
+       for (i = 0; i < ARRAY_SIZE(ns2_pins); i++) {
                pins[i].number = ns2_pins[i].pin;
                pins[i].name = ns2_pins[i].name;
                pins[i].drv_data = &ns2_pins[i];
@@ -1075,7 +1076,6 @@ static int ns2_pinmux_probe(struct platform_device *pdev)
        pinctrl->functions = ns2_pin_functions;
        pinctrl->num_functions = ARRAY_SIZE(ns2_pin_functions);
        ns2_pinctrl_desc.pins = pins;
-       ns2_pinctrl_desc.npins = num_pins;
 
        pinctrl->pctl = pinctrl_register(&ns2_pinctrl_desc, &pdev->dev,
                        pinctrl);