On Fri Jun 12, 2026 at 1:28 AM JST, Gary Guo wrote: > Currently, `Io` is implemented on owned I/O objects (e.g. `Bar`). This is > going to change with I/O projections, as then `Io` need to work both for
nit: s/need/needs. > owned objects and views of them. Views are themselves reference-like > (however they obviously cannot be references, because they belong to a > different address space). > > To faciliate the change, change `Io` to be implemented on reference types typo: facilitate. > for the owned I/O objects, and make methods take `self` instead of `&self`. > When I/O views are implemented, we can then naturally implement `Io` for > these objects. > > Signed-off-by: Gary Guo <[email protected]> > --- > rust/kernel/io.rs | 80 > +++++++++++++++++++++++++-------------------------- > rust/kernel/pci/io.rs | 12 ++++---- > 2 files changed, 46 insertions(+), 46 deletions(-) > > diff --git a/rust/kernel/io.rs b/rust/kernel/io.rs > index 38281636b4da..3b478dcf10f9 100644 > --- a/rust/kernel/io.rs > +++ b/rust/kernel/io.rs > @@ -224,7 +224,7 @@ pub trait IoCapable<T> { > /// > /// - The range `[address..address + size_of::<T>()]` must be within the > bounds of `Self`. > /// - `address` must be aligned. > - unsafe fn io_read(&self, address: usize) -> T; > + unsafe fn io_read(self, address: usize) -> T; > > /// Performs an I/O write of `value` at `address`. > /// > @@ -232,7 +232,7 @@ pub trait IoCapable<T> { > /// > /// - The range `[address..address + size_of::<T>()]` must be within the > bounds of `Self`. > /// - `address` must be aligned. > - unsafe fn io_write(&self, value: T, address: usize); > + unsafe fn io_write(self, value: T, address: usize); > } > > /// Describes a given I/O location: its offset, width, and type to convert > the raw value from and > @@ -299,21 +299,21 @@ fn offset(self) -> usize { > /// > /// For MMIO regions, all widths (u8, u16, u32, and u64 on 64-bit systems) > are typically > /// supported. For PCI configuration space, u8, u16, and u32 are supported > but u64 is not. > -pub trait Io { > +pub trait Io: Copy { This requirement on `Copy` could seem a bit confusing without context - maybe mention explicitly in `Io`'s doccomment that this type is expected to be implemented on cheaply copyable handles like references and views? Regardless, Reviewed-by: Alexandre Courbot <[email protected]>
