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

mfd: sta2x11: Use platform_register/unregister_drivers()

These new helpers simplify implementing multi-driver modules and
properly handle failure to register one driver by unregistering all
previously registered drivers.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Thierry Reding and committed by
Lee Jones
d91d76d8 742dcd11

+11 -27
+11 -27
drivers/mfd/sta2x11-mfd.c
··· 372 372 .probe = sta2x11_sctl_probe, 373 373 }; 374 374 375 - static int __init sta2x11_sctl_init(void) 376 - { 377 - pr_info("%s\n", __func__); 378 - return platform_driver_register(&sta2x11_sctl_platform_driver); 379 - } 380 - 381 375 static struct platform_driver sta2x11_platform_driver = { 382 376 .driver = { 383 377 .name = STA2X11_MFD_APBREG_NAME, 384 378 }, 385 379 .probe = sta2x11_apbreg_probe, 386 380 }; 387 - 388 - static int __init sta2x11_apbreg_init(void) 389 - { 390 - pr_info("%s\n", __func__); 391 - return platform_driver_register(&sta2x11_platform_driver); 392 - } 393 381 394 382 static struct platform_driver sta2x11_apb_soc_regs_platform_driver = { 395 383 .driver = { ··· 386 398 .probe = sta2x11_apb_soc_regs_probe, 387 399 }; 388 400 389 - static int __init sta2x11_apb_soc_regs_init(void) 390 - { 391 - pr_info("%s\n", __func__); 392 - return platform_driver_register(&sta2x11_apb_soc_regs_platform_driver); 393 - } 394 - 395 401 static struct platform_driver sta2x11_scr_platform_driver = { 396 402 .driver = { 397 403 .name = STA2X11_MFD_SCR_NAME, ··· 393 411 .probe = sta2x11_scr_probe, 394 412 }; 395 413 396 - static int __init sta2x11_scr_init(void) 397 - { 398 - pr_info("%s\n", __func__); 399 - return platform_driver_register(&sta2x11_scr_platform_driver); 400 - } 414 + static struct platform_driver * const drivers[] = { 415 + &sta2x11_platform_driver, 416 + &sta2x11_sctl_platform_driver, 417 + &sta2x11_apb_soc_regs_platform_driver, 418 + &sta2x11_scr_platform_driver, 419 + }; 401 420 421 + static int __init sta2x11_drivers_init(void) 422 + { 423 + return platform_register_drivers(drivers, ARRAY_SIZE(drivers)); 424 + } 402 425 403 426 /* 404 427 * What follows are the PCI devices that host the above pdevs. ··· 651 664 * prepares platform drivers very early and probe the PCI device later, 652 665 * but before other PCI devices. 653 666 */ 654 - subsys_initcall(sta2x11_apbreg_init); 655 - subsys_initcall(sta2x11_sctl_init); 656 - subsys_initcall(sta2x11_apb_soc_regs_init); 657 - subsys_initcall(sta2x11_scr_init); 667 + subsys_initcall(sta2x11_drivers_init); 658 668 rootfs_initcall(sta2x11_mfd_init); 659 669 660 670 MODULE_LICENSE("GPL v2");