Struct Config

Source
pub struct Config<T>
where T: Default + ConfigOps,
{ /* private fields */ }
Expand description

OPP configurations.

Rust abstraction for the C struct dev_pm_opp_config.

§Examples

The following example demonstrates how to set OPP property-name configuration for a Device.

use kernel::device::Device;
use kernel::error::Result;
use kernel::opp::{Config, ConfigOps, ConfigToken};
use kernel::str::CString;
use kernel::types::ARef;
use kernel::macros::vtable;

#[derive(Default)]
struct Driver;

#[vtable]
impl ConfigOps for Driver {}

fn configure(dev: &ARef<Device>) -> Result<ConfigToken> {
    let name = CString::try_from_fmt(fmt!("{}", "slow"))?;

    // The OPP configuration is cleared once the [`ConfigToken`] goes out of scope.
    Config::<Driver>::new()
        .set_prop_name(name)?
        .set(dev)
}

Implementations§

Source§

impl<T: ConfigOps + Default> Config<T>

Source

pub fn new() -> Self

Creates a new instance of Config.

Source

pub fn set_clk_names(self, names: KVec<CString>) -> Result<Self>

Initializes clock names.

Source

pub fn set_prop_name(self, name: CString) -> Result<Self>

Initializes property name.

Source

pub fn set_regulator_names(self, names: KVec<CString>) -> Result<Self>

Initializes regulator names.

Source

pub fn set_required_dev(self, dev: ARef<Device>, index: u32) -> Result<Self>

Initializes required devices.

Source

pub fn set_supported_hw(self, hw: KVec<u32>) -> Result<Self>

Initializes supported hardware.

Source

pub fn set(self, dev: &Device) -> Result<ConfigToken>

Sets the configuration with the OPP core.

The returned ConfigToken will remove the configuration when dropped.

Trait Implementations§

Source§

impl<T> Default for Config<T>
where T: Default + Default + ConfigOps,

Source§

fn default() -> Config<T>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Config<T>

§

impl<T> !RefUnwindSafe for Config<T>

§

impl<T> Send for Config<T>
where T: Send,

§

impl<T> Sync for Config<T>
where T: Sync,

§

impl<T> !Unpin for Config<T>

§

impl<T> !UnwindSafe for Config<T>

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, E> Init<T, E> for T

Source§

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

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, E> PinInit<T, E> for T

Source§

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

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.