]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
greybus: get rid of functions now...
authorAlex Elder <elder@linaro.org>
Thu, 2 Oct 2014 17:30:05 +0000 (12:30 -0500)
committerGreg Kroah-Hartman <greg@kroah.com>
Fri, 3 Oct 2014 04:22:45 +0000 (21:22 -0700)
We decided yesterday that we would no longer support the notion of a
"function."  Instead, a connection will simply exist between the AP
and an interface on a module (and a CPort Id on each end).  What
was previously considered the "function type" will now be handled
as the "protocol" associated with the connection.

Update gb_connection_create() to take just the interface and a cport
id associated with that interface.

Right now every module points back to a host device, so for now
we'll establish the connection back to that.

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
drivers/staging/greybus/connection.h
drivers/staging/greybus/function.c [deleted file]
drivers/staging/greybus/function.h [deleted file]
drivers/staging/greybus/greybus.h
drivers/staging/greybus/manifest.c
drivers/staging/greybus/operation.c

index a303f81a542de45d8c6ce33da0121a50f5446438..42a3944f4eeb2253a30096da603637550a2e3336 100644 (file)
@@ -6,7 +6,6 @@ greybus-y :=    core.o          \
                manifest.o      \
                module.o        \
                interface.o     \
-               function.o      \
                connection.o    \
                operation.o     \
                i2c-gb.o        \
index b16ac4c0cc818c1447217d003934cd8dccf5e899..f3f774d2ed7b848660dbaf6785e04d4783d5aa3e 100644 (file)
  * 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,
