Later patches don't want or need to serialize the cancellation of an
operation. This patch adds gb_operation_cancel_async() as a simple subset
of the existing gb_operation_cancel() sans the synchronous wait on the
cancellation queue.

Signed-off-by: Bryan O'Donoghue <pure.lo...@nexus-software.ie>
---
 drivers/staging/greybus/operation.c | 19 ++++++++++++++++---
 drivers/staging/greybus/operation.h |  1 +
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/greybus/operation.c 
b/drivers/staging/greybus/operation.c
index 0123109..e69f329 100644
--- a/drivers/staging/greybus/operation.c
+++ b/drivers/staging/greybus/operation.c
@@ -1043,13 +1043,13 @@ void gb_connection_recv(struct gb_connection 
*connection,
 }
 
 /*
- * Cancel an outgoing operation synchronously, and record the given error to
+ * Cancel an outgoing operation asynchronously, and record the given error to
  * indicate why.
  */
-void gb_operation_cancel(struct gb_operation *operation, int errno)
+int gb_operation_cancel_async(struct gb_operation *operation, int errno)
 {
        if (WARN_ON(gb_operation_is_incoming(operation)))
-               return;
+               return -EINVAL;
 
        if (gb_operation_result_set(operation, errno)) {
                gb_message_cancel(operation->request);
@@ -1057,6 +1057,19 @@ void gb_operation_cancel(struct gb_operation *operation, 
int errno)
        }
        trace_gb_message_cancel_outgoing(operation->request);
 
+       return 0;
+}
+EXPORT_SYMBOL_GPL(gb_operation_cancel_async);
+
+/*
+ * Cancel an outgoing operation synchronously, and record the given error to
+ * indicate why.
+ */
+void gb_operation_cancel(struct gb_operation *operation, int errno)
+{
+       if (gb_operation_cancel_async(operation, errno))
+               return;
+
        atomic_inc(&operation->waiters);
        wait_event(gb_operation_cancellation_queue,
                        !gb_operation_is_active(operation));
diff --git a/drivers/staging/greybus/operation.h 
b/drivers/staging/greybus/operation.h
index de09a2c..467a0dc 100644
--- a/drivers/staging/greybus/operation.h
+++ b/drivers/staging/greybus/operation.h
@@ -174,6 +174,7 @@ gb_operation_request_send_sync(struct gb_operation 
*operation)
                        GB_OPERATION_TIMEOUT_DEFAULT);
 }
 
+int gb_operation_cancel_async(struct gb_operation *operation, int errno);
 void gb_operation_cancel(struct gb_operation *operation, int errno);
 void gb_operation_cancel_incoming(struct gb_operation *operation, int errno);
 
-- 
2.7.4

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to