greybus: loopback: Fix broken loopback min values
authorAlexandre Bailon <abailon@baylibre.com>
Fri, 11 Mar 2016 16:23:37 +0000 (17:23 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Thu, 17 Mar 2016 04:49:31 +0000 (21:49 -0700)
Currently, when a loopback test completely fail,
loopback will return 4294967295 for every min value.
Return 0 instead of 4294967295 in such case.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/loopback.c

index 6c62706bb94cc40107edbfd0216b9b9fe01210fa..9b732a8664559da21151f2b12336326349cde5f7 100644 (file)
@@ -148,6 +148,9 @@ static ssize_t name##_##field##_show(struct device *dev,    \
                            char *buf)                                  \
 {                                                                      \
        struct gb_loopback *gb = dev_get_drvdata(dev);                  \
+       /* Report 0 for min and max if no transfer successed */         \
+       if (!gb->requests_completed)                                    \
+               return sprintf(buf, "0\n");                             \
        return sprintf(buf, "%"#type"\n", gb->name.field);      \
 }                                                                      \
 static DEVICE_ATTR_RO(name##_##field)