summaryrefslogtreecommitdiff
path: root/rust/helpers/time.c
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@gmail.com>2025-06-17 23:41:55 +0900
committerAndreas Hindborg <a.hindborg@kernel.org>2025-06-30 13:22:05 +0200
commitd4b29ddf82a458935f1bd4909b8a7a13df9d3bdc (patch)
tree8fe619c1e1df33ff74132570bb7cebe099c13efd /rust/helpers/time.c
parentfc38b7ff879683669bd9ff5dc7e7b6aeeb07bf2a (diff)
rust: time: Add wrapper for fsleep() function
Add a wrapper for fsleep(), flexible sleep functions in include/linux/delay.h which typically deals with hardware delays. The kernel supports several sleep functions to handle various lengths of delay. This adds fsleep(), automatically chooses the best sleep method based on a duration. fsleep() can only be used in a nonatomic context. This requirement is not checked by these abstractions, but it is intended that klint [1] or a similar tool will be used to check it in the future. Link: https://rust-for-linux.com/klint [1] Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Fiona Behrens <me@kloenk.dev> Tested-by: Daniel Almeida <daniel.almeida@collabora.com> Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Link: https://lore.kernel.org/r/20250617144155.3903431-3-fujita.tomonori@gmail.com Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
Diffstat (limited to 'rust/helpers/time.c')
-rw-r--r--rust/helpers/time.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/rust/helpers/time.c b/rust/helpers/time.c
index 08755db43fc2..a318e9fa4408 100644
--- a/rust/helpers/time.c
+++ b/rust/helpers/time.c
@@ -1,8 +1,14 @@
// SPDX-License-Identifier: GPL-2.0
+#include <linux/delay.h>
#include <linux/ktime.h>
#include <linux/timekeeping.h>
+void rust_helper_fsleep(unsigned long usecs)
+{
+ fsleep(usecs);
+}
+
ktime_t rust_helper_ktime_get_real(void)
{
return ktime_get_real();