Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pinctrl: ingenic: Only support SoCs enabled in config

Tested on a JZ4740 system (ARCH=mips make qi_lb60_defconfig), this saves
about 14 KiB, by allowing the compiler to garbage-collect all the
functions and tables that correspond to SoCs that were disabled in the
config.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20201213235447.138271-2-paul@crapouillou.net
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Paul Cercueil and committed by
Linus Walleij
9aa35178 1b399bb0

+48 -12
+48 -12
drivers/pinctrl/pinctrl-ingenic.c
··· 2384 2384 unsigned int i; 2385 2385 int err; 2386 2386 2387 + chip_info = of_device_get_match_data(dev); 2388 + if (!chip_info) { 2389 + dev_err(dev, "Unsupported SoC\n"); 2390 + return -EINVAL; 2391 + } 2392 + 2387 2393 jzpc = devm_kzalloc(dev, sizeof(*jzpc), GFP_KERNEL); 2388 2394 if (!jzpc) 2389 2395 return -ENOMEM; ··· 2406 2400 } 2407 2401 2408 2402 jzpc->dev = dev; 2409 - jzpc->info = chip_info = of_device_get_match_data(dev); 2403 + jzpc->info = chip_info; 2410 2404 2411 2405 pctl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctl_desc), GFP_KERNEL); 2412 2406 if (!pctl_desc) ··· 2476 2470 } 2477 2471 2478 2472 static const struct of_device_id ingenic_pinctrl_of_match[] = { 2479 - { .compatible = "ingenic,jz4740-pinctrl", .data = &jz4740_chip_info }, 2480 - { .compatible = "ingenic,jz4725b-pinctrl", .data = &jz4725b_chip_info }, 2481 - { .compatible = "ingenic,jz4760-pinctrl", .data = &jz4760_chip_info }, 2482 - { .compatible = "ingenic,jz4760b-pinctrl", .data = &jz4760_chip_info }, 2483 - { .compatible = "ingenic,jz4770-pinctrl", .data = &jz4770_chip_info }, 2484 - { .compatible = "ingenic,jz4780-pinctrl", .data = &jz4780_chip_info }, 2485 - { .compatible = "ingenic,x1000-pinctrl", .data = &x1000_chip_info }, 2486 - { .compatible = "ingenic,x1000e-pinctrl", .data = &x1000_chip_info }, 2487 - { .compatible = "ingenic,x1500-pinctrl", .data = &x1500_chip_info }, 2488 - { .compatible = "ingenic,x1830-pinctrl", .data = &x1830_chip_info }, 2489 - {}, 2473 + { 2474 + .compatible = "ingenic,jz4740-pinctrl", 2475 + .data = IF_ENABLED(CONFIG_MACH_JZ4740, &jz4740_chip_info) 2476 + }, 2477 + { 2478 + .compatible = "ingenic,jz4725b-pinctrl", 2479 + .data = IF_ENABLED(CONFIG_MACH_JZ4725B, &jz4725b_chip_info) 2480 + }, 2481 + { 2482 + .compatible = "ingenic,jz4760-pinctrl", 2483 + .data = IF_ENABLED(CONFIG_MACH_JZ4760, &jz4760_chip_info) 2484 + }, 2485 + { 2486 + .compatible = "ingenic,jz4760b-pinctrl", 2487 + .data = IF_ENABLED(CONFIG_MACH_JZ4760, &jz4760_chip_info) 2488 + }, 2489 + { 2490 + .compatible = "ingenic,jz4770-pinctrl", 2491 + .data = IF_ENABLED(CONFIG_MACH_JZ4770, &jz4770_chip_info) 2492 + }, 2493 + { 2494 + .compatible = "ingenic,jz4780-pinctrl", 2495 + .data = IF_ENABLED(CONFIG_MACH_JZ4780, &jz4780_chip_info) 2496 + }, 2497 + { 2498 + .compatible = "ingenic,x1000-pinctrl", 2499 + .data = IF_ENABLED(CONFIG_MACH_X1000, &x1000_chip_info) 2500 + }, 2501 + { 2502 + .compatible = "ingenic,x1000e-pinctrl", 2503 + .data = IF_ENABLED(CONFIG_MACH_X1000, &x1000_chip_info) 2504 + }, 2505 + { 2506 + .compatible = "ingenic,x1500-pinctrl", 2507 + .data = IF_ENABLED(CONFIG_MACH_X1500, &x1500_chip_info) 2508 + }, 2509 + { 2510 + .compatible = "ingenic,x1830-pinctrl", 2511 + .data = IF_ENABLED(CONFIG_MACH_X1830, &x1830_chip_info) 2512 + }, 2513 + { /* sentinel */ }, 2490 2514 }; 2491 2515 2492 2516 static struct platform_driver ingenic_pinctrl_driver = {