From d52b35f6b62c8b9e1b7e10010daa0370f8252f1d Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Tue, 19 May 2015 11:22:46 +0200 Subject: [PATCH] greybus: operation: add helper to retrieve max payload size Add helper to retrieve the maximum payload size for operations on a specific connection. Note that the helper is not inlined due to how the header files are currently organised, but it is not expected to be called after a connection has been initialised either. Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/operation.c | 8 ++++++++ drivers/staging/greybus/operation.h | 1 + 2 files changed, 9 insertions(+) diff --git a/drivers/staging/greybus/operation.c b/drivers/staging/greybus/operation.c index c78ccc0..f595b97 100644 --- a/drivers/staging/greybus/operation.c +++ b/drivers/staging/greybus/operation.c @@ -504,6 +504,14 @@ struct gb_operation *gb_operation_create(struct gb_connection *connection, } EXPORT_SYMBOL_GPL(gb_operation_create); +size_t gb_operation_get_payload_size_max(struct gb_connection *connection) +{ + struct greybus_host_device *hd = connection->hd; + + return hd->buffer_size_max - sizeof(struct gb_operation_msg_hdr); +} +EXPORT_SYMBOL_GPL(gb_operation_get_payload_size_max); + static struct gb_operation * gb_operation_create_incoming(struct gb_connection *connection, u16 id, u8 type, void *data, size_t size) diff --git a/drivers/staging/greybus/operation.h b/drivers/staging/greybus/operation.h index 740aacc..0199976 100644 --- a/drivers/staging/greybus/operation.h +++ b/drivers/staging/greybus/operation.h @@ -130,6 +130,7 @@ void gb_connection_recv(struct gb_connection *connection, int gb_operation_result(struct gb_operation *operation); +size_t gb_operation_get_payload_size_max(struct gb_connection *connection); struct gb_operation *gb_operation_create(struct gb_connection *connection, u8 type, size_t request_size, size_t response_size); -- 2.7.4