backports.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hauke Mehrtens <hauke@hauke-m.de>
To: backports@vger.kernel.org
Cc: Hauke Mehrtens <hauke@hauke-m.de>
Subject: [PATCH] header: Add fsleep()
Date: Sun,  6 Jun 2021 00:44:12 +0200	[thread overview]
Message-ID: <20210605224412.3172140-1-hauke@hauke-m.de> (raw)

This was added in upstream Linux commit c6af13d33475 ("timer: add fsleep
for flexible sleeping") and is now used by the rtw88 driver.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 backport/backport-include/linux/delay.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 backport/backport-include/linux/delay.h

diff --git a/backport/backport-include/linux/delay.h b/backport/backport-include/linux/delay.h
new file mode 100644
index 00000000..c19f4322
--- /dev/null
+++ b/backport/backport-include/linux/delay.h
@@ -0,0 +1,21 @@
+#ifndef __BACKPORT_LINUX_DELAY_H
+#define __BACKPORT_LINUX_DELAY_H
+#include_next <linux/delay.h>
+
+#include <linux/version.h>
+
+#if LINUX_VERSION_IS_LESS(5,8,0)
+#define fsleep LINUX_BACKPORT(fsleep)
+/* see Documentation/timers/timers-howto.rst for the thresholds */
+static inline void fsleep(unsigned long usecs)
+{
+	if (usecs <= 10)
+		udelay(usecs);
+	else if (usecs <= 20000)
+		usleep_range(usecs, 2 * usecs);
+	else
+		msleep(DIV_ROUND_UP(usecs, 1000));
+}
+#endif /* < 5.8.0 */
+
+#endif /* __BACKPORT_LINUX_DELAY_H */
-- 
2.30.2

--
To unsubscribe from this list: send the line "unsubscribe backports" in

                 reply	other threads:[~2021-06-05 22:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210605224412.3172140-1-hauke@hauke-m.de \
    --to=hauke@hauke-m.de \
    --cc=backports@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).