]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
greybus: operation: add gb_operation_sync_timeout helper
authorJohan Hovold <johan@hovoldconsulting.com>
Tue, 14 Jul 2015 13:43:37 +0000 (15:43 +0200)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 15 Jul 2015 19:39:13 +0000 (12:39 -0700)
Add gb_operation_sync_timeout convenience function, which allows drivers
to configure the operation timeout.

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/operation.c
drivers/staging/greybus/operation.h

index 63c4a5b8b0f178973e1adf4e2c38815505083e1e..a99505cc21fa4226bb36338eeb42886cacba2288 100644 (file)
@@ -978,6 +978,7 @@ void gb_operation_cancel_incoming(struct gb_operation *operation, int errno)
  * @request_size: size of @request
  * @response: pointer to a memory buffer to copy the response to
  * @response_size: the size of @response.
+ * @timeout: operation timeout in milliseconds
  *
  * This function implements a simple synchronous Greybus operation.  It sends
  * the provided operation request and waits (sleeps) until the corresponding
@@ -992,9 +993,10 @@ void gb_operation_cancel_incoming(struct gb_operation *operation, int errno)
  *
  * If there is an error, the response buffer is left alone.
  */
-int gb_operation_sync(struct gb_connection *connection, int type,
-                     void *request, int request_size,
-                     void *response, int response_size)
+int gb_operation_sync_timeout(struct gb_connection *connection, int type,
+                               void *request, int request_size,
+                               void *response, int response_size,
+                               unsigned int timeout)
 {
        struct gb_operation *operation;
        int ret;
@@ -1012,7 +1014,7 @@ int gb_operation_sync(struct gb_connection *connection, int type,
        if (request_size)
                memcpy(operation->request->payload, request, request_size);
 
-       ret = gb_operation_request_send_sync(operation);
+       ret = gb_operation_request_send_sync_timeout(operation, timeout);
        if (ret) {
                dev_err(&connection->dev, "synchronous operation failed: %d\n",
                        ret);
@@ -1026,7 +1028,7 @@ int gb_operation_sync(struct gb_connection *connection, int type,
 
        return ret;
 }
-EXPORT_SYMBOL_GPL(gb_operation_sync);
+EXPORT_SYMBOL_GPL(gb_operation_sync_timeout);
 
 int __init gb_operation_init(void)
 {
index f06dd11e0afb42e32142fe8d270c729fc71da5c4..6854703494606fcd2f5d28d21117990ea995cff9 100644 (file)
@@ -186,9 +186,19 @@ void gb_operation_cancel_incoming(struct gb_operation *operation, int errno);
 void greybus_message_sent(struct greybus_host_device *hd,
                                struct gb_message *message, int status);
 
-int gb_operation_sync(struct gb_connection *connection, int type,
+int gb_operation_sync_timeout(struct gb_connection *connection, int type,
+                               void *request, int request_size,
+                               void *response, int response_size,
+                               unsigned int timeout);
+
+static inline int gb_operation_sync(struct gb_connection *connection, int type,
                      void *request, int request_size,
-                     void *response, int response_size);
+                     void *response, int response_size)
+{
+       return gb_operation_sync_timeout(connection, type,
+                       request, request_size, response, response_size,
+                       GB_OPERATION_TIMEOUT_DEFAULT);
+}
 
 int gb_operation_init(void);
 void gb_operation_exit(void);