]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
greybus: connection: add offloaded connection flag
authorJohan Hovold <johan@hovoldconsulting.com>
Wed, 11 May 2016 08:17:56 +0000 (10:17 +0200)
committerGreg Kroah-Hartman <gregkh@google.com>
Fri, 13 May 2016 13:30:05 +0000 (15:30 +0200)
Add an offloaded connection flag, which is used to mark a connection as
offloaded and prevent drivers from initiating operation over it.

This will be used for the audio and camera data connections.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/connection.h
drivers/staging/greybus/operation.c

index bb25abf188f35b843dd6980f2b1191a3853fba0d..c740c3816f0d94e238748844ac34dc6e67032742 100644 (file)
@@ -15,6 +15,7 @@
 
 #define GB_CONNECTION_FLAG_CSD         BIT(0)
 #define GB_CONNECTION_FLAG_NO_FLOWCTRL BIT(1)
+#define GB_CONNECTION_FLAG_OFFLOADED   BIT(2)
 
 enum gb_connection_state {
        GB_CONNECTION_STATE_INVALID     = 0,
@@ -95,6 +96,11 @@ gb_connection_flow_control_disabled(struct gb_connection *connection)
        return connection->flags & GB_CONNECTION_FLAG_NO_FLOWCTRL;
 }
 
+static inline bool gb_connection_is_offloaded(struct gb_connection *connection)
+{
+       return connection->flags & GB_CONNECTION_FLAG_OFFLOADED;
+}
+
 static inline void *gb_connection_get_data(struct gb_connection *connection)
 {
        return connection->private;
index 62d0c4546d09b157b3eb141528267e6ceae633a8..716627e863c07ce660bea607d48717694a535502 100644 (file)
@@ -654,6 +654,9 @@ int gb_operation_request_send(struct gb_operation *operation,
        unsigned int cycle;
        int ret;
 
+       if (gb_connection_is_offloaded(connection))
+               return -EBUSY;
+
        if (!callback)
                return -EINVAL;
 
@@ -950,8 +953,9 @@ void gb_connection_recv(struct gb_connection *connection,
        size_t msg_size;
        u16 operation_id;
 
-       if (connection->state != GB_CONNECTION_STATE_ENABLED &&
-               connection->state != GB_CONNECTION_STATE_ENABLED_TX) {
+       if ((connection->state != GB_CONNECTION_STATE_ENABLED &&
+                       connection->state != GB_CONNECTION_STATE_ENABLED_TX) ||
+                       gb_connection_is_offloaded(connection)) {
                dev_warn(dev, "%s: dropping %zu received bytes\n",
                                connection->name, size);
                return;