pub struct IoRequest<'a> { /* private fields */ }Expand description
An IO request for a specific device and resource.
Implementations§
Source§impl<'a> IoRequest<'a>
 
impl<'a> IoRequest<'a>
Sourcepub fn iomap_sized<const SIZE: usize>(
    self,
) -> impl PinInit<Devres<IoMem<SIZE>>, Error> + 'a
 
pub fn iomap_sized<const SIZE: usize>( self, ) -> impl PinInit<Devres<IoMem<SIZE>>, Error> + 'a
Maps an IoRequest where the size is known at compile time.
This uses the ioremap() C API.
§Examples
The following example uses a kernel::platform::Device for
illustration purposes.
use kernel::{bindings, c_str, platform, of, device::Core};
struct SampleDriver;
impl platform::Driver for SampleDriver {
   fn probe(
      pdev: &platform::Device<Core>,
      info: Option<&Self::IdInfo>,
   ) -> impl PinInit<Self, Error> {
      let offset = 0; // Some offset.
      // If the size is known at compile time, use [`Self::iomap_sized`].
      //
      // No runtime checks will apply when reading and writing.
      let request = pdev.io_request_by_index(0).ok_or(ENODEV)?;
      let iomem = request.iomap_sized::<42>();
      let iomem = KBox::pin_init(iomem, GFP_KERNEL)?;
      let io = iomem.access(pdev.as_ref())?;
      // Read and write a 32-bit value at `offset`.
      let data = io.read32_relaxed(offset);
      io.write32_relaxed(data, offset);
    }
}Sourcepub fn iomap_exclusive_sized<const SIZE: usize>(
    self,
) -> impl PinInit<Devres<ExclusiveIoMem<SIZE>>, Error> + 'a
 
pub fn iomap_exclusive_sized<const SIZE: usize>( self, ) -> impl PinInit<Devres<ExclusiveIoMem<SIZE>>, Error> + 'a
Same as Self::iomap_sized but with exclusive access to the
underlying region.
This uses the ioremap() C API.
Sourcepub fn iomap(self) -> impl PinInit<Devres<IoMem<0>>, Error> + 'a
 
pub fn iomap(self) -> impl PinInit<Devres<IoMem<0>>, Error> + 'a
Maps an IoRequest where the size is not known at compile time,
This uses the ioremap() C API.
§Examples
The following example uses a kernel::platform::Device for
illustration purposes.
use kernel::{bindings, c_str, platform, of, device::Core};
struct SampleDriver;
impl platform::Driver for SampleDriver {
   fn probe(
      pdev: &platform::Device<Core>,
      info: Option<&Self::IdInfo>,
   ) -> impl PinInit<Self, Error> {
      let offset = 0; // Some offset.
      // Unlike [`Self::iomap_sized`], here the size of the memory region
      // is not known at compile time, so only the `try_read*` and `try_write*`
      // family of functions should be used, leading to runtime checks on every
      // access.
      let request = pdev.io_request_by_index(0).ok_or(ENODEV)?;
      let iomem = request.iomap();
      let iomem = KBox::pin_init(iomem, GFP_KERNEL)?;
      let io = iomem.access(pdev.as_ref())?;
      let data = io.try_read32_relaxed(offset)?;
      io.try_write32_relaxed(data, offset)?;
    }
}Sourcepub fn iomap_exclusive(
    self,
) -> impl PinInit<Devres<ExclusiveIoMem<0>>, Error> + 'a
 
pub fn iomap_exclusive( self, ) -> impl PinInit<Devres<ExclusiveIoMem<0>>, Error> + 'a
Same as Self::iomap but with exclusive access to the underlying
region.
Auto Trait Implementations§
impl<'a> Freeze for IoRequest<'a>
impl<'a> !RefUnwindSafe for IoRequest<'a>
impl<'a> !Send for IoRequest<'a>
impl<'a> !Sync for IoRequest<'a>
impl<'a> Unpin for IoRequest<'a>
impl<'a> !UnwindSafe for IoRequest<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> PinInit<T> for T
 
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
 
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
Initializes 
slot. Read more