Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/drivers/cpufreq/rcpufreq_dt.rs b/drivers/cpufreq/rcpufreq_dt.rs
- index d7ead60bf8c2..0e069c0054dd 100644
- --- a/drivers/cpufreq/rcpufreq_dt.rs
- +++ b/drivers/cpufreq/rcpufreq_dt.rs
- @@ -177,13 +177,30 @@ fn verify(data: &mut cpufreq::PolicyData) -> Result {
- data.generic_verify()
- }
- - fn target_index(policy: &mut cpufreq::Policy, index: cpufreq::TableIndex) -> Result {
- + // EXPERIMENT ONLY: replaces `target_index` -- `cpufreq_register_driver()` rejects a
- + // driver offering both (cpufreq.c:2928, `!!setpolicy == (target_index || target)`).
- + //
- + // Ported from `longrun_set_policy()` (drivers/cpufreq/longrun.c): apply the policy's
- + // [min, max] window. longrun writes both bounds to MSRs and branches on
- + // `policy->policy`; cpufreq-dt has a single OPP rate and the Rust `Policy` API exposes
- + // no `policy->policy` accessor, so clamp the current rate into the window instead.
- + fn setpolicy(policy: &mut cpufreq::Policy) -> Result {
- + // `Policy::data()` borrows `policy` mutably, so read the limits first.
- + let (min, max, cur) = (policy.min(), policy.max(), policy.cur());
- +
- let Some(data) = policy.data::<Self::PData>() else {
- return Err(ENOENT);
- };
- - let freq = data.freq_table.freq(index)?;
- - data.opp_table.set_rate(freq)
- + let target = if cur.as_hz() < min.as_hz() {
- + min
- + } else if cur.as_hz() > max.as_hz() {
- + max
- + } else {
- + cur
- + };
- +
- + data.opp_table.set_rate(target)
- }
- fn get(policy: &mut cpufreq::Policy) -> Result<u32> {
Add Comment
Please, Sign In to add comment