mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 12:21:22 -05:00
pinctrl: bcm: cygnus-nsp: 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-10-b11c1d650384@linaro.org Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
committed by
Linus Walleij
parent
9b2ae7ca1a
commit
dd12fca449
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user