greybus: rework message initialization
Rework gb_opreation_message_init() so it doesn't use a struct gbuf local variable. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
This commit is contained in:
parent
58a5bdc735
commit
6a70736aca
|
@ -228,7 +228,6 @@ static int gb_operation_message_init(struct gb_operation *operation,
|
||||||
struct greybus_host_device *hd = connection->hd;
|
struct greybus_host_device *hd = connection->hd;
|
||||||
struct gb_message *message;
|
struct gb_message *message;
|
||||||
struct gb_operation_msg_hdr *header;
|
struct gb_operation_msg_hdr *header;
|
||||||
struct gbuf *gbuf;
|
|
||||||
gfp_t gfp_flags = request && !outbound ? GFP_ATOMIC : GFP_KERNEL;
|
gfp_t gfp_flags = request && !outbound ? GFP_ATOMIC : GFP_KERNEL;
|
||||||
u16 dest_cport_id;
|
u16 dest_cport_id;
|
||||||
|
|
||||||
|
@ -242,23 +241,22 @@ static int gb_operation_message_init(struct gb_operation *operation,
|
||||||
message = &operation->response;
|
message = &operation->response;
|
||||||
type |= GB_OPERATION_TYPE_RESPONSE;
|
type |= GB_OPERATION_TYPE_RESPONSE;
|
||||||
}
|
}
|
||||||
gbuf = &message->gbuf;
|
|
||||||
|
|
||||||
if (outbound)
|
if (outbound)
|
||||||
dest_cport_id = connection->interface_cport_id;
|
dest_cport_id = connection->interface_cport_id;
|
||||||
else
|
else
|
||||||
dest_cport_id = CPORT_ID_BAD;
|
dest_cport_id = CPORT_ID_BAD;
|
||||||
|
|
||||||
gbuf->transfer_buffer = hd->driver->buffer_alloc(size, gfp_flags);
|
message->gbuf.transfer_buffer = hd->driver->buffer_alloc(size, gfp_flags);
|
||||||
if (!gbuf->transfer_buffer)
|
if (!message->gbuf.transfer_buffer)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
gbuf->transfer_buffer_length = size;
|
message->gbuf.transfer_buffer_length = size;
|
||||||
gbuf->hd = hd;
|
message->gbuf.hd = hd;
|
||||||
gbuf->dest_cport_id = dest_cport_id;
|
message->gbuf.dest_cport_id = dest_cport_id;
|
||||||
gbuf->status = -EBADR; /* Initial value--means "never set" */
|
message->gbuf.status = -EBADR; /* Initial value--means "never set" */
|
||||||
|
|
||||||
/* Fill in the header structure */
|
/* Fill in the header structure */
|
||||||
header = (struct gb_operation_msg_hdr *)gbuf->transfer_buffer;
|
header = message->gbuf.transfer_buffer;
|
||||||
header->size = cpu_to_le16(size);
|
header->size = cpu_to_le16(size);
|
||||||
header->id = 0; /* Filled in when submitted */
|
header->id = 0; /* Filled in when submitted */
|
||||||
header->type = type;
|
header->type = type;
|
||||||
|
|
Loading…
Reference in New Issue