pub struct FwNode(/* private fields */);
Expand description
A reference-counted fwnode_handle.
This structure represents the Rust abstraction for a
C struct fwnode_handle
. This implementation abstracts the usage of an
already existing C struct fwnode_handle
within Rust code that we get
passed from the C side.
§Invariants
A FwNode
instance represents a valid struct fwnode_handle
created by the
C portion of the kernel.
Instances of this type are always reference-counted, that is, a call to
fwnode_handle_get
ensures that the allocation remains valid at least until
the matching call to fwnode_handle_put
.
Implementations§
Source§impl FwNode
impl FwNode
Sourcepub fn display_name(&self) -> impl Display + '_
pub fn display_name(&self) -> impl Display + '_
Returns an object that implements Display
for
printing the name of a node.
This is an alternative to the default Display
implementation, which
prints the full path.
Sourcepub fn property_present(&self, name: &CStr) -> bool
pub fn property_present(&self, name: &CStr) -> bool
Checks if property is present or not.
Sourcepub fn property_read_bool(&self, name: &CStr) -> bool
pub fn property_read_bool(&self, name: &CStr) -> bool
Returns firmware property name
boolean value.
Sourcepub fn property_match_string(
&self,
name: &CStr,
match_str: &CStr,
) -> Result<usize>
pub fn property_match_string( &self, name: &CStr, match_str: &CStr, ) -> Result<usize>
Returns the index of matching string match_str
for firmware string
property name
.
Sourcepub fn property_read_array_vec<'fwnode, 'name, T: PropertyInt>(
&'fwnode self,
name: &'name CStr,
len: usize,
) -> Result<PropertyGuard<'fwnode, 'name, KVec<T>>>
pub fn property_read_array_vec<'fwnode, 'name, T: PropertyInt>( &'fwnode self, name: &'name CStr, len: usize, ) -> Result<PropertyGuard<'fwnode, 'name, KVec<T>>>
Returns firmware property name
integer array values in a KVec
.
Sourcepub fn property_count_elem<T: PropertyInt>(&self, name: &CStr) -> Result<usize>
pub fn property_count_elem<T: PropertyInt>(&self, name: &CStr) -> Result<usize>
Returns integer array length for firmware property name
.
Sourcepub fn property_read<'fwnode, 'name, T: Property>(
&'fwnode self,
name: &'name CStr,
) -> PropertyGuard<'fwnode, 'name, T>
pub fn property_read<'fwnode, 'name, T: Property>( &'fwnode self, name: &'name CStr, ) -> PropertyGuard<'fwnode, 'name, T>
Returns the value of firmware property name
.
This method is generic over the type of value to read. The types that can be read are strings, integers and arrays of integers.
Reading a KVec
of integers is done with the separate
method Self::property_read_array_vec
, because it takes an
additional len
argument.
Reading a boolean is done with the separate method
Self::property_read_bool
, because this operation is infallible.
For more precise documentation about what types can be read, see the implementors of Property and its implementations on foreign types.
§Examples
fn examples(dev: &Device) -> Result {
let fwnode = dev.fwnode().ok_or(ENOENT)?;
let b: u32 = fwnode.property_read(c_str!("some-number")).required_by(dev)?;
if let Some(s) = fwnode.property_read::<CString>(c_str!("some-str")).optional() {
// ...
}
Ok(())
}
Trait Implementations§
Source§impl AlwaysRefCounted for FwNode
impl AlwaysRefCounted for FwNode
Auto Trait Implementations§
impl !Freeze for FwNode
impl !RefUnwindSafe for FwNode
impl !Send for FwNode
impl !Sync for FwNode
impl !Unpin for FwNode
impl UnwindSafe for FwNode
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
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>
slot
. Read more