return 0;
}
-int gb_connection_enable(struct gb_connection *connection)
+int gb_connection_enable(struct gb_connection *connection,
+ gb_request_handler_t handler)
{
int ret;
goto err_hd_cport_disable;
spin_lock_irq(&connection->lock);
+ connection->handler = handler;
connection->state = GB_CONNECTION_STATE_ENABLED;
spin_unlock_irq(&connection->lock);
}
EXPORT_SYMBOL_GPL(gb_connection_disable);
+static int gb_legacy_request_handler(struct gb_operation *operation)
+{
+ struct gb_protocol *protocol = operation->connection->protocol;
+
+ return protocol->request_recv(operation->type, operation);
+}
+
int gb_connection_legacy_init(struct gb_connection *connection)
{
+ gb_request_handler_t handler;
int ret;
ret = gb_connection_bind_protocol(connection);
if (ret)
return ret;
- ret = gb_connection_enable(connection);
+ if (connection->protocol->request_recv)
+ handler = gb_legacy_request_handler;
+ else
+ handler = NULL;
+
+ ret = gb_connection_enable(connection, handler);
if (ret)
goto err_unbind_protocol;
GB_CONNECTION_STATE_DESTROYING = 3,
};
+struct gb_operation;
+
+typedef int (*gb_request_handler_t)(struct gb_operation *);
+
struct gb_connection {
struct gb_host_device *hd;
struct gb_interface *intf;
struct list_head hd_links;
struct list_head bundle_links;
+ gb_request_handler_t handler;
+
struct gb_protocol *protocol;
u8 protocol_id;
u8 major;
return !connection->intf;
}
-int gb_connection_enable(struct gb_connection *connection);
+int gb_connection_enable(struct gb_connection *connection,
+ gb_request_handler_t handler);
void gb_connection_disable(struct gb_connection *connection);
int gb_connection_legacy_init(struct gb_connection *connection);
static void gb_operation_request_handle(struct gb_operation *operation)
{
struct gb_connection *connection = operation->connection;
- struct gb_protocol *protocol = connection->protocol;
int status;
int ret;
- if (!protocol)
- return;
-
- if (protocol->request_recv) {
- status = protocol->request_recv(operation->type, operation);
+ if (connection->handler) {
+ status = connection->handler(operation);
} else {
dev_err(&connection->hd->dev,
"%s: unexpected incoming request of type 0x%02x\n",