cpufreq: rust: Use C FFI types in bios_limit_callback
Subsystems (2)
PATCH 1/1 cpufreq: rust: Use C FFI types in bios_limit_callback
Update the bios_limit_callback function to use C FFI-compatible types (kernel::ffi::c_int and kernel::ffi::c_uint) for its parameters and return value. This ensures ABI compatibility with the corresponding C callback signature.
--- rust/kernel/cpufreq.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
rust/kernel/cpufreq.rs +1 -1
@@ -1277,7 +1277,7 @@ extern "C" fn update_limits_callback(ptr: *mut bindings::cpufreq_policy) {/// Driver's `bios_limit` callback. /// /// SAFETY: Called from C. Inputs must be valid pointers. -extern "C" fn bios_limit_callback (cpu:i32 , limit: *mut u32 ) -> kernel::ffi::c_int { +extern "C" fn bios_limit_callback (cpu: kernel::ffi::c_int , limit: *mut kernel::ffi::c_uint ) -> kernel::ffi::c_int {from_result (|| {let mut policy =PolicyCpu ::from_cpu (cpuas u32 )?;
Signature · 1 line
2.34.1
Benno Lossin
reviewerQuoted 17 lines · Abhinav Ananthu
Update the
bios_limit_callbackfunction to use C FFI-compatible types (kernel::ffi::c_intandkernel::ffi::c_uint) for its parameters and return value. This ensures ABI compatibility with the corresponding C callback signature.Reported-by Miguel Ojeda <[email protected]>Closes https://lore.kernel.org/rust-for-linux/CANiq72=WpuGELzLbH-fxdOeJy9fiDFwatz6ynERDh=HP2z2MBw@mail.gmail.com/. open hereSigned-off-by Abhinav Ananthu <[email protected]>--- rust/kernel/cpufreq.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)rust/kernel/cpufreq.rs +0
-0
rust/kernel/cpufreq.rs extern "C" fn update_limits_callback(ptr: *mut bindings::cpufreq_policy) { · line 1280
Quoted 5 lines
rust/kernel/cpufreq.rs +1
-1@@ -1277,7 +1277,7 @@ extern "C" fn update_limits_callback(ptr: *mut bindings::cpufreq_policy) {/// Driver's `bios_limit` callback. /// /// SAFETY: Called from C. Inputs must be valid pointers. -extern "C" fn bios_limit_callback (cpu:i32 , limit: *mut u32 ) -> kernel::ffi::c_int { +extern "C" fn bios_limit_callback (cpu: kernel::ffi::c_int , limit: *mut kernel::ffi::c_uint ) -> kernel::ffi::c_int {
This file imports the kernel's prelude, so you should be able to just use c_int and c_uint instead of their qualified names.
---
Cheers,
Benno
Quoted 3 lines
rust/kernel/cpufreq.rs +0
-0from_result (|| {let mut policy =PolicyCpu ::from_cpu (cpuas u32 )?;
PATCH v2 1/1 fix : Update the bios_limit_callback to use
PATCH(v1)
Update the bios_limit_callback function to use C FFI-compatible types (kernel::ffi::c_int and kernel::ffi::c_uint) for its parameters and return value. This ensures ABI compatibility with the corresponding C callback signature.
PATCH(v2)
updated the bios_limit_callback function to use c_int and c_uint directly via the prelude instead of the fully-qualified kernel::ffi::* paths.
--- rust/kernel/cpufreq.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
rust/kernel/cpufreq.rs +1 -1
@@ -1277,7 +1277,7 @@ extern "C" fn update_limits_callback(ptr: *mut bindings::cpufreq_policy) {/// Driver's `bios_limit` callback. /// /// SAFETY: Called from C. Inputs must be valid pointers. -extern "C" fn bios_limit_callback (cpu:i32 , limit: *mut u32 ) -> kernel::ffi::c_int { +extern "C" fn bios_limit_callback (cpu:c_int , limit: *mut c_uint ) ->c_int {from_result (|| {let mut policy =PolicyCpu ::from_cpu (cpuas u32 )?;
Signature · 1 line
2.34.1
Re: [PATCHv2 rust-for-linux] fix : Update the bios_limit_callback to use
Quoted 7 lines · Abhinav Ananthu
PATCH(v1)
Update thebios_limit_callbackfunction to use C FFI-compatible types (kernel::ffi::c_intandkernel::ffi::c_uint) for its parameters and return value. This ensures ABI compatibility with the corresponding C callback signature.
Quoted 7 lines
PATCH(v2)
updated thebios_limit_callbackfunction to usec_intandc_uintdirectly via the prelude instead of the fully-qualifiedkernel::ffi::*paths.
Cc'ing Viresh/Rafael/cpufreq, since this is on their subsystem (please see the entry in the MAINTAINERS file for rust/kernel/cpufreq.rs).
Also, please note that the changelog goes below the --- line. The commit message (above the --- line) should explain the "what" and the "why" of the current proposed changes, not other versions.
Finally, the title would normally have been something like:
[PATCH v2] rust: cpufreq: ...
Thanks for the patch!
Cheers,
Miguel