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) {
}
/* 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;
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);
}
* 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;
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 */
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 */
};
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);
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;