mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 11:06:41 -05:00
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>
This commit is contained in:
committed by
Linus Walleij
parent
fa856a2c3f
commit
9b2ae7ca1a
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user