From d4b29ddf82a458935f1bd4909b8a7a13df9d3bdc Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Tue, 17 Jun 2025 23:41:55 +0900 Subject: 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 Reviewed-by: Alice Ryhl Reviewed-by: Fiona Behrens Tested-by: Daniel Almeida Reviewed-by: Andreas Hindborg Signed-off-by: FUJITA Tomonori Link: https://lore.kernel.org/r/20250617144155.3903431-3-fujita.tomonori@gmail.com Signed-off-by: Andreas Hindborg --- rust/helpers/time.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'rust/helpers/time.c') 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 #include #include +void rust_helper_fsleep(unsigned long usecs) +{ + fsleep(usecs); +} + ktime_t rust_helper_ktime_get_real(void) { return ktime_get_real(); -- cgit v1.2.3