Skip to content

Commit 2d4a628

Browse files
prabhakarladgeertu
authored andcommitted
pinctrl: renesas: rzg2l: Add BUILD_BUG_ON() checks
Add BUILD_BUG_ON() checks to avoid overflows for GPIO configs for each supported SoC. While at it, for readability set n_port_pins based on the GPIO pin configs and not on GPIO names for r9a07g044_data as done for r9a07g043_data. Suggested-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Lad Prabhakar <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Acked-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent 00dfe29 commit 2d4a628

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/pinctrl/renesas/pinctrl-rzg2l.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,12 @@ static int rzg2l_pinctrl_probe(struct platform_device *pdev)
14681468
struct rzg2l_pinctrl *pctrl;
14691469
int ret;
14701470

1471+
BUILD_BUG_ON(ARRAY_SIZE(rzg2l_gpio_configs) * RZG2L_PINS_PER_PORT >
1472+
ARRAY_SIZE(rzg2l_gpio_names));
1473+
1474+
BUILD_BUG_ON(ARRAY_SIZE(r9a07g043_gpio_configs) * RZG2L_PINS_PER_PORT >
1475+
ARRAY_SIZE(rzg2l_gpio_names));
1476+
14711477
pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);
14721478
if (!pctrl)
14731479
return -ENOMEM;
@@ -1531,7 +1537,7 @@ static struct rzg2l_pinctrl_data r9a07g044_data = {
15311537
.port_pin_configs = rzg2l_gpio_configs,
15321538
.n_ports = ARRAY_SIZE(rzg2l_gpio_configs),
15331539
.dedicated_pins = rzg2l_dedicated_pins.common,
1534-
.n_port_pins = ARRAY_SIZE(rzg2l_gpio_names),
1540+
.n_port_pins = ARRAY_SIZE(rzg2l_gpio_configs) * RZG2L_PINS_PER_PORT,
15351541
.n_dedicated_pins = ARRAY_SIZE(rzg2l_dedicated_pins.common) +
15361542
ARRAY_SIZE(rzg2l_dedicated_pins.rzg2l_pins),
15371543
};

0 commit comments

Comments
 (0)