Text of rust.docs.kernel.org › kernel › opp › struct.OPP.html as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

OPP in kernel::opp - Rust

Skip to main content OPP kernel :: opp Struct OPP Source 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 Source 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.

Source pub unsafe fn from_raw_opp <'a>(ptr: *mut dev_pm_opp) -> Result <&'a Self> Creates a reference to a OPP from a valid pointer. The refcount is not updated by the Rust API unless the returned reference is converted to an ARef object. § Safety The caller must ensure that ptr is valid and remains valid for the duration of 'a . Source pub fn freq (&self, index: Option < u32 >) -> Hertz Returns the frequency of an OPP .

Source pub fn voltage (&self) -> MicroVolt Returns the voltage of an OPP . Source pub fn level (&self) -> u32 Returns the level of an OPP . Source pub fn power (&self) -> MicroWatt Returns the power of an OPP . Source pub fn required_pstate (&self, index: u32 ) -> u32 Returns the required pstate of an OPP . Source pub fn is_turbo (&self) -> bool Returns true if the OPP is turbo. Trait Implementations § Source § impl AlwaysRefCounted for OPP SAFETY: The type invariants guarantee that OPP is always refcounted.

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 Send for OPP SAFETY: It is okay to send the ownership of OPP across thread boundaries. Source § 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.

Auto Trait Implementations § § impl ! Freeze for OPP § impl ! RefUnwindSafe for OPP § impl ! Unpin for OPP § impl ! UnsafeUnpin for OPP § impl UnwindSafe for OPP 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<ST, DT> CastableFrom <ST, Initialized , Initialized > for DT where ST: ? Sized , DT: ? Sized , Source § impl<ST, DT> CastableFrom <ST, Uninit , Uninit > for DT where ST: ? Sized , DT: ? Sized , 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 § 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<S, T> IntoSafeCast <T> for S where T: FromSafeCast <S>, Source § fn into_safe_cast (self) -> T Convert self into a T . This operation is guaranteed to be lossless. Source § impl<S, T> IntoSafeCastArch <T> for S where T: FromSafeCastArch <S>, Source § fn into_safe_cast_arch (self) -> T Convert self into a T . This operation is guaranteed to be lossless. Source § impl<T> KnownSize for T Source § const MIN_SIZE : usize = const MIN_SIZE: usize = size_of::<T>(); Minimum size of this type known at compile-time.

Source § const MIN_ALIGN : Alignment = const MIN_ALIGN: Alignment = Alignment::of::<T>(); Minimum alignment of this type known at compile-time. Source § fn size (_: *const T ) -> usize Get the size of an object of this type in bytes, with the metadata of the given pointer. Source § impl<T> PinInit <T> for T Source § unsafe fn __init (self, slot: *mut T ) -> Result < () , ! > 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> Read < Exclusive , BecauseExclusive > for T where T: ? Sized , Source § impl<T, U> TryFrom <U> for T where U: Into <T>, Source § type Error = ! The type returned in the event of a conversion error. Source § fn try_from (value: U) -> Result <T, ! > 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. Source § impl<T, U, const N: u32 > TryIntoBounded <T, N> for U where T: Integer , U: TryInto <T>, Source § fn try_into_bounded (self) -> Option < Bounded <T, N>> Attempts to convert self into a Bounded using N bits. Read more