]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
greybus: loopback: make loopback type input equivalent to protocol type
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>
Mon, 13 Jul 2015 19:20:48 +0000 (20:20 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Mon, 13 Jul 2015 22:42:01 +0000 (15:42 -0700)
Sepcifying loopback operation type with a type value that is internal to
the loopback driver is non-intunitive and requires reading code to
understand. Remove confusing duplicate definitions and update code to
accept the greybus-specification function identity defintiions as the
appropriate type values for initiating loopback operations.

See greybus-spec section 10.16.1 'Greybus Loopback Message Types' for a
full list of valid messages to set this type field to.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/loopback.c

index 6cd4acf93bf6fde533964521e843635827e70b89..bdbebd6dbede933028fdc8d5bdc7e266044e78c1 100644 (file)
@@ -45,12 +45,6 @@ struct gb_loopback {
        u32 error;
 };
 
-/* Current function (type of traffic generated by the loopback thread) */
-#define GB_LOOPBACK_FN_NONE                            0x00
-#define GB_LOOPBACK_FN_PING                            0x01
-#define GB_LOOPBACK_FN_XFER                            0x02
-#define GB_LOOPBACK_FN_COUNT                           0x03
-
 #define GB_LOOPBACK_MS_WAIT_MAX                                1000
 #define GB_LOOPBACK_SIZE_MAX                           SZ_4K
 
@@ -117,10 +111,16 @@ static DEVICE_ATTR_RW(field)
 static void gb_loopback_reset_stats(struct gb_loopback *gb);
 static void gb_loopback_check_attr(struct gb_loopback *gb)
 {
+       switch (gb->type) {
+       case GB_LOOPBACK_TYPE_PING:
+       case GB_LOOPBACK_TYPE_TRANSFER:
+               break;
+       default:
+               gb->type = 0;
+               break;
+       }
        if (gb->ms_wait > GB_LOOPBACK_MS_WAIT_MAX)
                gb->ms_wait = GB_LOOPBACK_MS_WAIT_MAX;
-       if (gb->type >= GB_LOOPBACK_FN_COUNT)
-               gb->type = GB_LOOPBACK_FN_NONE;
        if (gb->size > GB_LOOPBACK_SIZE_MAX)
                gb->size = GB_LOOPBACK_SIZE_MAX;
        gb->error = 0;
@@ -337,13 +337,13 @@ static int gb_loopback_fn(void *data)
        struct gb_loopback *gb = (struct gb_loopback *)data;
 
        while (!kthread_should_stop()) {
-               if (gb->type == GB_LOOPBACK_FN_NONE) {
+               if (!gb->type) {
                        msleep(1000);
                        continue;
                }
-               if (gb->type == GB_LOOPBACK_FN_PING)
+               if (gb->type == GB_LOOPBACK_TYPE_PING)
                        error = gb_loopback_ping(gb, &tlat);
-               else if (gb->type == GB_LOOPBACK_FN_XFER)
+               else if (gb->type == GB_LOOPBACK_TYPE_TRANSFER)
                        error = gb_loopback_transfer(gb, &tlat, gb->size);
                if (error)
                        gb->error++;