Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>

authored by

Johan Hovold and committed by
Greg Kroah-Hartman
18079ece 77bbbcf6

+37
+5
drivers/staging/greybus/greybus_trace.h
··· 131 131 DEFINE_OPERATION_EVENT(gb_operation_create); 132 132 133 133 /* 134 + * Occurs after a new core operation has been created. 135 + */ 136 + DEFINE_OPERATION_EVENT(gb_operation_create_core); 137 + 138 + /* 134 139 * Occurs after a new operation has been created for an incoming 135 140 * request has been successfully created and initialized. 136 141 */
+20
drivers/staging/greybus/operation.c
··· 571 571 } 572 572 EXPORT_SYMBOL_GPL(gb_operation_create_flags); 573 573 574 + struct gb_operation * 575 + gb_operation_create_core(struct gb_connection *connection, 576 + u8 type, size_t request_size, 577 + size_t response_size, unsigned long flags, 578 + gfp_t gfp) 579 + { 580 + struct gb_operation *operation; 581 + 582 + flags |= GB_OPERATION_FLAG_CORE; 583 + 584 + operation = gb_operation_create_common(connection, type, 585 + request_size, response_size, 586 + flags, gfp); 587 + if (operation) 588 + trace_gb_operation_create_core(operation); 589 + 590 + return operation; 591 + } 592 + /* Do not export this function. */ 593 + 574 594 size_t gb_operation_get_payload_size_max(struct gb_connection *connection) 575 595 { 576 596 struct gb_host_device *hd = connection->hd;
+12
drivers/staging/greybus/operation.h
··· 60 60 #define GB_OPERATION_FLAG_INCOMING BIT(0) 61 61 #define GB_OPERATION_FLAG_UNIDIRECTIONAL BIT(1) 62 62 #define GB_OPERATION_FLAG_SHORT_RESPONSE BIT(2) 63 + #define GB_OPERATION_FLAG_CORE BIT(3) 63 64 64 65 #define GB_OPERATION_FLAG_USER_MASK (GB_OPERATION_FLAG_SHORT_RESPONSE | \ 65 66 GB_OPERATION_FLAG_UNIDIRECTIONAL) ··· 124 123 return operation->flags & GB_OPERATION_FLAG_SHORT_RESPONSE; 125 124 } 126 125 126 + static inline bool gb_operation_is_core(struct gb_operation *operation) 127 + { 128 + return operation->flags & GB_OPERATION_FLAG_CORE; 129 + } 130 + 127 131 void gb_connection_recv(struct gb_connection *connection, 128 132 void *data, size_t size); 129 133 ··· 149 143 return gb_operation_create_flags(connection, type, request_size, 150 144 response_size, 0, gfp); 151 145 } 146 + 147 + struct gb_operation * 148 + gb_operation_create_core(struct gb_connection *connection, 149 + u8 type, size_t request_size, 150 + size_t response_size, unsigned long flags, 151 + gfp_t gfp); 152 152 153 153 void gb_operation_get(struct gb_operation *operation); 154 154 void gb_operation_put(struct gb_operation *operation);