INIT_LIST_HEAD(&connection->operations);
INIT_LIST_HEAD(&connection->pending);
- atomic_set(&connection->op_cycle, 0);
return connection;
}
device_del(&connection->dev);
}
-u16 gb_connection_operation_id(struct gb_connection *connection)
-{
- return (u16)(atomic_inc_return(&connection->op_cycle) & (int)U16_MAX);
-}
-
void gb_connection_err(struct gb_connection *connection, const char *fmt, ...)
{
struct va_format vaf;
enum gb_connection_state state;
+ u16 op_cycle;
struct list_head operations;
struct list_head pending; /* awaiting reponse */
- atomic_t op_cycle;
void *private;
};
struct gb_connection *gb_hd_connection_find(struct greybus_host_device *hd,
u16 cport_id);
-u16 gb_connection_operation_id(struct gb_connection *connection);
-
__printf(2, 3)
void gb_connection_err(struct gb_connection *connection, const char *fmt, ...);
struct gb_connection *connection = operation->connection;
struct gb_operation_msg_hdr *header;
- /* Assign the operation's id, and store it in the header of
- * the request message header.
+ /*
+ * Assign the operation's id and move it into its
+ * connection's pending list.
*/
- operation->id = gb_connection_operation_id(connection);
- header = operation->request->transfer_buffer;
- header->id = cpu_to_le16(operation->id);
-
- /* Insert the operation into its connection's pending list */
spin_lock_irq(&gb_operations_lock);
+ operation->id = ++connection->op_cycle;
list_move_tail(&operation->links, &connection->pending);
spin_unlock_irq(&gb_operations_lock);
+
+ /* Store the operation id in the request header */
+ header = operation->request->transfer_buffer;
+ header->id = cpu_to_le16(operation->id);
}
static void gb_pending_operation_remove(struct gb_operation *operation)