summaryrefslogtreecommitdiff
path: root/rust/helpers/helpers.c
diff options
context:
space:
mode:
authorDanilo Krummrich <dakr@kernel.org>2024-12-19 18:04:09 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-12-20 17:19:26 +0100
commitce30d94e6855a4f6dc687f658e63c225fcc1d690 (patch)
treef2a15a3ac51a13511c764eba44b80b96626a312f /rust/helpers/helpers.c
parent0494d9c82b0c722d8ce2af7dc5f92be6aef4625b (diff)
downloadlwn-ce30d94e6855a4f6dc687f658e63c225fcc1d690.tar.gz
lwn-ce30d94e6855a4f6dc687f658e63c225fcc1d690.zip
rust: add `io::{Io, IoRaw}` base types
I/O memory is typically either mapped through direct calls to ioremap() or subsystem / bus specific ones such as pci_iomap(). Even though subsystem / bus specific functions to map I/O memory are based on ioremap() / iounmap() it is not desirable to re-implement them in Rust. Instead, implement a base type for I/O mapped memory, which generically provides the corresponding accessors, such as `Io::readb` or `Io:try_readb`. `Io` supports an optional const generic, such that a driver can indicate the minimal expected and required size of the mapping at compile time. Correspondingly, calls to the 'non-try' accessors, support compile time checks of the I/O memory offset to read / write, while the 'try' accessors, provide boundary checks on runtime. `IoRaw` is meant to be embedded into a structure (e.g. pci::Bar or io::IoMem) which creates the actual I/O memory mapping and initializes `IoRaw` accordingly. To ensure that I/O mapped memory can't out-live the device it may be bound to, subsystems must embed the corresponding I/O memory type (e.g. pci::Bar) into a `Devres` container, such that it gets revoked once the device is unbound. Reviewed-by: Alice Ryhl <aliceryhl@google.com> Tested-by: Daniel Almeida <daniel.almeida@collabora.com> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com> Signed-off-by: Danilo Krummrich <dakr@kernel.org> Tested-by: Dirk Behme <dirk.behme@de.bosch.com> Link: https://lore.kernel.org/r/20241219170425.12036-8-dakr@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'rust/helpers/helpers.c')
-rw-r--r--rust/helpers/helpers.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
index 060750af6524..63f9b1da179f 100644
--- a/rust/helpers/helpers.c
+++ b/rust/helpers/helpers.c
@@ -14,6 +14,7 @@
#include "cred.c"
#include "err.c"
#include "fs.c"
+#include "io.c"
#include "jump_label.c"
#include "kunit.c"
#include "mutex.c"