mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Felipe Balbi <balbi@ti.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] usb: gadget: dummy: Use platform_register/unregister_drivers()
Date: Wed,  2 Dec 2015 17:33:53 +0100	[thread overview]
Message-ID: <1449074033-13054-1-git-send-email-thierry.reding@gmail.com> (raw)

From: Thierry Reding <treding@nvidia.com>

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>
---
 drivers/usb/gadget/udc/dummy_hcd.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index dde44450dfa9..5ae6b60cc218 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -2692,6 +2692,11 @@ static struct platform_driver dummy_hcd_driver = {
 	},
 };
 
+static struct platform_driver * const drivers[] = {
+	&dummy_hcd_driver,
+	&dummy_udc_driver,
+};
+
 /*-------------------------------------------------------------------------*/
 #define MAX_NUM_UDC	2
 static struct platform_device *the_udc_pdev[MAX_NUM_UDC];
@@ -2749,12 +2754,9 @@ static int __init init(void)
 			goto err_add_pdata;
 	}
 
-	retval = platform_driver_register(&dummy_hcd_driver);
+	retval = platform_register_drivers(drivers, ARRAY_SIZE(drivers));
 	if (retval < 0)
 		goto err_add_pdata;
-	retval = platform_driver_register(&dummy_udc_driver);
-	if (retval < 0)
-		goto err_register_udc_driver;
 
 	for (i = 0; i < mod_data.num; i++) {
 		retval = platform_device_add(the_hcd_pdev[i]);
@@ -2806,9 +2808,7 @@ err_add_udc:
 	for (i = 0; i < mod_data.num; i++)
 		platform_device_del(the_hcd_pdev[i]);
 err_add_hcd:
-	platform_driver_unregister(&dummy_udc_driver);
-err_register_udc_driver:
-	platform_driver_unregister(&dummy_hcd_driver);
+	platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
 err_add_pdata:
 	for (i = 0; i < mod_data.num; i++)
 		kfree(dum[i]);
@@ -2834,7 +2834,6 @@ static void __exit cleanup(void)
 		platform_device_unregister(the_hcd_pdev[i]);
 		kfree(dum);
 	}
-	platform_driver_unregister(&dummy_udc_driver);
-	platform_driver_unregister(&dummy_hcd_driver);
+	platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
 }
 module_exit(cleanup);
-- 
2.5.0


                 reply	other threads:[~2015-12-02 16:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449074033-13054-1-git-send-email-thierry.reding@gmail.com \
    --to=thierry.reding@gmail.com \
    --cc=balbi@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®