aboutsummaryrefslogtreecommitdiffstats
path: root/rust/helpers/time.c
diff options
context:
space:
mode:
authorFUJITA Tomonori <[email protected]>2025-06-17 14:41:55 +0000
committerAndreas Hindborg <[email protected]>2025-06-30 11:22:05 +0000
commitd4b29ddf82a458935f1bd4909b8a7a13df9d3bdc (patch)
tree8fe619c1e1df33ff74132570bb7cebe099c13efd /rust/helpers/time.c
parentrust: time: Seal the HrTimerMode trait (diff)
downloadkernel-d4b29ddf82a458935f1bd4909b8a7a13df9d3bdc.tar.gz
kernel-d4b29ddf82a458935f1bd4909b8a7a13df9d3bdc.zip
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 <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Fiona Behrens <[email protected]> Tested-by: Daniel Almeida <[email protected]> Reviewed-by: Andreas Hindborg <[email protected]> Signed-off-by: FUJITA Tomonori <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andreas Hindborg <[email protected]>
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();