Struct FwNode

Source
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

Source

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.

Source

pub fn property_present(&self, name: &CStr) -> bool

Checks if property is present or not.

Source

pub fn property_read_bool(&self, name: &CStr) -> bool

Returns firmware property name boolean value.

Source

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.

Source

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.

Source

pub fn property_count_elem<T: PropertyInt>(&self, name: &CStr) -> Result<usize>

Returns integer array length for firmware property name.

Source

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

Source§

fn inc_ref(&self)

Increments the reference count on the object.
Source§

unsafe fn dec_ref(obj: NonNull<Self>)

Decrements the reference count on the object. Read more
Source§

impl Display for FwNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Init<T> for T

Source§

unsafe fn __init(self, slot: *mut T) -> Result<(), Infallible>

Initializes slot. Read more
Source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PinInit<T> for T

Source§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>

Initializes slot. Read more
Source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.