From 18079ece816b3b272b114b770e636f4e5567b028 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Fri, 27 May 2016 17:26:35 +0200 Subject: [PATCH] greybus: operation: add helper for creating core operations Add a new core operation flag and a helper that core can use to create core operations. This will be used to implement the ping operations that core sends as part of connection tear down. Note that a new trace point is also added. Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/greybus_trace.h | 5 +++++ drivers/staging/greybus/operation.c | 20 ++++++++++++++++++++ drivers/staging/greybus/operation.h | 12 ++++++++++++ 3 files changed, 37 insertions(+) diff --git a/drivers/staging/greybus/greybus_trace.h b/drivers/staging/greybus/greybus_trace.h index 93e04a8..148ffaf 100644 --- a/drivers/staging/greybus/greybus_trace.h +++ b/drivers/staging/greybus/greybus_trace.h @@ -131,6 +131,11 @@ DECLARE_EVENT_CLASS(gb_operation, DEFINE_OPERATION_EVENT(gb_operation_create); /* + * Occurs after a new core operation has been created. + */ +DEFINE_OPERATION_EVENT(gb_operation_create_core); + +/* * Occurs after a new operation has been created for an incoming * request has been successfully created and initialized. */ diff --git a/drivers/staging/greybus/operation.c b/drivers/staging/greybus/operation.c index 75d1231..fb4a29e 100644 --- a/drivers/staging/greybus/operation.c +++ b/drivers/staging/greybus/operation.c @@ -571,6 +571,26 @@ gb_operation_create_flags(struct gb_connection *connection, } EXPORT_SYMBOL_GPL(gb_operation_create_flags); +struct gb_operation * +gb_operation_create_core(struct gb_connection *connection, + u8 type, size_t request_size, + size_t response_size, unsigned long flags, + gfp_t gfp) +{ + struct gb_operation *operation; + + flags |= GB_OPERATION_FLAG_CORE; + + operation = gb_operation_create_common(connection, type, + request_size, response_size, + flags, gfp); + if (operation) + trace_gb_operation_create_core(operation); + + return operation; +} +/* Do not export this function. */ + size_t gb_operation_get_payload_size_max(struct gb_connection *connection) { struct gb_host_device *hd = connection->hd; diff --git a/drivers/staging/greybus/operation.h b/drivers/staging/greybus/operation.h index 117d7df..de09a2c 100644 --- a/drivers/staging/greybus/operation.h +++ b/drivers/staging/greybus/operation.h @@ -60,6 +60,7 @@ struct gb_message { #define GB_OPERATION_FLAG_INCOMING BIT(0) #define GB_OPERATION_FLAG_UNIDIRECTIONAL BIT(1) #define GB_OPERATION_FLAG_SHORT_RESPONSE BIT(2) +#define GB_OPERATION_FLAG_CORE BIT(3) #define GB_OPERATION_FLAG_USER_MASK (GB_OPERATION_FLAG_SHORT_RESPONSE | \ GB_OPERATION_FLAG_UNIDIRECTIONAL) @@ -123,6 +124,11 @@ gb_operation_short_response_allowed(struct gb_operation *operation) return operation->flags & GB_OPERATION_FLAG_SHORT_RESPONSE; } +static inline bool gb_operation_is_core(struct gb_operation *operation) +{ + return operation->flags & GB_OPERATION_FLAG_CORE; +} + void gb_connection_recv(struct gb_connection *connection, void *data, size_t size); @@ -144,6 +150,12 @@ gb_operation_create(struct gb_connection *connection, response_size, 0, gfp); } +struct gb_operation * +gb_operation_create_core(struct gb_connection *connection, + u8 type, size_t request_size, + size_t response_size, unsigned long flags, + gfp_t gfp); + void gb_operation_get(struct gb_operation *operation); void gb_operation_put(struct gb_operation *operation); -- 2.7.4