greybus: pass operation type on request receive
authorAlex Elder <elder@linaro.org>
Wed, 12 Nov 2014 21:17:55 +0000 (15:17 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Nov 2014 21:11:35 +0000 (13:11 -0800)
When an incoming request is received, the operation type is encoded
in the header and is not available in the payload.  Add the
operation type as a parameter to the request_recv method so the
request handler knows what to do.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/greybus/operation.c
drivers/staging/greybus/protocol.h

index 72e5ef9ecad85f3283c9cdc98a74f1bca5104743..f4554528e7ab7cc856eea49d1ec79d128922e506 100644 (file)
@@ -137,16 +137,17 @@ static void gb_operation_request_handle(struct gb_operation *operation)
        struct gb_protocol *protocol = operation->connection->protocol;
        struct gb_operation_msg_hdr *header;
 
+       header = operation->request->transfer_buffer;
+
        /*
         * If the protocol has no incoming request handler, report
         * an error and mark the request bad.
         */
        if (protocol->request_recv) {
-               protocol->request_recv(operation);
+               protocol->request_recv(header->type, operation);
                goto out;
        }
 
-       header = operation->request->transfer_buffer;
        gb_connection_err(operation->connection,
                "unexpected incoming request type 0x%02hhx\n", header->type);
        operation->result = GB_OP_PROTOCOL_BAD;
index f57f0db4f8194b7cf9c71ca921f8498a80c9dcd1..1aeb34068a3fef025d9cab14da587b26b7d641e5 100644 (file)
@@ -15,7 +15,7 @@ struct gb_operation;
 
 typedef int (*gb_connection_init_t)(struct gb_connection *);
 typedef void (*gb_connection_exit_t)(struct gb_connection *);
-typedef void (*gb_request_recv_t)(struct gb_operation *);
+typedef void (*gb_request_recv_t)(u8, struct gb_operation *);
 
 /*
  * Protocols having the same id but different major and/or minor