]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
greybus: get rid of message status
authorAlex Elder <elder@linaro.org>
Wed, 19 Nov 2014 18:27:15 +0000 (12:27 -0600)
committerGreg Kroah-Hartman <greg@kroah.com>
Wed, 19 Nov 2014 18:43:21 +0000 (10:43 -0800)
We (sort of) maintain the status of each message, but we shouldn't
need to.  Right now we're not using it consistently in any case.

If a message fails to send, the caller will know to destroy the
operation that contained it.

If a message has been sent (i.e., handed to the host device layer)
it'll have a non-null cookie pointer.

If a does complete in error, we can update the status of the
operation that contains it.  That isn't happening right now but
it will soon.

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

index 96f4c689e998d8398007a111bdd8498fa59a2f76..05a61d87dabe6c472b9c28166790e8e59ba82af5 100644 (file)
@@ -107,28 +107,30 @@ static int gb_message_send(struct gb_message *message, gfp_t gfp_mask)
 {
        struct gb_connection *connection = message->operation->connection;
        u16 dest_cport_id = connection->interface_cport_id;
+       int ret = 0;
 
-       message->status = -EINPROGRESS;
        message->cookie = connection->hd->driver->buffer_send(connection->hd,
                                        dest_cport_id,
                                        message->buffer,
                                        message->buffer_size,
                                        gfp_mask);
        if (IS_ERR(message->cookie)) {
-               message->status = PTR_ERR(message->cookie);
+               ret = PTR_ERR(message->cookie);
                message->cookie = NULL;
-
-               return message->status;
        }
-       return 0;
+       return ret;
 }
 
+/*
+ * Cancel a message whose buffer we have passed to the host device
+ * layer to be sent.
+ */
 static void gb_message_cancel(struct gb_message *message)
 {
        struct greybus_host_device *hd;
 
-       if (message->status != -EINPROGRESS)
-               return;
+       if (!message->cookie)
+               return; /* Don't bother if the message isn't in flight */
 
        hd = message->operation->connection->hd;
        hd->driver->buffer_cancel(message->cookie);
@@ -252,7 +254,6 @@ static int gb_operation_message_init(struct gb_operation *operation,
        if (!message->buffer)
                return -ENOMEM;
        message->buffer_size = size;
-       message->status = -EBADR;       /* Initial value--means "never set" */
 
        /* Fill in the header structure */
        header = message->buffer;
index 81fd7f70b8baf5df9a0fdc49b7a99422fd1a387c..80ee158d74f7d0792ae46cadd78f5bae33f30d84 100644 (file)
@@ -28,7 +28,6 @@ struct gb_message {
        void                    *payload;
 
        struct gb_operation     *operation;
-       int                     status;
 
        void                    *buffer;
        size_t                  buffer_size;