-                               struct gb_function *function)
+struct gb_connection *gb_connection_create(struct gb_interface *interface,
+                                               u16 cport_id)
 {
        struct gb_connection *connection;
+       struct greybus_host_device *hd;
 
        connection = kzalloc(sizeof(*connection), GFP_KERNEL);
        if (!connection)
                return NULL;
 
-       connection->cport_id = greybus_hd_cport_id_alloc(hd);
-       if (connection->cport_id == CPORT_ID_BAD) {
+       hd = interface->gmod->hd;
+       connection->hd_cport_id = greybus_hd_cport_id_alloc(hd);
+       if (connection->hd_cport_id == CPORT_ID_BAD) {
                kfree(connection);
                return NULL;
        }
-
        connection->hd = hd;                    /* XXX refcount? */
-       connection->function = function;        /* XXX refcount? */
+       connection->interface = interface;      /* XXX refcount? */
+       connection->interface_cport_id = cport_id;
        INIT_LIST_HEAD(&connection->operations);
        atomic_set(&connection->op_cycle, 0);
 
@@ -56,9 +58,9 @@ void gb_connection_destroy(struct gb_connection *connection)
        /* XXX Need to wait for any outstanding requests to complete */
        WARN_ON(!list_empty(&connection->operations));
 
-       greybus_hd_cport_id_free(connection->hd, connection->cport_id);
-       /* kref_put(function); */
-       /* kref_put(hd); */
+       greybus_hd_cport_id_free(connection->hd, connection->hd_cport_id);
+       /* kref_put(connection->interface); */
+       /* kref_put(connection->hd); */
        kfree(connection);
 }
 
index f06ff92d74875f15dbfffe21c94a8eec68b88aca..530d6451c75d9105c6cff3cda5fa166a552dce8e 100644 (file)
 #include "greybus.h"
 
 struct gb_connection {
-       struct gb_function              *function;
        struct greybus_host_device      *hd;
-       u16                             cport_id;       /* Host side */
+       struct gb_interface             *interface;
+       u16                             hd_cport_id;
+       u16                             interface_cport_id;
 
-       struct list_head                host_links;
+       struct list_head                hd_links;
+       struct list_head                interface_links;
+       /* protocol */
 
        struct list_head                operations;
        atomic_t                        op_cycle;
 };
 
-struct gb_connection *gb_connection_create(struct greybus_host_device *hd,
-                                       struct gb_function *function);
+struct gb_connection *gb_connection_create(struct gb_interface *interface,
+                                               u16 cport_id);
 void gb_connection_destroy(struct gb_connection *connection);
 
 u16 gb_connection_op_id(struct gb_connection *connection);
diff --git a/drivers/staging/greybus/function.c b/drivers/staging/greybus/function.c
deleted file mode 100644 (file)
index bfc9ac7..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Greybus functions
- *
- * Copyright 2014 Google Inc.
- *
- * Released under the GPLv2 only.
- */
-
-#include "greybus.h"
-
-/* XXX This could be per-host device or per-module or per-interface */
-static DEFINE_SPINLOCK(gb_functions_lock);
-
-/*
- * A Greybus function generically defines an entity associated with
- * a CPort within a module.  Each function has a type (e.g. i2c,
- * GPIO, etc.) that defines how it behaves and how the AP interacts
- * with it.
- *
- * Create a gb_function structure to represent a discovered
- * function.  Returns a pointer to the new function or a null
- * pointer if a failure occurs due to memory exhaustion.
- */
-struct gb_function *gb_function_create(struct gb_interface *interface,
-                                       u16 cport_id)
-{
-       struct gb_function *function;
-
-       function = kzalloc(sizeof(*function), GFP_KERNEL);
-       if (!function)
-               return NULL;
-
-       function->interface = interface;        /* XXX refcount? */
-       function->cport_id = cport_id;
-
-       spin_lock_irq(&gb_functions_lock);
-       list_add_tail(&function->links, &interface->functions);
-       spin_unlock_irq(&gb_functions_lock);
-
-       return function;
-}
-
-/*
- * Tear down a previously set up function.
- */
-void gb_function_destroy(struct gb_function *function)
-{
-       if (WARN_ON(!function))
-               return;
-
-       spin_lock_irq(&gb_functions_lock);
-       list_del(&function->links);
-       spin_unlock_irq(&gb_functions_lock);
-
-       /* kref_put(gmod); */
-       kfree(function);
-}
diff --git a/drivers/staging/greybus/function.h b/drivers/staging/greybus/function.h
deleted file mode 100644 (file)
index e1b30c5..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Greybus functions
- *
- * Copyright 2014 Google Inc.
- *
- * Released under the GPLv2 only.
- */
-
-#ifndef __FUNCTION_H
-#define __FUNCTION_H
-
-struct gb_function {
-       struct gb_interface             *interface;
-       u16                             cport_id;
-
-       struct list_head                links;  /* interface->functions */
-};
-
-struct gb_function *gb_function_create(struct gb_interface *interface,
-                                       u16 cport_id);
-void gb_function_destroy(struct gb_function *function);
-
-#endif /* __FUNCTION_H */
index 077daf0a92bfac88a8fef676de1c8e64c3251dc9..0813201260b18e6b06f2a8ac545597eedaf69cd3 100644 (file)
@@ -24,7 +24,6 @@
 #include "manifest.h"
 #include "module.h"
 #include "interface.h"
-#include "function.h"
 #include "connection.h"
 #include "operation.h"
 
index 4066547cd2e5c6298f50473200bf0cc77a2a56c0..6411c26928b33b8620368f485e4ca14cd3d258c6 100644 (file)
@@ -204,7 +204,7 @@ u32 gb_manifest_parse_cports(struct gb_interface *interface)
                /* Found one.  Set up its function structure */
                protocol = (enum greybus_protocol)desc_cport->protocol;
                cport_id = le16_to_cpu(desc_cport->id);
-               if (!gb_function_create(interface, cport_id))
+               if (!gb_connection_create(interface, cport_id))
                        return 0;       /* Error */
 
                count++;
index 5cb23aa3867a76fd211132d234a1f0ce749d510b..b930d24ce552fd02719078620d653fe3d2bc9eda 100644 (file)
@@ -124,8 +124,8 @@ struct gb_operation *gb_operation_create(struct gb_connection *connection,
 
        /* Our buffer holds a header in addition to the requested payload */
        size += sizeof(*header);
-       gbuf = greybus_alloc_gbuf(connection->function->interface->gmod,
-                               connection->cport_id,
+       gbuf = greybus_alloc_gbuf(connection->interface->gmod,
+                               connection->hd_cport_id,
                                gbuf_out_callback, size,
                                GFP_KERNEL, operation);
        if (gbuf) {