greybus: i2c-gb: split out into a stand-alone kernel module.
authorGreg Kroah-Hartman <greg@kroah.com>
Tue, 23 Dec 2014 23:16:54 +0000 (15:16 -0800)
committerGreg Kroah-Hartman <greg@kroah.com>
Wed, 24 Dec 2014 05:04:02 +0000 (21:04 -0800)
This splits the i2c-gb protocol into a stand-alone kernel module.

It's not going to stay in this fashion for long, this was done to test
the "can a protcol be loaded later" logic.  Future refactoring is going
to move the gpbridge protocols to a separate kernel module, where this
protocol is going to live.

But for now, split it out, it is good to test with, and shows a bug in
gbsim at the moment.

Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/staging/greybus/Makefile
drivers/staging/greybus/i2c-gb.c
drivers/staging/greybus/protocol.c
drivers/staging/greybus/protocol.h

index 0d3977d..6ce00c2 100644 (file)
@@ -8,7 +8,6 @@ greybus-y :=    core.o          \
                connection.o    \
                protocol.o      \
                operation.o     \
-               i2c-gb.o        \
                gpio-gb.o       \
                pwm-gb.o        \
                sdio-gb.o       \
@@ -18,6 +17,7 @@ greybus-y :=  core.o          \
                usb-gb.o
 
 obj-m += greybus.o
+obj-m += i2c-gb.o
 obj-m += es1-ap-usb.o
 
 KERNELVER              ?= $(shell uname -r)
index b78de6b..d430bea 100644 (file)
@@ -438,12 +438,6 @@ static struct gb_protocol i2c_protocol = {
        .request_recv           = NULL, /* no incoming requests */
 };
 
-int gb_i2c_protocol_init(void)
-{
-       return gb_protocol_register(&i2c_protocol);
-}
+gb_protocol_driver(&i2c_protocol);
 
-void gb_i2c_protocol_exit(void)
-{
-       gb_protocol_deregister(&i2c_protocol);
-}
+MODULE_LICENSE("GPL v2");
index 2527532..ee8ee3e 100644 (file)
@@ -184,10 +184,6 @@ bool gb_protocol_init(void)
                pr_err("error initializing gpio protocol\n");
                ret = false;
        }
-       if (gb_i2c_protocol_init()) {
-               pr_err("error initializing i2c protocol\n");
-               ret = false;
-       }
        if (gb_pwm_protocol_init()) {
                pr_err("error initializing pwm protocol\n");
                ret = false;
@@ -217,7 +213,6 @@ void gb_protocol_exit(void)
        gb_vibrator_protocol_exit();
        gb_sdio_protocol_exit();
        gb_uart_protocol_exit();
-       gb_i2c_protocol_exit();
        gb_gpio_protocol_exit();
        gb_battery_protocol_exit();
 }
index 49214d6..e2555b7 100644 (file)
@@ -53,9 +53,6 @@ extern void gb_battery_protocol_exit(void);
 extern int gb_gpio_protocol_init(void);
 extern void gb_gpio_protocol_exit(void);
 
-extern int gb_i2c_protocol_init(void);
-extern void gb_i2c_protocol_exit(void);
-
 extern int gb_pwm_protocol_init(void);
 extern void gb_pwm_protocol_exit(void);
 
@@ -74,4 +71,16 @@ extern void gb_usb_protocol_exit(void);
 bool gb_protocol_init(void);
 void gb_protocol_exit(void);
 
+#define gb_protocol_driver(__protocol)                 \
+static int __init protocol_init(void)                  \
+{                                                      \
+       return gb_protocol_register(__protocol);        \
+}                                                      \
+module_init(protocol_init);                            \
+static void __exit protocol_exit(void)                 \
+{                                                      \
+       gb_protocol_deregister(__protocol);             \
+}                                                      \
+module_exit(protocol_exit);
+
 #endif /* __PROTOCOL_H */