]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
greybus: renumber operation result values
authorAlex Elder <elder@linaro.org>
Mon, 1 Dec 2014 13:53:09 +0000 (07:53 -0600)
committerGreg Kroah-Hartman <greg@kroah.com>
Tue, 2 Dec 2014 04:40:35 +0000 (20:40 -0800)
Define a new operation status GB_OP_MALFUNCTION, which will be used
to represent that something unexpected happened while handling an
operation.  This is intended as an indication similar to a BUG()
call--whatever went wrong should *never* happen and because it's
unexpected we need to treat it as a fatal error.

Define another new operation status GB_OP_UNKNOWN_ERROR, which
will represent the case where an operation ended in error, but
the error was not recognized to be properly represented by one
of the other status values.

Renumber the operation status values, defining those that are
produced by core operations code ahead of those that are more
likely to come from operation handlers.  Represent the values in
hexadecimal to emphasize that they must be represented with 8 bits.
The Use 0xff for GB_OP_MALFUNCTION instead of GB_OP_TIMEOUT; the
latter is special, but a malfunction is in a class by itself.

Reorder the cases in gb_operation_status_map() to match their
numeric order.

Map GB_OP_UNKNOWN_ERROR to -EIO in gb_operation_status_map().  Map
GB_OP_MALFUNCTION to -EILSEQ in gb_operation_status_map(), since
that value is used to represent an implementation error.

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 905c6de9e20ef98a75416fbde6d8e411c6bf1f26..0841ab271496174ae2e1ca9f08a4d60787a5ef00 100644 (file)
@@ -368,20 +368,23 @@ int gb_operation_status_map(u8 status)
        switch (status) {
        case GB_OP_SUCCESS:
                return 0;
-       case GB_OP_INVALID:
-               return -EINVAL;
-       case GB_OP_NO_MEMORY:
-               return -ENOMEM;
        case GB_OP_INTERRUPTED:
                return -EINTR;
-       case GB_OP_RETRY:
-               return -EAGAIN;
+       case GB_OP_TIMEOUT:
+               return -ETIMEDOUT;
+       case GB_OP_NO_MEMORY:
+               return -ENOMEM;
        case GB_OP_PROTOCOL_BAD:
                return -EPROTONOSUPPORT;
        case GB_OP_OVERFLOW:
                return -EMSGSIZE;
-       case GB_OP_TIMEOUT:
-               return -ETIMEDOUT;
+       case GB_OP_INVALID:
+               return -EINVAL;
+       case GB_OP_RETRY:
+               return -EAGAIN;
+       case GB_OP_MALFUNCTION:
+               return -EILSEQ;
+       case GB_OP_UNKNOWN_ERROR:
        default:
                return -EIO;
        }
index 7f835d2e8f356d0a6756e9e674cb2eddb6ea73d3..feff8238f7cfe17987a8ebed7ae7a0e69b0ae146 100644 (file)
 struct gb_operation;
 
 enum gb_operation_result {
-       GB_OP_SUCCESS           = 0,
-       GB_OP_INVALID           = 1,
-       GB_OP_NO_MEMORY         = 2,
-       GB_OP_INTERRUPTED       = 3,
-       GB_OP_RETRY             = 4,
-       GB_OP_PROTOCOL_BAD      = 5,
-       GB_OP_OVERFLOW          = 6,
-       GB_OP_TIMEOUT           = 0xff,
+       GB_OP_SUCCESS           = 0x00,
+       GB_OP_INTERRUPTED       = 0x01,
+       GB_OP_TIMEOUT           = 0x02,
+       GB_OP_NO_MEMORY         = 0x03,
+       GB_OP_PROTOCOL_BAD      = 0x04,
+       GB_OP_OVERFLOW          = 0x05,
+       GB_OP_INVALID           = 0x06,
+       GB_OP_RETRY             = 0x07,
+       GB_OP_UNKNOWN_ERROR     = 0xfe,
+       GB_OP_MALFUNCTION       = 0xff,
 };
 
 struct gb_message {