From: Lars-Peter Clausen <lars@metafoo.de>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: Alan Stern <stern@rowland.harvard.edu>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC] USB: create module_usb_serial_driver macro
Date: Sat, 25 Feb 2012 12:53:51 +0100 [thread overview]
Message-ID: <4F48CBCF.7060004@metafoo.de> (raw)
In-Reply-To: <20120224233814.GA16588@kroah.com>
On 02/25/2012 12:38 AM, Greg KH wrote:
> Now that Alan Stern has cleaned up the usb serial driver registration,
> we have the ability to create a module_usb_serial_driver macro to make
> things a bit simpler, like the other *_driver macros created.
>
> But, as we need two functions here, we can't reuse the existing
> module_driver() macro, so we need to roll our own.
>
> Lars-Peter, or anyone else, am I missing something here and we can use
> module_driver() somehow, or even modify it, to work for subsystems that
> need 2 parameters for their function calls to register/deregister?
>
I suppose we can make module_driver a variadic macro and pass any additional
parameters to the register and unregister functions. Patch attached.
- Lars
8<-------------------------------------------------------------------->8
>From 0d731970249b787748eccd6e81890c012a44e5a6 Mon Sep 17 00:00:00 2001
From: Lars-Peter Clausen <lars@metafoo.de>
Date: Sat, 25 Feb 2012 11:25:58 +0100
Subject: [PATCH] driver-core: Allow additional parameters for module_driver
Allow module_driver take additional parameters which will be passed to the
register and unregister function calls. This allows it to be used in cases
where additional parameters are required (e.g. usb_serial_register_drivers).
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
include/linux/device.h | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/include/linux/device.h b/include/linux/device.h
index b63fb39..bccccef 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -1007,19 +1007,20 @@ extern long sysfs_deprecated;
* @__driver: driver name
* @__register: register function for this driver type
* @__unregister: unregister function for this driver type
+ * @...: Additional arguments to be passed to __register and __unregister.
*
* Use this macro to construct bus specific macros for registering
* drivers, and do not use it on its own.
*/
-#define module_driver(__driver, __register, __unregister) \
+#define module_driver(__driver, __register, __unregister, ...) \
static int __init __driver##_init(void) \
{ \
- return __register(&(__driver)); \
+ return __register(&(__driver) , ##__VA_ARGS__); \
} \
module_init(__driver##_init); \
static void __exit __driver##_exit(void) \
{ \
- __unregister(&(__driver)); \
+ __unregister(&(__driver) , ##__VA_ARGS__); \
} \
module_exit(__driver##_exit);
--
1.7.2.5
next prev parent reply other threads:[~2012-02-25 11:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-24 23:38 [RFC] USB: create module_usb_serial_driver macro Greg KH
2012-02-25 11:53 ` Lars-Peter Clausen [this message]
2012-03-10 0:30 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2012-02-24 22:47 Greg KH
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=4F48CBCF.7060004@metafoo.de \
--to=lars@metafoo.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.