Commit 48cc8b8b authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman

greybus: loopback: define loopback functions symbolically

Add some symbols to indicate what kind of "function" the
loopback thread is supposed to be performing--the type of
traffic it generates over its connection.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 91262c3a
...@@ -55,6 +55,12 @@ struct gb_loopback { ...@@ -55,6 +55,12 @@ struct gb_loopback {
#define GB_LOOPBACK_TYPE_PING 0x02 #define GB_LOOPBACK_TYPE_PING 0x02
#define GB_LOOPBACK_TYPE_TRANSFER 0x03 #define GB_LOOPBACK_TYPE_TRANSFER 0x03
/* 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_MS_WAIT_MAX 1000
#define GB_LOOPBACK_SIZE_MAX SZ_4K #define GB_LOOPBACK_SIZE_MAX SZ_4K
...@@ -124,8 +130,8 @@ static void gb_loopback_check_attr(struct gb_loopback *gb) ...@@ -124,8 +130,8 @@ static void gb_loopback_check_attr(struct gb_loopback *gb)
{ {
if (gb->ms_wait > GB_LOOPBACK_MS_WAIT_MAX) if (gb->ms_wait > GB_LOOPBACK_MS_WAIT_MAX)
gb->ms_wait = GB_LOOPBACK_MS_WAIT_MAX; gb->ms_wait = GB_LOOPBACK_MS_WAIT_MAX;
if (gb->type > 2) if (gb->type >= GB_LOOPBACK_FN_COUNT)
gb->type = 0; gb->type = GB_LOOPBACK_FN_NONE;
if (gb->size > GB_LOOPBACK_SIZE_MAX) if (gb->size > GB_LOOPBACK_SIZE_MAX)
gb->size = GB_LOOPBACK_SIZE_MAX; gb->size = GB_LOOPBACK_SIZE_MAX;
gb->error = 0; gb->error = 0;
...@@ -310,13 +316,13 @@ static int gb_loopback_fn(void *data) ...@@ -310,13 +316,13 @@ static int gb_loopback_fn(void *data)
struct gb_loopback *gb = (struct gb_loopback *)data; struct gb_loopback *gb = (struct gb_loopback *)data;
while (!kthread_should_stop()) { while (!kthread_should_stop()) {
if (gb->type == 0) { if (gb->type == GB_LOOPBACK_FN_NONE) {
msleep(1000); msleep(1000);
continue; continue;
} }
if (gb->type == 1) if (gb->type == GB_LOOPBACK_FN_PING)
error = gb_loopback_ping(gb, &tlat); error = gb_loopback_ping(gb, &tlat);
if (gb->type == 2) else if (gb->type == GB_LOOPBACK_FN_XFER)
error = gb_loopback_transfer(gb, &tlat, gb->size); error = gb_loopback_transfer(gb, &tlat, gb->size);
if (error) if (error)
gb->error++; gb->error++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment