diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-06-26 03:35:27 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-06-26 03:35:27 +0000 |
commit | 9f3fc9128d1991b40e6ae0ad16b76f0ebc59c632 (patch) | |
tree | 37f6628fdfcda6c8bb108189d9c66eef509e2470 | |
parent | 3c793956e22038963bc00c87a4e2052d2f44ecb0 (diff) |
add readx_poll_timeout() required for 5.7.6 drm
with help from cheloha@
-rw-r--r-- | sys/dev/pci/drm/include/linux/iopoll.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sys/dev/pci/drm/include/linux/iopoll.h b/sys/dev/pci/drm/include/linux/iopoll.h new file mode 100644 index 00000000000..4a2d42842aa --- /dev/null +++ b/sys/dev/pci/drm/include/linux/iopoll.h @@ -0,0 +1,34 @@ +/* Public domain. */ + +#ifndef _LINUX_IOPOLL_H +#define _LINUX_IOPOLL_H + +#define readx_poll_timeout(op, addr, val, cond, sleep_us, timeout_us) \ +({ \ + struct timeval __end, __now, __timeout_tv; \ + int __timed_out = 0; \ + \ + if (timeout_us) { \ + microuptime(&__now); \ + USEC_TO_TIMEVAL(timeout_us, &__timeout_tv); \ + timeradd(&__now, &__timeout_tv, &__end); \ + } \ + \ + for (;;) { \ + (val) = (op)(addr); \ + if (cond) \ + break; \ + if (timeout_us) { \ + microuptime(&__now); \ + if (timercmp(&__end, &__now, <=)) { \ + __timed_out = 1; \ + break; \ + } \ + } \ + if (sleep_us) \ + delay((sleep_us) / 2); \ + } \ + (__timed_out) ? -ETIMEDOUT : 0; \ +}) + +#endif |