greybus: gbuf: have caller set actual_length
authorAlex Elder <elder@linaro.org>
Fri, 3 Oct 2014 20:05:19 +0000 (15:05 -0500)
committerGreg Kroah-Hartman <greg@kroah.com>
Sat, 4 Oct 2014 02:02:22 +0000 (19:02 -0700)
A Greybus buffer has both a transfer_buffer_size field, which is the
size in bytes of the transfer buffer, and an actual_length field,
which is the number of bytes in that buffer that are actually
consumed.  The user of the buffer--and not the buffer allocation
method--should be setting the actual_length field.

Stop setting the actual length on the es1-ap-usb alloc_gbuf_data
method.  And *do* set it in gb_operation_create(), where we can
presume the operation being allocated will consume all the bytes
requested.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/staging/greybus/es1-ap-usb.c
drivers/staging/greybus/operation.c

index f23c67414ecf1461d7da61606068e8207359686e..360149923c1724f4054861ee9100095cc7306468 100644 (file)
@@ -126,7 +126,6 @@ static int alloc_gbuf_data(struct gbuf *gbuf, unsigned int size, gfp_t gfp_mask)
        buffer[0] = gbuf->cport_id;
        gbuf->transfer_buffer = &buffer[1];
        gbuf->transfer_buffer_length = size;
-       gbuf->actual_length = size;
 
        /* When we send the gbuf, we need this pointer to be here */
        gbuf->hdpriv = es1;
index fe2f1a7137e5544eacd295b59c8545244e18c190..75f6e50b2ee6fd04f92ddfc46fc1c330d7f50dc0 100644 (file)
@@ -132,6 +132,7 @@ struct gb_operation *gb_operation_create(struct gb_connection *connection,
                kfree(operation);
                return NULL;
        }
+       gbuf->actual_length = size;     /* Record what we'll use */
 
        operation->connection = connection;             /* XXX refcount? */