summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/connection.c
diff options
context:
space:
mode:
authorAlex Elder2014-10-02 04:54:14 +0200
committerGreg Kroah-Hartman2014-10-03 06:18:41 +0200
commitc68adb2f2c999886f8e18e98ad4e69aec14c9f32 (patch)
treefca422bc25269ef9251fce7eab6ddd8080b13b5b /drivers/staging/greybus/connection.c
parentgreybus: define greybus function abstraction (diff)
downloadkernel-qcow2-linux-c68adb2f2c999886f8e18e98ad4e69aec14c9f32.tar.gz
kernel-qcow2-linux-c68adb2f2c999886f8e18e98ad4e69aec14c9f32.tar.xz
kernel-qcow2-linux-c68adb2f2c999886f8e18e98ad4e69aec14c9f32.zip
greybus: introduce a connection abstraction
Within a UniPro network a pair of CPorts can be linked to form a UniPro Connection. This patch creates a new abstraction to represent an AP CPort that is connected with a CPort used by a function within a Greybus module. 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.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c
new file mode 100644
index 000000000000..113c98542858
--- /dev/null
+++ b/drivers/staging/greybus/connection.c
@@ -0,0 +1,48 @@
+/*
+ * Greybus connections
+ *
+ * Copyright 2014 Google Inc.
+ *
+ * Released under the GPLv2 only.
+ */
+
+#include "greybus.h"
+
+/*
+ * Set up a Greybus connection, representing the bidirectional link
+ * between a CPort on a (local) Greybus host device and a CPort on
+ * another Greybus module.
+ *
+ * Returns a pointer to the new connection if successful, or a null
+ * pointer otherwise.
+ */
+struct gb_connection *gb_connection_create(struct greybus_host_device *hd,
+ u16 cport_id, struct gb_function *function)
+{
+ struct gb_connection *connection;
+
+ connection = kzalloc(sizeof(*connection), GFP_KERNEL);
+ if (!connection)
+ return NULL;
+
+ connection->hd = hd; /* XXX refcount? */
+ connection->cport_id = cport_id;
+ connection->function = function; /* XXX refcount? */
+
+ return connection;
+}
+
+/*
+ * Tear down a previously set up connection.
+ */
+void gb_connection_destroy(struct gb_connection *connection)
+{
+ if (WARN_ON(!connection))
+ return;
+
+ /* XXX Need to wait for any outstanding requests to complete */
+
+ /* kref_put(function); */
+ /* kref_put(hd); */
+ kfree(connection);
+}