From: Alex Elder Date: Mon, 17 Nov 2014 14:08:41 +0000 (-0600) Subject: greybus: record a gbuf's destination CPort id X-Git-Tag: v4.9-rc1~119^2~378^2~21^2~1882 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=63921d88724168da6d7868aa5eae8def6888a253;p=karo-tx-linux.git greybus: record a gbuf's destination CPort id 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/es1-ap-usb.c b/drivers/staging/greybus/es1-ap-usb.c index f82f665261b2..df0af1331370 100644 --- a/drivers/staging/greybus/es1-ap-usb.c +++ b/drivers/staging/greybus/es1-ap-usb.c @@ -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); } diff --git a/drivers/staging/greybus/gbuf.c b/drivers/staging/greybus/gbuf.c index d5cfb38d6d75..1b6a31d43a4f 100644 --- a/drivers/staging/greybus/gbuf.c +++ b/drivers/staging/greybus/gbuf.c @@ -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 */ diff --git a/drivers/staging/greybus/greybus.h b/drivers/staging/greybus/greybus.h index 41be5792443c..b817c7615516 100644 --- a/drivers/staging/greybus/greybus.h +++ b/drivers/staging/greybus/greybus.h @@ -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); diff --git a/drivers/staging/greybus/operation.c b/drivers/staging/greybus/operation.c index 2b33d336bfad..24e0a525821a 100644 --- a/drivers/staging/greybus/operation.c +++ b/drivers/staging/greybus/operation.c @@ -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;