staging: greybus: loopback: fix broken udelay
authorJohan Hovold <johan@kernel.org>
Thu, 26 Jan 2017 11:37:32 +0000 (12:37 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 12 Mar 2017 05:41:42 +0000 (06:41 +0100)
commit2893a55e39fcfe3b9f5738584db98848b4957d9f
tree26f9c06ad909a240020c7ada072e965b274cee52
parent6c95eba9ca104fad6abd758c58b3ac55c44f627d
staging: greybus: loopback: fix broken udelay

commit 33b8807a6fe10d0e675e0704444373a6fad93188 upstream.

The loopback driver allows the user to set a minimum delay of up to one
second to be inserted between test iterations (i.e. request
submissions). The delay is currently specified in microseconds and is
implemented using udelay.

Busy looping for long periods is not just anti-social; udelay must not
be used for delays longer than a few milliseconds due to the risk of
integer overflow.

Replace the broken udelay with a usleep_range with a 100 us range for
short delays (< 20 ms) and otherwise revert to using msleep.

Fixes: b36f04fa9417 ("greybus: loopback: Convert thread delay to microseconds")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/greybus/loopback.c