Commit ca1f8f80 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

greybus: connection: add offloaded connection flag

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: default avatarJohan Hovold <johan@hovoldconsulting.com>
Reviewed-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 0e9b41ab
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#define GB_CONNECTION_FLAG_CSD BIT(0) #define GB_CONNECTION_FLAG_CSD BIT(0)
#define GB_CONNECTION_FLAG_NO_FLOWCTRL BIT(1) #define GB_CONNECTION_FLAG_NO_FLOWCTRL BIT(1)
#define GB_CONNECTION_FLAG_OFFLOADED BIT(2)
enum gb_connection_state { enum gb_connection_state {
GB_CONNECTION_STATE_INVALID = 0, GB_CONNECTION_STATE_INVALID = 0,
...@@ -95,6 +96,11 @@ gb_connection_flow_control_disabled(struct gb_connection *connection) ...@@ -95,6 +96,11 @@ gb_connection_flow_control_disabled(struct gb_connection *connection)
return connection->flags & GB_CONNECTION_FLAG_NO_FLOWCTRL; 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) static inline void *gb_connection_get_data(struct gb_connection *connection)
{ {
return connection->private; return connection->private;
......
...@@ -654,6 +654,9 @@ int gb_operation_request_send(struct gb_operation *operation, ...@@ -654,6 +654,9 @@ int gb_operation_request_send(struct gb_operation *operation,
unsigned int cycle; unsigned int cycle;
int ret; int ret;
if (gb_connection_is_offloaded(connection))
return -EBUSY;
if (!callback) if (!callback)
return -EINVAL; return -EINVAL;
...@@ -950,8 +953,9 @@ void gb_connection_recv(struct gb_connection *connection, ...@@ -950,8 +953,9 @@ void gb_connection_recv(struct gb_connection *connection,
size_t msg_size; size_t msg_size;
u16 operation_id; u16 operation_id;
if (connection->state != GB_CONNECTION_STATE_ENABLED && if ((connection->state != GB_CONNECTION_STATE_ENABLED &&
connection->state != GB_CONNECTION_STATE_ENABLED_TX) { connection->state != GB_CONNECTION_STATE_ENABLED_TX) ||
gb_connection_is_offloaded(connection)) {
dev_warn(dev, "%s: dropping %zu received bytes\n", dev_warn(dev, "%s: dropping %zu received bytes\n",
connection->name, size); connection->name, size);
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment