]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
pinctrl: bcm: cygnus-nsp: Move fixed assignments to 'pinctrl_desc' definition
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Wed, 11 Jun 2025 06:13:42 +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-10-b11c1d650384@linaro.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/bcm/pinctrl-nsp-mux.c

index eb6298507c1d1873f9d5a90ec724b36af6d4da48..9b716c0d2b9456b9e64ca1094375effefdf4817c 100644 (file)
@@ -525,6 +525,7 @@ static struct pinctrl_desc nsp_pinctrl_desc = {
        .name = "nsp-pinmux",
        .pctlops = &nsp_pinctrl_ops,
        .pmxops = &nsp_pinmux_ops,
+       .npins = ARRAY_SIZE(nsp_pins),
 };
 
 static int nsp_mux_log_init(struct nsp_pinctrl *pinctrl)
@@ -556,7 +557,6 @@ static int nsp_pinmux_probe(struct platform_device *pdev)
        struct resource *res;
        int i, ret;
        struct pinctrl_pin_desc *pins;
-       unsigned int num_pins = ARRAY_SIZE(nsp_pins);
 
        pinctrl = devm_kzalloc(&pdev->dev, sizeof(*pinctrl), GFP_KERNEL);
        if (!pinctrl)
@@ -589,11 +589,12 @@ static int nsp_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(nsp_pins), sizeof(*pins),
+                           GFP_KERNEL);
        if (!pins)
                return -ENOMEM;
 
-       for (i = 0; i < num_pins; i++) {
+       for (i = 0; i < ARRAY_SIZE(nsp_pins); i++) {
                pins[i].number = nsp_pins[i].pin;
                pins[i].name = nsp_pins[i].name;
                pins[i].drv_data = &nsp_pins[i].gpio_select;
@@ -604,7 +605,6 @@ static int nsp_pinmux_probe(struct platform_device *pdev)
        pinctrl->functions = nsp_pin_functions;
        pinctrl->num_functions = ARRAY_SIZE(nsp_pin_functions);
        nsp_pinctrl_desc.pins = pins;
-       nsp_pinctrl_desc.npins = num_pins;
 
        pinctrl->pctl = devm_pinctrl_register(&pdev->dev, &nsp_pinctrl_desc,
                                         pinctrl);