Skip to content

Commit b7dc260

Browse files
committed
rust: io_mem: Add accessor functions for resource start/size
Add Resource::start() and Resource::size() to return the resource properties. Signed-off-by: Asahi Lina <[email protected]>
1 parent f48e140 commit b7dc260

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

rust/kernel/io_mem.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
77
#![allow(dead_code)]
88

9-
use crate::{bindings, error::code::*, error::Result};
9+
use crate::{addr::*, bindings, error::code::*, error::Result};
1010
use core::convert::TryInto;
11+
use core::ptr::NonNull;
1112

1213
/// The type of `Resource`.
1314
pub enum IoResource {
@@ -41,6 +42,16 @@ impl Resource {
4142
pub(crate) fn new_from_resource(res: &bindings::resource) -> Option<Self> {
4243
Self::new(res.start, res.end, res.flags)
4344
}
45+
46+
/// Returns the start of this memory resource as a [`PhysicalAddr`]
47+
pub fn start(&self) -> PhysicalAddr {
48+
self.offset
49+
}
50+
51+
/// Returns the size of this memory resource as a [`ResourceSize`]
52+
pub fn size(&self) -> ResourceSize {
53+
self.size
54+
}
4455
}
4556

4657
/// Represents a memory block of at least `SIZE` bytes.

0 commit comments

Comments
 (0)