* [PATCH v2 1/1] serdev: Replace poll loop by readx_poll_timeout() macro
@ 2022-09-23 17:10 Andy Shevchenko
2022-09-24 11:57 ` Greg Kroah-Hartman
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2022-09-23 17:10 UTC (permalink / raw)
To: Greg Kroah-Hartman, Magnus Damm, linux-serial, linux-kernel
Cc: Rob Herring, Andy Shevchenko
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>
---
v2: dropped TODO: in the Subject line
include/linux/serdev.h | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/include/linux/serdev.h b/include/linux/serdev.h
index 66f624fc618c..69d9c3188065 100644
--- a/include/linux/serdev.h
+++ b/include/linux/serdev.h
@@ -7,9 +7,11 @@
#include <linux/types.h>
#include <linux/device.h>
+#include <linux/iopoll.h>
#include <linux/uaccess.h>
#include <linux/termios.h>
#include <linux/delay.h>
+#include <vdso/time64.h>
struct serdev_controller;
struct serdev_device;
@@ -279,18 +281,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)
{
- unsigned long timeout;
bool signal;
- timeout = jiffies + msecs_to_jiffies(timeout_ms);
- while (time_is_after_jiffies(timeout)) {
- signal = serdev_device_get_cts(serdev);
- if (signal == state)
- return 0;
- usleep_range(1000, 2000);
- }
-
- return -ETIMEDOUT;
+ return readx_poll_timeout(serdev_device_get_cts, serdev, signal, signal == state,
+ 2000, timeout_ms * USEC_PER_MSEC);
}
static inline int serdev_device_set_rts(struct serdev_device *serdev, bool enable)
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/1] serdev: Replace poll loop by readx_poll_timeout() macro
2022-09-23 17:10 [PATCH v2 1/1] serdev: Replace poll loop by readx_poll_timeout() macro Andy Shevchenko
@ 2022-09-24 11:57 ` Greg Kroah-Hartman
2022-09-26 10:48 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2022-09-24 11:57 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Magnus Damm, linux-serial, linux-kernel, Rob Herring
On Fri, Sep 23, 2022 at 08:10:48PM +0300, Andy Shevchenko wrote:
> 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>
> ---
> v2: dropped TODO: in the Subject line
> include/linux/serdev.h | 14 ++++----------
> 1 file changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/include/linux/serdev.h b/include/linux/serdev.h
> index 66f624fc618c..69d9c3188065 100644
> --- a/include/linux/serdev.h
> +++ b/include/linux/serdev.h
> @@ -7,9 +7,11 @@
>
> #include <linux/types.h>
> #include <linux/device.h>
> +#include <linux/iopoll.h>
> #include <linux/uaccess.h>
> #include <linux/termios.h>
> #include <linux/delay.h>
> +#include <vdso/time64.h>
Ick, just for USEC_PER_MSEC? That should be in units.h, not burried in
a vdso-only .h file. This feels wrong, sorry.
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/1] serdev: Replace poll loop by readx_poll_timeout() macro
2022-09-24 11:57 ` Greg Kroah-Hartman
@ 2022-09-26 10:48 ` Andy Shevchenko
0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2022-09-26 10:48 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Magnus Damm, linux-serial, linux-kernel, Rob Herring
On Sat, Sep 24, 2022 at 01:57:29PM +0200, Greg Kroah-Hartman wrote:
> On Fri, Sep 23, 2022 at 08:10:48PM +0300, Andy Shevchenko wrote:
> > The readx_poll_timeout() consolidates the necessary code under
> > macro. Replace current code with it.
...
> > +#include <vdso/time64.h>
>
> Ick, just for USEC_PER_MSEC? That should be in units.h, not burried in
> a vdso-only .h file. This feels wrong, sorry.
Why are you asking me about this? It was not my choice and it was made
a couple of years ago (see [1]).
As a solution I can just drop using that constant in v3.
[1]: b72a9c5e023b ("linux/time64.h: Extract common header for vDSO")
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-26 11:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-23 17:10 [PATCH v2 1/1] serdev: Replace poll loop by readx_poll_timeout() macro Andy Shevchenko
2022-09-24 11:57 ` Greg Kroah-Hartman
2022-09-26 10:48 ` Andy Shevchenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.