Commit e1308c1f authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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: default avatarGreg Kroah-Hartman <greg@kroah.com>
Reviewed-by: default avatarAlex Elder <elder@linaro.org>
parent 7dd26263
......@@ -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
......
......@@ -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 @@ static int __init gb_init(void)
static void __exit gb_exit(void)
{
gb_protocol_exit();
gb_operation_exit();
gb_ap_exit();
bus_unregister(&greybus_bus_type);
......
/*
* 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 <linux/types.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/device.h>
#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");
......@@ -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();
}
......@@ -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) \
{ \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment