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 <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20221114151813.37294-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
24ce048b0d
commit
96e8298945
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
|
#include <linux/iopoll.h>
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
#include <linux/termios.h>
|
#include <linux/termios.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
@ -279,18 +280,10 @@ static inline bool serdev_device_get_cts(struct serdev_device *serdev)
|
|||||||
|
|
||||||
static inline int serdev_device_wait_for_cts(struct serdev_device *serdev, bool state, int timeout_ms)
|
static inline int serdev_device_wait_for_cts(struct serdev_device *serdev, bool state, int timeout_ms)
|
||||||
{
|
{
|
||||||
unsigned long timeout;
|
|
||||||
bool signal;
|
bool signal;
|
||||||
|
|
||||||
timeout = jiffies + msecs_to_jiffies(timeout_ms);
|
return readx_poll_timeout(serdev_device_get_cts, serdev, signal, signal == state,
|
||||||
while (time_is_after_jiffies(timeout)) {
|
2000, timeout_ms * 1000);
|
||||||
signal = serdev_device_get_cts(serdev);
|
|
||||||
if (signal == state)
|
|
||||||
return 0;
|
|
||||||
usleep_range(1000, 2000);
|
|
||||||
}
|
|
||||||
|
|
||||||
return -ETIMEDOUT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int serdev_device_set_rts(struct serdev_device *serdev, bool enable)
|
static inline int serdev_device_set_rts(struct serdev_device *serdev, bool enable)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user