module.o \
interface.o \
function.o \
+ connection.o \
i2c-gb.o \
gpio-gb.o \
sdio-gb.o \
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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 */
.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;
#include "module.h"
#include "interface.h"
#include "function.h"
+#include "connection.h"
/* Matches up with the Greybus Protocol specification document */
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))));