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 <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
This commit is contained in:
parent
c7d0f258fb
commit
63921d8872
@ -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);
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user