From 9f3fc9128d1991b40e6ae0ad16b76f0ebc59c632 Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Fri, 26 Jun 2020 03:35:27 +0000 Subject: add readx_poll_timeout() required for 5.7.6 drm with help from cheloha@ --- sys/dev/pci/drm/include/linux/iopoll.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 sys/dev/pci/drm/include/linux/iopoll.h 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 -- cgit v1.2.3