]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rust: io: mem: add a generic iomem abstraction
authorDaniel Almeida <daniel.almeida@collabora.com>
Thu, 17 Jul 2025 15:55:23 +0000 (12:55 -0300)
committerDanilo Krummrich <dakr@kernel.org>
Sun, 20 Jul 2025 17:43:14 +0000 (19:43 +0200)
commit1d0d4b28513b5e0e9e87e09c8da289e1b8d88f84
tree094daa6aa30773bc3e3b0a99f9740e4053a3acfa
parent493fc33ec25294cb2e444dfa77c105aa774c83f2
rust: io: mem: add a generic iomem abstraction

Add a generic iomem abstraction to safely read and write ioremapped
regions. This abstraction requires a previously acquired IoRequest
instance. This makes it so that both the resource and the device match,
or, in other words, that the resource is indeed a valid resource for a
given bound device.

A subsequent patch will add the ability to retrieve IoRequest instances
from platform devices.

The reads and writes are done through IoRaw, and are thus checked either
at compile-time, if the size of the region is known at that point, or at
runtime otherwise.

Non-exclusive access to the underlying memory region is made possible to
cater to cases where overlapped regions are unavoidable.

Acked-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
Link: https://lore.kernel.org/r/20250717-topics-tyr-platform_iomem-v15-2-beca780b77e3@collabora.com
[ Add #[expect(dead_code)] to avoid a temporary warning, remove
  unnecessary OF_ID_TABLE constants in doc-tests and ignore doc-tests
  for now to avoid a temporary build failure. - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
rust/helpers/io.c
rust/kernel/io.rs
rust/kernel/io/mem.rs [new file with mode: 0644]