From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758872AbbLBQUB (ORCPT ); Wed, 2 Dec 2015 11:20:01 -0500 Received: from mail-wm0-f43.google.com ([74.125.82.43]:33434 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750973AbbLBQT6 (ORCPT ); Wed, 2 Dec 2015 11:19:58 -0500 From: Thierry Reding To: Linus Walleij , Alexandre Courbot Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] gpio: mpc5200: Use platform_register/unregister_drivers() Date: Wed, 2 Dec 2015 17:19:55 +0100 Message-Id: <1449073195-11054-1-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thierry Reding 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 --- drivers/gpio/gpio-mpc5200.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-mpc5200.c b/drivers/gpio/gpio-mpc5200.c index 4c542153e923..044bbbb747f2 100644 --- a/drivers/gpio/gpio-mpc5200.c +++ b/drivers/gpio/gpio-mpc5200.c @@ -360,15 +360,14 @@ static struct platform_driver mpc52xx_simple_gpiochip_driver = { .remove = mpc52xx_gpiochip_remove, }; +static struct platform_driver * const drivers[] = { + &mpc52xx_wkup_gpiochip_driver, + &mpc52xx_simple_gpiochip_driver, +}; + static int __init mpc52xx_gpio_init(void) { - if (platform_driver_register(&mpc52xx_wkup_gpiochip_driver)) - printk(KERN_ERR "Unable to register wakeup GPIO driver\n"); - - if (platform_driver_register(&mpc52xx_simple_gpiochip_driver)) - printk(KERN_ERR "Unable to register simple GPIO driver\n"); - - return 0; + return platform_register_drivers(drivers, ARRAY_SIZE(drivers)); } /* Make sure we get initialised before anyone else tries to use us */ @@ -376,9 +375,7 @@ subsys_initcall(mpc52xx_gpio_init); static void __exit mpc52xx_gpio_exit(void) { - platform_driver_unregister(&mpc52xx_wkup_gpiochip_driver); - - platform_driver_unregister(&mpc52xx_simple_gpiochip_driver); + platform_unregister_drivers(drivers, ARRAY_SIZE(drivers)); } module_exit(mpc52xx_gpio_exit); -- 2.5.0