]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
greybus: introduce a connection abstraction
authorAlex Elder <elder@linaro.org>
Thu, 2 Oct 2014 02:54:14 +0000 (21:54 -0500)
committerGreg Kroah-Hartman <greg@kroah.com>
Fri, 3 Oct 2014 04:18:41 +0000 (21:18 -0700)
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>
drivers/staging/greybus/Makefile
drivers/staging/greybus/connection.c [new file with mode: 0644]
drivers/staging/greybus/connection.h [new file with mode: 0644]
drivers/staging/greybus/core.c
drivers/staging/greybus/greybus.h

index 0efb6958322d76a93c602b337db07255f213da15..ed39a5c6b6fd0ef2af928cd52b7c8091952f307a 100644 (file)
@@ -6,6 +6,7 @@ greybus-y :=    core.o          \
                module.o        \
                interface.o     \
                function.o      \
+               connection.o    \
                i2c-gb.o        \
                gpio-gb.o       \
                sdio-gb.o       \
diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c
new file mode 100644 (file)
index 0000000..113c985
--- /dev/null
@@ -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);
+}
diff --git a/drivers/staging/greybus/connection.h b/drivers/staging/greybus/connection.h
new file mode 100644 (file)
index 0000000..79b3b07
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Greybus connections
+ *
+ * Copyright 2014 Google Inc.
+ *
+ * Released under the GPLv2 only.
+ */
+
+#ifndef __CONNECTION_H
+#define __CONNECTION_H
+
+#include <linux/list.h>
+
+#include "greybus.h"
+#include "function.h"
+
+struct gb_connection {
+       struct gb_function              *function;
+       struct greybus_host_device      *hd;
+       u16                             cport_id;       /* Host side */
+
+       struct list_head                host_links;
+};
+
+bool gb_connection_setup(struct greybus_host_device *hd, u16 cport_id,
+                               struct gb_function *function);
+void gb_connection_teardown(struct gb_connection *connection);
+
+#endif /* __CONNECTION_H */
index 934bdebe039cae447648a43f0f6eaa3f7c48c343..eb8f8e522e5ba5bac276400c86e3ee4d099673aa 100644 (file)
@@ -147,12 +147,22 @@ static struct device_type greybus_module_type = {
        .release =      greybus_module_release,
 };
 
+/* XXX
+ * This needs to be driven by the list of functions that the
+ * manifest says are present.
+ */
 static int gb_init_subdevs(struct gb_module *gmod,
                           const struct greybus_module_id *id)
 {
        int retval;
 
        /* Allocate all of the different "sub device types" for this device */
+
+       /* XXX
+        * Decide what exactly we should get supplied for the i2c
+        * probe, and then work that back to what should be present
+        * in the manifest.
+        */
        retval = gb_i2c_probe(gmod, id);
        if (retval)
                goto error_i2c;
index 4eb70af9e006ac092aa2b499118b8a2c1bd38dde..732cc5e51dc4732b4a4937514f65de13fa11f263 100644 (file)
@@ -23,6 +23,7 @@
 #include "module.h"
 #include "interface.h"
 #include "function.h"
+#include "connection.h"
 
 
 /* Matches up with the Greybus Protocol specification document */
@@ -180,6 +181,7 @@ struct greybus_host_device {
        const struct greybus_host_driver *driver;
 
        struct list_head modules;
+       struct list_head connections;
 
        /* Private data for the host driver */
        unsigned long hd_priv[0] __attribute__ ((aligned(sizeof(s64))));