Skip to contentSkip to conversation

rust: opp: use c_* types via kernel prelude

PATCH Applied Abhinav Ananthu 3 participants 3 messages Jun 20, 2025 – Jun 23, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rust: opp: use c_* types via kernel prelude

Update OPP FFI callback signatures to use c_int from the kernel::prelude, instead of accessing it via kernel::ffi::c_int.

Although these types are defined in a crate named ffi, they are re-exported via the kernel::prelude and should be used from there. This aligns with the Rust-for-Linux coding guidelines and ensures ABI correctness when interfacing with C code.

---
 rust/kernel/opp.rs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
rust/kernel/opp.rs +4 -4
index a566fc3e7dcb..846583da9a2f 100644
@@ -514,9 +514,9 @@ extern "C" fn config_clks(
         dev: *mut bindings::device,
         opp_table: *mut bindings::opp_table,
         opp: *mut bindings::dev_pm_opp,
-        _data: *mut kernel::ffi::c_void,
+        _data: *mut c_void,
         scaling_down: bool,
-    ) -> kernel::ffi::c_int {
+    ) -> c_int {
         from_result(|| {
             // SAFETY: 'dev' is guaranteed by the C code to be valid.
             let dev = unsafe { Device::get_device(dev) };
@@ -540,8 +540,8 @@ extern "C" fn config_regulators(
         old_opp: *mut bindings::dev_pm_opp,
         new_opp: *mut bindings::dev_pm_opp,
         regulators: *mut *mut bindings::regulator,
-        count: kernel::ffi::c_uint,
-    ) -> kernel::ffi::c_int {
+        count: c_uint,
+    ) -> c_int {
         from_result(|| {
             // SAFETY: 'dev' is guaranteed by the C code to be valid.
             let dev = unsafe { Device::get_device(dev) };
Signature · 1 line
2.34.1
#1 lore raw
Quoted 5 lines · Abhinav Ananthu

Although these types are defined in a crate named ffi, they are re-exported via the kernel::prelude and should be used from there. This aligns with the Rust-for-Linux coding guidelines and ensures ABI correctness when interfacing with C code.

By the way, thanks for sending these, and please feel free to clean up the rest -- we have a bunch of instances of this in the tree :)

Happy to create an issue about it.

Cheers,
Miguel

Applied
#2 lore raw
In reply to Abhinav Ananthu
Quoted 8 lines · Abhinav Ananthu

Update OPP FFI callback signatures to use c_int from the kernel::prelude, instead of accessing it via kernel::ffi::c_int.

Although these types are defined in a crate named ffi, they are re-exported via the kernel::prelude and should be used from there. This aligns with the Rust-for-Linux coding guidelines and ensures ABI correctness when interfacing with C code.

Quoted 5 lines
---
 rust/kernel/opp.rs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Applied. Thanks.

Signature · 1 line
viresh