Struct Table

Source
pub struct Table { /* private fields */ }
Expand description

A reference-counted OPP table.

Rust abstraction for the C struct opp_table.

§Invariants

The pointer stored in Self is non-null and valid for the lifetime of the Table.

Instances of this type are reference-counted.

§Examples

The following example demonstrates how to get OPP Table for a Cpumask and set its frequency.

use kernel::clk::Hertz;
use kernel::cpumask::Cpumask;
use kernel::device::Device;
use kernel::error::Result;
use kernel::opp::Table;
use kernel::types::ARef;

fn get_table(dev: &ARef<Device>, mask: &mut Cpumask, freq: Hertz) -> Result<Table> {
    let mut opp_table = Table::from_of_cpumask(dev, mask)?;

    if opp_table.opp_count()? == 0 {
        return Err(EINVAL);
    }

    pr_info!("Max transition latency is: {} ns\n", opp_table.max_transition_latency_ns());
    pr_info!("Suspend frequency is: {:?}\n", opp_table.suspend_freq());

    opp_table.set_rate(freq)?;
    Ok(opp_table)
}

Implementations§

Source§

impl Table

Source

pub fn from_dev(dev: &Device) -> Result<Self>

Creates a new reference-counted Table instance for a Device.

Source

pub fn from_of(dev: &ARef<Device>, index: i32) -> Result<Self>

Creates a new reference-counted Table instance for a Device based on device tree entries.

Source

pub fn from_of_cpumask(dev: &Device, cpumask: &mut Cpumask) -> Result<Self>

Creates a new reference-counted Table instance for a Cpumask based on device tree entries.

Source

pub fn opp_count(&self) -> Result<u32>

Returns the number of OPPs in the Table.

Source

pub fn max_clock_latency_ns(&self) -> usize

Returns max clock latency (in nanoseconds) of the OPPs in the Table.

Source

pub fn max_volt_latency_ns(&self) -> usize

Returns max volt latency (in nanoseconds) of the OPPs in the Table.

Source

pub fn max_transition_latency_ns(&self) -> usize

Returns max transition latency (in nanoseconds) of the OPPs in the Table.

Source

pub fn suspend_freq(&self) -> Hertz

Returns the suspend OPP’s frequency.

Source

pub fn sync_regulators(&self) -> Result<()>

Synchronizes regulators used by the Table.

Source

pub fn sharing_cpus(dev: &Device, cpumask: &mut Cpumask) -> Result<()>

Gets sharing CPUs.

Source

pub fn set_sharing_cpus(&mut self, cpumask: &mut Cpumask) -> Result<()>

Sets sharing CPUs.

Source

pub fn of_sharing_cpus(dev: &Device, cpumask: &mut Cpumask) -> Result<()>

Gets sharing CPUs from device tree.

Source

pub fn adjust_voltage( &self, freq: Hertz, volt: MicroVolt, volt_min: MicroVolt, volt_max: MicroVolt, ) -> Result<()>

Updates the voltage value for an OPP.

Source

pub fn cpufreq_table(&mut self) -> Result<FreqTable>

Creates FreqTable from Table.

Source

pub fn set_rate(&self, freq: Hertz) -> Result<()>

Configures device with OPP matching the frequency value.

Source

pub fn set_opp(&self, opp: &OPP) -> Result<()>

Configures device with OPP.

Source

pub fn opp_from_freq( &self, freq: Hertz, available: Option<bool>, index: Option<u32>, stype: SearchType, ) -> Result<ARef<OPP>>

Finds OPP based on frequency.

Source

pub fn opp_from_level(&self, level: u32, stype: SearchType) -> Result<ARef<OPP>>

Finds OPP based on level.

Source

pub fn opp_from_bw( &self, bw: u32, index: i32, stype: SearchType, ) -> Result<ARef<OPP>>

Finds OPP based on bandwidth.

Source

pub fn enable_opp(&self, freq: Hertz) -> Result<()>

Enables the OPP.

Source

pub fn disable_opp(&self, freq: Hertz) -> Result<()>

Disables the OPP.

Source

pub fn of_register_em(&mut self, cpumask: &mut Cpumask) -> Result<()>

Registers with the Energy model.

Trait Implementations§

Source§

impl Drop for Table

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Table

SAFETY: It is okay to send ownership of Table across thread boundaries.

Source§

impl Sync for Table

SAFETY: It is okay to access Table through shared references from other threads because we’re either accessing properties that don’t change or that are properly synchronised by C code.

Auto Trait Implementations§

§

impl Freeze for Table

§

impl !RefUnwindSafe for Table

§

impl !Unpin for Table

§

impl !UnwindSafe for Table

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.