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::sync::aref::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
impl Table
Sourcepub fn from_of_cpumask(dev: &Device, cpumask: &mut Cpumask) -> Result<Self>
pub fn from_of_cpumask(dev: &Device, cpumask: &mut Cpumask) -> Result<Self>
Sourcepub fn max_clock_latency_ns(&self) -> usize
pub fn max_clock_latency_ns(&self) -> usize
Sourcepub fn max_volt_latency_ns(&self) -> usize
pub fn max_volt_latency_ns(&self) -> usize
Sourcepub fn max_transition_latency_ns(&self) -> usize
pub fn max_transition_latency_ns(&self) -> usize
Sourcepub fn suspend_freq(&self) -> Hertz
pub fn suspend_freq(&self) -> Hertz
Returns the suspend OPP’s frequency.
Sourcepub fn sync_regulators(&self) -> Result
pub fn sync_regulators(&self) -> Result
Synchronizes regulators used by the Table.
Sourcepub fn sharing_cpus(dev: &Device, cpumask: &mut Cpumask) -> Result
pub fn sharing_cpus(dev: &Device, cpumask: &mut Cpumask) -> Result
Gets sharing CPUs.
Sourcepub fn set_sharing_cpus(&mut self, cpumask: &mut Cpumask) -> Result
pub fn set_sharing_cpus(&mut self, cpumask: &mut Cpumask) -> Result
Sets sharing CPUs.
Sourcepub fn of_sharing_cpus(dev: &Device, cpumask: &mut Cpumask) -> Result
pub fn of_sharing_cpus(dev: &Device, cpumask: &mut Cpumask) -> Result
Gets sharing CPUs from device tree.
Sourcepub fn adjust_voltage(
&self,
freq: Hertz,
volt: MicroVolt,
volt_min: MicroVolt,
volt_max: MicroVolt,
) -> Result
pub fn adjust_voltage( &self, freq: Hertz, volt: MicroVolt, volt_min: MicroVolt, volt_max: MicroVolt, ) -> Result
Updates the voltage value for an OPP.
Sourcepub fn set_rate(&self, freq: Hertz) -> Result
pub fn set_rate(&self, freq: Hertz) -> Result
Configures device with OPP matching the frequency value.
Sourcepub fn opp_from_freq(
&self,
freq: Hertz,
available: Option<bool>,
index: Option<u32>,
stype: SearchType,
) -> Result<ARef<OPP>>
pub fn opp_from_freq( &self, freq: Hertz, available: Option<bool>, index: Option<u32>, stype: SearchType, ) -> Result<ARef<OPP>>
Finds OPP based on frequency.
Sourcepub fn opp_from_level(&self, level: u32, stype: SearchType) -> Result<ARef<OPP>>
pub fn opp_from_level(&self, level: u32, stype: SearchType) -> Result<ARef<OPP>>
Finds OPP based on level.
Sourcepub fn opp_from_bw(
&self,
bw: u32,
index: i32,
stype: SearchType,
) -> Result<ARef<OPP>>
pub fn opp_from_bw( &self, bw: u32, index: i32, stype: SearchType, ) -> Result<ARef<OPP>>
Finds OPP based on bandwidth.
Sourcepub fn enable_opp(&self, freq: Hertz) -> Result
pub fn enable_opp(&self, freq: Hertz) -> Result
Enables the OPP.
Sourcepub fn disable_opp(&self, freq: Hertz) -> Result
pub fn disable_opp(&self, freq: Hertz) -> Result
Disables the OPP.
Sourcepub fn of_register_em(&mut self, cpumask: &mut Cpumask) -> Result
pub fn of_register_em(&mut self, cpumask: &mut Cpumask) -> Result
Registers with the Energy model.
Trait Implementations§
impl Send for Table
SAFETY: It is okay to send ownership of Table across thread boundaries.
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 !RefUnwindSafe for Table
impl !UnwindSafe for Table
impl Forget for Table
impl Freeze for Table
impl Move for Table
impl Unpin for Table
impl UnsafeUnpin for Table
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<S, T> IntoSafeCast<T> for Swhere
T: FromSafeCast<S>,
impl<S, T> IntoSafeCast<T> for Swhere
T: FromSafeCast<S>,
Source§fn into_safe_cast(self) -> T
fn into_safe_cast(self) -> T
self into a T. This operation is guaranteed to be lossless.Source§impl<S, T> IntoSafeCastArch<T> for Swhere
T: FromSafeCastArch<S>,
impl<S, T> IntoSafeCastArch<T> for Swhere
T: FromSafeCastArch<S>,
Source§fn into_safe_cast_arch(self) -> T
fn into_safe_cast_arch(self) -> T
self into a T. This operation is guaranteed to be lossless.