From e1308c1fb675878ace7a489c50b2ae52c598d294 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 24 Dec 2014 13:01:43 -0800 Subject: [PATCH] greybus: gpb: Create a "GP Bridge" kernel module This bundles together the existing GP Bridged PHY protocols that were part of the Greybus core: USB, UART, SDIO, PWM, and GPIO. This is now a stand-alone kernel module. More logic will be moving here in the future to handle bridged devices. Signed-off-by: Greg Kroah-Hartman Reviewed-by: Alex Elder --- drivers/staging/greybus/Makefile | 9 +++-- drivers/staging/greybus/core.c | 10 ------ drivers/staging/greybus/gpb.c | 70 ++++++++++++++++++++++++++++++++++++++ drivers/staging/greybus/protocol.c | 35 ------------------- drivers/staging/greybus/protocol.h | 3 -- 5 files changed, 76 insertions(+), 51 deletions(-) create mode 100644 drivers/staging/greybus/gpb.c diff --git a/drivers/staging/greybus/Makefile b/drivers/staging/greybus/Makefile index 79cb193..5d73aed 100644 --- a/drivers/staging/greybus/Makefile +++ b/drivers/staging/greybus/Makefile @@ -7,14 +7,17 @@ greybus-y := core.o \ bundle.o \ connection.o \ protocol.o \ - operation.o \ - gpio-gb.o \ - pwm-gb.o \ + operation.o + +gpbridge-y := gpb.o \ sdio-gb.o \ uart-gb.o \ + pwm-gb.o \ + gpio-gb.o \ usb-gb.o obj-m += greybus.o +obj-m += gpbridge.o obj-m += i2c-gb.o obj-m += vibrator-gb.o obj-m += battery-gb.o diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c index f6ca89a..ee8bba5 100644 --- a/drivers/staging/greybus/core.c +++ b/drivers/staging/greybus/core.c @@ -233,17 +233,8 @@ static int __init gb_init(void) goto error_operation; } - if (!gb_protocol_init()) { - /* This only fails for duplicate protocol registration */ - retval = -EEXIST; - pr_err("gb_protocol_init failed\n"); - goto error_protocol; - } - return 0; /* Success */ -error_protocol: - gb_operation_exit(); error_operation: gb_ap_exit(); error_ap: @@ -256,7 +247,6 @@ error_bus: static void __exit gb_exit(void) { - gb_protocol_exit(); gb_operation_exit(); gb_ap_exit(); bus_unregister(&greybus_bus_type); diff --git a/drivers/staging/greybus/gpb.c b/drivers/staging/greybus/gpb.c new file mode 100644 index 0000000..0c4f46c --- /dev/null +++ b/drivers/staging/greybus/gpb.c @@ -0,0 +1,70 @@ +/* + * Greybus GP Bridge driver + * + * Copyright 2014 Google Inc. + * Copyright 2014 Linaro Ltd. + * + * Released under the GPLv2 only. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include + +#include "greybus.h" + + +static int __init gpbridge_init(void) +{ + if (gb_gpio_protocol_init()) { + pr_err("error initializing gpio protocol\n"); + goto error_gpio; + } + if (gb_pwm_protocol_init()) { + pr_err("error initializing pwm protocol\n"); + goto error_pwm; + } + if (gb_uart_protocol_init()) { + pr_err("error initializing uart protocol\n"); + goto error_uart; + } + if (gb_sdio_protocol_init()) { + pr_err("error initializing sdio protocol\n"); + goto error_sdio; + } + if (gb_usb_protocol_init()) { + pr_err("error initializing usb protocol\n"); + goto error_usb; + } + return 0; + +error_usb: + gb_sdio_protocol_exit(); +error_sdio: + gb_uart_protocol_exit(); +error_uart: + gb_pwm_protocol_exit(); +error_pwm: + gb_gpio_protocol_exit(); +error_gpio: + return -EPROTO; +} + +static void __exit gpbridge_exit(void) +{ + gb_usb_protocol_exit(); + gb_sdio_protocol_exit(); + gb_uart_protocol_exit(); + gb_pwm_protocol_exit(); + gb_gpio_protocol_exit(); +} + +module_init(gpbridge_init); +module_exit(gpbridge_exit); + +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/greybus/protocol.c b/drivers/staging/greybus/protocol.c index e32f4ac..654adbc 100644 --- a/drivers/staging/greybus/protocol.c +++ b/drivers/staging/greybus/protocol.c @@ -178,38 +178,3 @@ void gb_protocol_put(struct gb_protocol *protocol) pr_err("protocol id %hhu version %hhu.%hhu not found\n", protocol->id, major, minor); } - -bool gb_protocol_init(void) -{ - bool ret = true; - - if (gb_gpio_protocol_init()) { - pr_err("error initializing gpio protocol\n"); - ret = false; - } - if (gb_pwm_protocol_init()) { - pr_err("error initializing pwm protocol\n"); - ret = false; - } - if (gb_uart_protocol_init()) { - pr_err("error initializing uart protocol\n"); - ret = false; - } - if (gb_sdio_protocol_init()) { - pr_err("error initializing sdio protocol\n"); - ret = false; - } - if (gb_usb_protocol_init()) { - pr_err("error initializing usb protocol\n"); - ret = false; - } - return ret; -} - -void gb_protocol_exit(void) -{ - gb_usb_protocol_exit(); - gb_sdio_protocol_exit(); - gb_uart_protocol_exit(); - gb_gpio_protocol_exit(); -} diff --git a/drivers/staging/greybus/protocol.h b/drivers/staging/greybus/protocol.h index 1acc615..1f6fd74 100644 --- a/drivers/staging/greybus/protocol.h +++ b/drivers/staging/greybus/protocol.h @@ -66,9 +66,6 @@ extern void gb_sdio_protocol_exit(void); extern int gb_usb_protocol_init(void); 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) \ { \ -- 2.7.4