greybus: protocol: Add gb_gpbridge_protocol_driver()
authorViresh Kumar <viresh.kumar@linaro.org>
Wed, 20 May 2015 11:50:09 +0000 (17:20 +0530)
committerGreg Kroah-Hartman <gregkh@google.com>
Thu, 21 May 2015 05:44:37 +0000 (22:44 -0700)
There are many gpbridge protocol drivers that need gb_protocol_driver()
without the module_init/exit() lines. Lets create one for them.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/protocol.h

index 7958802..95e5b68 100644 (file)
@@ -90,6 +90,7 @@ extern void gb_hid_protocol_exit(void);
 extern int gb_audio_protocol_init(void);
 extern void gb_audio_protocol_exit(void);
 
+/* __protocol: Pointer to struct gb_protocol */
 #define gb_protocol_driver(__protocol)                 \
 static int __init protocol_init(void)                  \
 {                                                      \
@@ -102,6 +103,17 @@ static void __exit protocol_exit(void)                     \
 }                                                      \
 module_exit(protocol_exit)
 
+/* __protocol: string matching name of struct gb_protocol */
+#define gb_gpbridge_protocol_driver(__protocol)                \
+int __init gb_##__protocol##_init(void)                        \
+{                                                      \
+       return gb_protocol_register(&__protocol);       \
+}                                                      \
+void __exit gb_##__protocol##_exit(void)               \
+{                                                      \
+       gb_protocol_deregister(&__protocol);            \
+}                                                      \
+
 /*
  * Macro to create get_version() routine for protocols
  * @__device: name of the device struct