mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

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>
35 lines
568 B
C
35 lines
568 B
C
// 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();
|
|
}
|
|
|
|
ktime_t rust_helper_ktime_get_boottime(void)
|
|
{
|
|
return ktime_get_boottime();
|
|
}
|
|
|
|
ktime_t rust_helper_ktime_get_clocktai(void)
|
|
{
|
|
return ktime_get_clocktai();
|
|
}
|
|
|
|
s64 rust_helper_ktime_to_us(const ktime_t kt)
|
|
{
|
|
return ktime_to_us(kt);
|
|
}
|
|
|
|
s64 rust_helper_ktime_to_ms(const ktime_t kt)
|
|
{
|
|
return ktime_to_ms(kt);
|
|
}
|