]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
greybus: record a gbuf's destination CPort id
authorAlex Elder <elder@linaro.org>
Mon, 17 Nov 2014 14:08:41 +0000 (08:08 -0600)
committerGreg Kroah-Hartman <greg@kroah.com>
Mon, 17 Nov 2014 18:41:19 +0000 (10:41 -0800)
Rather than indicating whether a gbuf is intended for outbound data,
record its destination CPort id.  That's what's really needed by
the ES1 host driver.  Use CPORT_ID_BAD when the buffer is intended
for inbound data.

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/gbuf.c
drivers/staging/greybus/greybus.h
drivers/staging/greybus/operation.c

index f82f665261b2288b27c45b3806abf643119c504d..df0af1331370da7be7ec946f8baee58b31623bf6 100644 (file)
@@ -97,7 +97,7 @@ static int alloc_gbuf_data(struct gbuf *gbuf, unsigned int size,
                                gfp_t gfp_mask)
 {
        struct gb_connection *connection = gbuf->operation->connection;
-       u32 cport_reserve = gbuf->outbound ? 1 : 0;
+       u32 cport_reserve = gbuf->dest_cport_id == CPORT_ID_BAD ? 0 : 1;
        u8 *buffer;
 
        if (size > ES1_GBUF_MSG_SIZE) {
@@ -130,7 +130,7 @@ static int alloc_gbuf_data(struct gbuf *gbuf, unsigned int size,
        }
 
        /* Insert the cport id for outbound buffers */
-       if (gbuf->outbound)
+       if (cport_reserve)
                *buffer++ = connection->interface_cport_id;
        gbuf->transfer_buffer = buffer;
        gbuf->transfer_buffer_length = size;
@@ -147,7 +147,8 @@ static void free_gbuf_data(struct gbuf *gbuf)
        if (!transfer_buffer)
                return;
 
-       if (gbuf->outbound)
+       /* Account for the cport id in outbound buffers */
+       if (gbuf->dest_cport_id != CPORT_ID_BAD)
                transfer_buffer--;      /* Back up to cport id */
        kfree(transfer_buffer);
 }
index d5cfb38d6d750adf5cae507629c402469a9e279c..1b6a31d43a4fecb8b57856703f1fa8ff2930291a 100644 (file)
@@ -35,8 +35,8 @@ static struct kmem_cache *gbuf_head_cache;
  * hardware designers for this issue...
  */
 struct gbuf *greybus_alloc_gbuf(struct gb_operation *operation,
+                               u16 dest_cport_id,
                                unsigned int size,
-                               bool outbound,
                                gfp_t gfp_mask)
 {
        struct greybus_host_device *hd = operation->connection->hd;
@@ -49,7 +49,7 @@ struct gbuf *greybus_alloc_gbuf(struct gb_operation *operation,
 
        kref_init(&gbuf->kref);
        gbuf->operation = operation;
-       gbuf->outbound = outbound;
+       gbuf->dest_cport_id = dest_cport_id;
        gbuf->status = -EBADR;  /* Initial value--means "never set" */
 
        /* Host controller specific allocation for the actual buffer */
index 41be5792443c379a317d94c4d681f45281271524..b817c7615516c0dcc4374877ceaacc38a2b032af 100644 (file)
@@ -122,12 +122,12 @@ struct gbuf {
        struct kref kref;
 
        struct gb_operation *operation;
+       u16 dest_cport_id;              /* Destination CPort id */
        int status;
+
        void *transfer_buffer;
        u32 transfer_buffer_length;
 
-       bool outbound;                  /* AP-relative data direction */
-
        void *hcd_data;                 /* for the HCD to track the gbuf */
 };
 
@@ -182,7 +182,7 @@ void greybus_cport_in(struct greybus_host_device *hd, u16 cport_id,
                        u8 *data, size_t length);
 
 struct gbuf *greybus_alloc_gbuf(struct gb_operation *operation,
-                               unsigned int size, bool outbound,
+                               u16 dest_cport_id, unsigned int size,
                                gfp_t gfp_mask);
 void greybus_free_gbuf(struct gbuf *gbuf);
 struct gbuf *greybus_get_gbuf(struct gbuf *gbuf);
index 2b33d336bfad9e9718cb4d329abd71deea1bbc51..24e0a525821a0dd22fc18f938c38722000f91c46 100644 (file)
@@ -203,12 +203,17 @@ static struct gbuf *gb_operation_gbuf_create(struct gb_operation *operation,
        struct gb_operation_msg_hdr *header;
        struct gbuf *gbuf;
        gfp_t gfp_flags = data_out ? GFP_KERNEL : GFP_ATOMIC;
+       u16 dest_cport_id;
 
        if (size > GB_OPERATION_MESSAGE_SIZE_MAX)
                return NULL;    /* Message too big */
 
+       if (data_out)
+               dest_cport_id = operation->connection->interface_cport_id;
+       else
+               dest_cport_id = CPORT_ID_BAD;
        size += sizeof(*header);
-       gbuf = greybus_alloc_gbuf(operation, size, data_out, gfp_flags);
+       gbuf = greybus_alloc_gbuf(operation, dest_cport_id, size, gfp_flags);
        if (!gbuf)
                return NULL;