Skip to content

Commit 96e8298

Browse files
andy-shevgregkh
authored andcommitted
serdev: Replace poll loop by readx_poll_timeout() macro
The readx_poll_timeout() consolidates the necessary code under macro. Replace current code with it. Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 24ce048 commit 96e8298

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

include/linux/serdev.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <linux/types.h>
99
#include <linux/device.h>
10+
#include <linux/iopoll.h>
1011
#include <linux/uaccess.h>
1112
#include <linux/termios.h>
1213
#include <linux/delay.h>
@@ -279,18 +280,10 @@ static inline bool serdev_device_get_cts(struct serdev_device *serdev)
279280

280281
static inline int serdev_device_wait_for_cts(struct serdev_device *serdev, bool state, int timeout_ms)
281282
{
282-
unsigned long timeout;
283283
bool signal;
284284

285-
timeout = jiffies + msecs_to_jiffies(timeout_ms);
286-
while (time_is_after_jiffies(timeout)) {
287-
signal = serdev_device_get_cts(serdev);
288-
if (signal == state)
289-
return 0;
290-
usleep_range(1000, 2000);
291-
}
292-
293-
return -ETIMEDOUT;
285+
return readx_poll_timeout(serdev_device_get_cts, serdev, signal, signal == state,
286+
2000, timeout_ms * 1000);
294287
}
295288

296289
static inline int serdev_device_set_rts(struct serdev_device *serdev, bool enable)

0 commit comments

Comments
 (0)