mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
rust: io: add typedef for phys_addr_t
The C typedef phys_addr_t is missing an analogue in Rust, meaning that we end up using bindings::phys_addr_t or ResourceSize as a replacement in various places throughout the kernel. Fix that by introducing a new typedef on the Rust side. Place it next to the existing ResourceSize typedef since they're quite related to each other. Cc: stable@vger.kernel.org # for v6.18 [1] Signed-off-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20251112-resource-phys-typedefs-v2-4-538307384f82@google.com Link: https://lore.kernel.org/all/20251112-resource-phys-typedefs-v2-0-538307384f82@google.com/ [1] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
committed by
Danilo Krummrich
parent
ee2776e54b
commit
dd6ff5cf56
@@ -52,8 +52,20 @@ struct Inner<T: Send> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```no_run
|
||||
/// # use kernel::{bindings, device::{Bound, Device}, devres::Devres, io::{Io, IoRaw}};
|
||||
/// # use core::ops::Deref;
|
||||
/// use kernel::{
|
||||
/// bindings,
|
||||
/// device::{
|
||||
/// Bound,
|
||||
/// Device,
|
||||
/// },
|
||||
/// devres::Devres,
|
||||
/// io::{
|
||||
/// Io,
|
||||
/// IoRaw,
|
||||
/// PhysAddr,
|
||||
/// },
|
||||
/// };
|
||||
/// use core::ops::Deref;
|
||||
///
|
||||
/// // See also [`pci::Bar`] for a real example.
|
||||
/// struct IoMem<const SIZE: usize>(IoRaw<SIZE>);
|
||||
@@ -66,7 +78,7 @@ struct Inner<T: Send> {
|
||||
/// unsafe fn new(paddr: usize) -> Result<Self>{
|
||||
/// // SAFETY: By the safety requirements of this function [`paddr`, `paddr` + `SIZE`) is
|
||||
/// // valid for `ioremap`.
|
||||
/// let addr = unsafe { bindings::ioremap(paddr as bindings::phys_addr_t, SIZE) };
|
||||
/// let addr = unsafe { bindings::ioremap(paddr as PhysAddr, SIZE) };
|
||||
/// if addr.is_null() {
|
||||
/// return Err(ENOMEM);
|
||||
/// }
|
||||
|
||||
Reference in New Issue
Block a user