diff options
| author | Gary Guo <gary@garyguo.net> | 2026-07-16 15:25:43 +0100 |
|---|---|---|
| committer | Danilo Krummrich <dakr@kernel.org> | 2026-07-21 00:48:25 +0200 |
| commit | c2d8b262057c0707ef5a1cd8e80842b7fde281b8 (patch) | |
| tree | b6452b125cddfb298072b4ae6014295ab25449b5 /rust | |
| parent | f7acb19abcd867e5d2e1feb6197dcc65aa3b8e45 (diff) | |
rust: io: document const-offset requirement for infallible accessors
Due to the usage of `build_assert!` for address validity checking, these
accessors want constant offsets. Non-constant offsets can work but it
depend on compiler optimization levels, so it should be avoided.
Signed-off-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://patch.msgid.link/20260716142545.3622278-1-gary@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'rust')
| -rw-r--r-- | rust/kernel/io.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/rust/kernel/io.rs b/rust/kernel/io.rs index 95f46bb75f9e..a38c20ba3d23 100644 --- a/rust/kernel/io.rs +++ b/rust/kernel/io.rs @@ -721,6 +721,8 @@ pub trait Io<'a>: IoBase<'a> { } /// Infallible 8-bit read with compile-time bounds check. + /// + /// `offset` should be constant. #[inline(always)] fn read8(self, offset: usize) -> u8 where @@ -731,6 +733,8 @@ pub trait Io<'a>: IoBase<'a> { } /// Infallible 16-bit read with compile-time bounds check. + /// + /// `offset` should be constant. #[inline(always)] fn read16(self, offset: usize) -> u16 where @@ -741,6 +745,8 @@ pub trait Io<'a>: IoBase<'a> { } /// Infallible 32-bit read with compile-time bounds check. + /// + /// `offset` should be constant. #[inline(always)] fn read32(self, offset: usize) -> u32 where @@ -751,6 +757,8 @@ pub trait Io<'a>: IoBase<'a> { } /// Infallible 64-bit read with compile-time bounds check. + /// + /// `offset` should be constant. #[inline(always)] fn read64(self, offset: usize) -> u64 where @@ -761,6 +769,8 @@ pub trait Io<'a>: IoBase<'a> { } /// Infallible 8-bit write with compile-time bounds check. + /// + /// `offset` should be constant. #[inline(always)] fn write8(self, value: u8, offset: usize) where @@ -771,6 +781,8 @@ pub trait Io<'a>: IoBase<'a> { } /// Infallible 16-bit write with compile-time bounds check. + /// + /// `offset` should be constant. #[inline(always)] fn write16(self, value: u16, offset: usize) where @@ -781,6 +793,8 @@ pub trait Io<'a>: IoBase<'a> { } /// Infallible 32-bit write with compile-time bounds check. + /// + /// `offset` should be constant. #[inline(always)] fn write32(self, value: u32, offset: usize) where @@ -791,6 +805,8 @@ pub trait Io<'a>: IoBase<'a> { } /// Infallible 64-bit write with compile-time bounds check. + /// + /// `offset` should be constant. #[inline(always)] fn write64(self, value: u64, offset: usize) where |
