From 900ceba9e480f49bb8fef688994b4fbdb1688b77 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 23 Dec 2014 15:16:54 -0800 Subject: [PATCH] greybus: i2c-gb: split out into a stand-alone kernel module. 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 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/Makefile | 2 +- drivers/staging/greybus/i2c-gb.c | 10 ++-------- drivers/staging/greybus/protocol.c | 5 ----- drivers/staging/greybus/protocol.h | 15 ++++++++++++--- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/drivers/staging/greybus/Makefile b/drivers/staging/greybus/Makefile index 0d3977d87cd2..6ce00c2b6e97 100644 --- a/drivers/staging/greybus/Makefile +++ b/drivers/staging/greybus/Makefile @@ -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) diff --git a/drivers/staging/greybus/i2c-gb.c b/drivers/staging/greybus/i2c-gb.c index b78de6b4be10..d430beac9d5c 100644 --- a/drivers/staging/greybus/i2c-gb.c +++ b/drivers/staging/greybus/i2c-gb.c @@ -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"); diff --git a/drivers/staging/greybus/protocol.c b/drivers/staging/greybus/protocol.c index 2527532b0514..ee8ee3e15f8e 100644 --- a/drivers/staging/greybus/protocol.c +++ b/drivers/staging/greybus/protocol.c @@ -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(); } diff --git a/drivers/staging/greybus/protocol.h b/drivers/staging/greybus/protocol.h index 49214d6a9af0..e2555b75e334 100644 --- a/drivers/staging/greybus/protocol.h +++ b/drivers/staging/greybus/protocol.h @@ -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 */