pub struct OPP(/* private fields */);
Expand description
A reference-counted Operating performance point (OPP).
Rust abstraction for the C struct dev_pm_opp
.
§Invariants
The pointer stored in Self
is non-null and valid for the lifetime of the OPP
.
Instances of this type are reference-counted. The reference count is incremented by the
dev_pm_opp_get
function and decremented by dev_pm_opp_put
. The Rust type ARef<OPP>
represents a pointer that owns a reference count on the OPP
.
A reference to the OPP
, &OPP
, isn’t refcounted by the Rust code.
§Examples
The following example demonstrates how to get OPP
corresponding to a frequency value and
configure the device with it.
use kernel::clk::Hertz;
use kernel::error::Result;
use kernel::opp::{SearchType, Table};
fn configure_opp(table: &Table, freq: Hertz) -> Result {
let opp = table.opp_from_freq(freq, Some(true), None, SearchType::Exact)?;
if opp.freq(None) != freq {
return Err(EINVAL);
}
table.set_opp(&opp)
}
Implementations§
Source§impl OPP
impl OPP
Sourcepub unsafe fn from_raw_opp_owned(ptr: *mut dev_pm_opp) -> Result<ARef<Self>>
pub unsafe fn from_raw_opp_owned(ptr: *mut dev_pm_opp) -> Result<ARef<Self>>
Creates an owned reference to a OPP
from a valid pointer.
The refcount is incremented by the C code and will be decremented by dec_ref
when the
ARef
object is dropped.
§Safety
The caller must ensure that ptr
is valid and the refcount of the OPP
is incremented.
The caller must also ensure that it doesn’t explicitly drop the refcount of the OPP
, as
the returned ARef
object takes over the refcount increment on the underlying object and
the same will be dropped along with it.
Sourcepub unsafe fn from_raw_opp<'a>(ptr: *mut dev_pm_opp) -> Result<&'a Self>
pub unsafe fn from_raw_opp<'a>(ptr: *mut dev_pm_opp) -> Result<&'a Self>
Sourcepub fn required_pstate(&self, index: u32) -> u32
pub fn required_pstate(&self, index: u32) -> u32
Returns the required pstate of an OPP
.
Trait Implementations§
Source§impl AlwaysRefCounted for OPP
SAFETY: The type invariants guarantee that OPP
is always refcounted.
impl AlwaysRefCounted for OPP
SAFETY: The type invariants guarantee that OPP
is always refcounted.
impl Send for OPP
SAFETY: It is okay to send the ownership of OPP
across thread boundaries.
impl Sync for OPP
SAFETY: It is okay to access OPP
through shared references from other threads because we’re
either accessing properties that don’t change or that are properly synchronised by C code.