summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/connection.c
diff options
context:
space:
mode:
authorAlex Elder2014-10-16 13:35:35 +0200
committerGreg Kroah-Hartman2014-10-17 18:14:11 +0200
commit574341c67213afdc9dcb5aefb4f6fa84644438bb (patch)
tree1c9069ba64526541840f793f933a4fe860750b08 /drivers/staging/greybus/connection.c
parentgreybus: move receive handling to operation layer (diff)
downloadkernel-qcow2-linux-574341c67213afdc9dcb5aefb4f6fa84644438bb.tar.gz
kernel-qcow2-linux-574341c67213afdc9dcb5aefb4f6fa84644438bb.tar.xz
kernel-qcow2-linux-574341c67213afdc9dcb5aefb4f6fa84644438bb.zip
greybus: add device initialization
Set up the infrastructure for initializing connections based on their protocol. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Diffstat (limited to 'drivers/staging/greybus/connection.c')
-rw-r--r--drivers/staging/greybus/connection.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c
index 740f491bf5fc..0143a4f6bd12 100644
--- a/drivers/staging/greybus/connection.c
+++ b/drivers/staging/greybus/connection.c
@@ -191,3 +191,27 @@ void gb_connection_err(struct gb_connection *connection, const char *fmt, ...)
va_end(args);
}
+
+/*
+ * XXX Protocols should have a set of function pointers:
+ * ->init (called here, to initialize the device)
+ * ->input_handler
+ * ->exit (reverse of init)
+ */
+int gb_connection_init(struct gb_connection *connection)
+{
+ switch (connection->protocol) {
+ case GREYBUS_PROTOCOL_I2C:
+ case GREYBUS_PROTOCOL_CONTROL:
+ case GREYBUS_PROTOCOL_AP:
+ case GREYBUS_PROTOCOL_GPIO:
+ case GREYBUS_PROTOCOL_UART:
+ case GREYBUS_PROTOCOL_HID:
+ case GREYBUS_PROTOCOL_VENDOR:
+ default:
+ gb_connection_err(connection, "unimplemented protocol %u",
+ (u32)connection->protocol);
+ break;
+ }
+ return -ENXIO;
+}