]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
greybus: vibrator-gb: convert to use gb_operation_sync
authorGreg Kroah-Hartman <greg@kroah.com>
Mon, 24 Nov 2014 01:45:20 +0000 (17:45 -0800)
committerGreg Kroah-Hartman <greg@kroah.com>
Mon, 24 Nov 2014 20:56:51 +0000 (12:56 -0800)
This converts the vibrator protocol driver to use gb_operation_sync,
removing the hand-rolled version of the same function, as well as
removing an open-coded version for a request when turning on the
vibrator motor.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
drivers/staging/greybus/vibrator-gb.c

index b65a586b87c991946126ddb0db21b284427c3909..d00301dce8f007368cd5b9c445c29d813dbd8e47 100644 (file)
@@ -42,35 +42,6 @@ struct gb_vibrator_on_request {
        __le16  timeout_ms;
 };
 
-/*
- * The get_version and turn_off vibrator operations have no payload.
- * This function implements these requests by allowing the caller to
- * supply a buffer into which the operation response should be
- * copied.  The turn_off operation, there is no response either.
- * If there is an error, the response buffer is left alone.
- */
-static int request_operation(struct gb_connection *connection, int type,
-                            void *response, int response_size)
-{
-       struct gb_operation *operation;
-       int ret;
-
-       operation = gb_operation_create(connection, type, 0, response_size);
-       if (!operation)
-               return -ENOMEM;
-
-       /* Synchronous operation--no callback */
-       ret = gb_operation_request_send(operation, NULL);
-       if (ret)
-               pr_err("version operation failed (%d)\n", ret);
-       else if (response_size && response)
-               memcpy(response, operation->response->payload,
-                                       response_size);
-       gb_operation_destroy(operation);
-
-       return ret;
-}
-
 /*
  * This request only uses the connection field, and if successful,
  * fills in the major and minor protocol version of the target.
@@ -81,8 +52,9 @@ static int get_version(struct gb_vibrator_device *vib)
        struct gb_vibrator_proto_version_response version_response;
        int retval;
 
-       retval = request_operation(connection,
+       retval = gb_operation_sync(connection,
                                   GB_VIBRATOR_TYPE_PROTOCOL_VERSION,
+                                  NULL, 0,
                                   &version_response, sizeof(version_response));
        if (retval)
                return retval;
@@ -101,33 +73,17 @@ static int get_version(struct gb_vibrator_device *vib)
 
 static int turn_on(struct gb_vibrator_device *vib, u16 timeout_ms)
 {
-       struct gb_connection *connection = vib->connection;
-       struct gb_operation *operation;
-       struct gb_vibrator_on_request *request;
-       int retval;
-
-       operation = gb_operation_create(connection, GB_VIBRATOR_TYPE_ON,
-                                       sizeof(*request), 0);
-       if (!operation)
-               return -ENOMEM;
-       request = operation->request->payload;
-       request->timeout_ms = cpu_to_le16(timeout_ms);
+       struct gb_vibrator_on_request request;
 
-       /* Synchronous operation--no callback */
-       retval = gb_operation_request_send(operation, NULL);
-       if (retval)
-               dev_err(&connection->dev,
-                       "send data operation failed (%d)\n", retval);
-       gb_operation_destroy(operation);
-
-       return retval;
+       request.timeout_ms = cpu_to_le16(timeout_ms);
+       return gb_operation_sync(vib->connection, GB_VIBRATOR_TYPE_ON,
+                                &request, sizeof(request), NULL, 0);
 }
 
 static int turn_off(struct gb_vibrator_device *vib)
 {
-       struct gb_connection *connection = vib->connection;
-
-       return request_operation(connection, GB_VIBRATOR_TYPE_OFF, NULL, 0);
+       return gb_operation_sync(vib->connection, GB_VIBRATOR_TYPE_OFF,
+                                NULL, 0, NULL, 0);
 }
 
 static ssize_t timeout_store(struct device *dev, struct device_attribute *attr,