lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240815082916.1210110-5-pierre.gondois@arm.com>
Date: Thu, 15 Aug 2024 10:29:08 +0200
From: Pierre Gondois <pierre.gondois@....com>
To: linux-kernel@...r.kernel.org
Cc: Pierre Gondois <pierre.gondois@....com>,
	"Rafael J. Wysocki" <rafael@...nel.org>,
	Len Brown <lenb@...nel.org>,
	Viresh Kumar <viresh.kumar@...aro.org>,
	Robert Moore <robert.moore@...el.com>,
	Miguel Ojeda <ojeda@...nel.org>,
	Alex Gaynor <alex.gaynor@...il.com>,
	Wedson Almeida Filho <wedsonaf@...il.com>,
	Boqun Feng <boqun.feng@...il.com>,
	Gary Guo <gary@...yguo.net>,
	Björn Roy Baron <bjorn3_gh@...tonmail.com>,
	Benno Lossin <benno.lossin@...ton.me>,
	Andreas Hindborg <a.hindborg@...sung.com>,
	Alice Ryhl <aliceryhl@...gle.com>,
	Martin Rodriguez Reboredo <yakoyoku@...il.com>,
	Manos Pitsidianakis <manos.pitsidianakis@...aro.org>,
	Danilo Krummrich <dakr@...hat.com>,
	"Rob Herring (Arm)" <robh@...nel.org>,
	FUJITA Tomonori <fujita.tomonori@...il.com>,
	Mika Westerberg <mika.westerberg@...ux.intel.com>,
	Thomas Bertschinger <tahbertschinger@...il.com>,
	linux-acpi@...r.kernel.org,
	linux-pm@...r.kernel.org,
	acpica-devel@...ts.linux.dev,
	rust-for-linux@...r.kernel.org
Subject: [RFC PATCH 4/6] rust: cpufreq: Add methods to struct Cpufreq

The following methods are added and seamlessly allow to get/set
the matching fields in the C definition of the `struct cpufreq`:
- set_min()
- set_max()
- set_cur()
- fast_switch_possible()
- set_fast_switch_possible()
- set_cpuinfo_min_freq()
- set_cpuinfo_max_freq()
- set_transition_delay_us()
- set_shared_type()

Signed-off-by: Pierre Gondois <pierre.gondois@....com>
---
 rust/kernel/cpufreq.rs | 53 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/rust/kernel/cpufreq.rs b/rust/kernel/cpufreq.rs
index b395694de6c4..588080724fbf 100644
--- a/rust/kernel/cpufreq.rs
+++ b/rust/kernel/cpufreq.rs
@@ -318,16 +318,34 @@ pub fn min(&self) -> u32 {
         self.as_ref().min
     }
 
+    /// Set the minimum frequency for a cpufreq policy.
+    pub fn set_min(&mut self, min: u32) -> &mut Self {
+        self.as_mut_ref().min = min;
+        self
+    }
+
     /// Returns the maximum frequency for a cpufreq policy.
     pub fn max(&self) -> u32 {
         self.as_ref().max
     }
 
+    /// Set the maximum frequency for a cpufreq policy.
+    pub fn set_max(&mut self, max: u32) -> &mut Self {
+        self.as_mut_ref().max = max;
+        self
+    }
+
     /// Returns the current frequency for a cpufreq policy.
     pub fn cur(&self) -> u32 {
         self.as_ref().cur
     }
 
+    /// Set the current frequency for a cpufreq policy.
+    pub fn set_cur(&mut self, cur: u32) -> &mut Self {
+        self.as_mut_ref().cur = cur;
+        self
+    }
+
     /// Sets the suspend frequency for a cpufreq policy.
     pub fn set_suspend_freq(&mut self, freq: u32) -> &mut Self {
         self.as_mut_ref().suspend_freq = freq;
@@ -378,12 +396,47 @@ pub fn set_dvfs_possible_from_any_cpu(&mut self) -> &mut Self {
         self
     }
 
+    /// Get fast_switch_possible value.
+    pub fn fast_switch_possible(&self) -> bool {
+        self.as_ref().fast_switch_possible
+    }
+
+    /// Enable/disable fast frequency switching.
+    pub fn set_fast_switch_possible(&mut self, val: bool) -> &mut Self {
+        self.as_mut_ref().fast_switch_possible = val;
+        self
+    }
+
     /// Sets transition latency for a cpufreq policy.
     pub fn set_transition_latency(&mut self, latency: u32) -> &mut Self {
         self.as_mut_ref().cpuinfo.transition_latency = latency;
         self
     }
 
+    /// Set cpuinfo.min_freq.
+    pub fn set_cpuinfo_min_freq(&mut self, min_freq: u32) -> &mut Self {
+        self.as_mut_ref().cpuinfo.min_freq = min_freq;
+        self
+    }
+
+    /// Set cpuinfo.max_freq.
+    pub fn set_cpuinfo_max_freq(&mut self, max_freq: u32) -> &mut Self {
+        self.as_mut_ref().cpuinfo.max_freq = max_freq;
+        self
+    }
+
+    /// Set transition_delay_us, i.e. time between successive freq. change requests.
+    pub fn set_transition_delay_us(&mut self, transition_delay_us: u32) -> &mut Self {
+        self.as_mut_ref().transition_delay_us = transition_delay_us;
+        self
+    }
+
+    /// Set shared_type, how CPUs coordinate freq. requests (ACPI only).
+    pub fn set_shared_type(&mut self, shared_type: u32) -> &mut Self {
+        self.as_mut_ref().shared_type = shared_type;
+        self
+    }
+
     /// Returns the cpufreq table for a cpufreq policy. The cpufreq table is recreated in a
     /// light-weight manner from the raw pointer. The table in C code is not freed once this table
     /// is dropped.
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