* [PATCH] cpufreq: rust: Use C FFI types in bios_limit_callback
@ 2025-06-12 6:09 Abhinav Ananthu
2025-06-12 7:43 ` Benno Lossin
0 siblings, 1 reply; 4+ messages in thread
From: Abhinav Ananthu @ 2025-06-12 6:09 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor
Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
rust-for-linux, Abhinav Ananthu
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.
Reported-by: Miguel Ojeda <ojeda@kernel.org>
Closes: https://lore.kernel.org/rust-for-linux/CANiq72=WpuGELzLbH-fxdOeJy9fiDFwatz6ynERDh=HP2z2MBw@mail.gmail.com/.
Signed-off-by: Abhinav Ananthu <abhinav.ogl@gmail.com>
---
rust/kernel/cpufreq.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rust/kernel/cpufreq.rs b/rust/kernel/cpufreq.rs
index b0a9c6182aec..7ef2f64d8f34 100644
--- a/rust/kernel/cpufreq.rs
+++ b/rust/kernel/cpufreq.rs
@@ -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(cpu as u32)?;
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] cpufreq: rust: Use C FFI types in bios_limit_callback
2025-06-12 6:09 [PATCH] cpufreq: rust: Use C FFI types in bios_limit_callback Abhinav Ananthu
@ 2025-06-12 7:43 ` Benno Lossin
2025-06-12 8:46 ` [PATCHv2 rust-for-linux] fix : Update the bios_limit_callback to use Abhinav Ananthu
0 siblings, 1 reply; 4+ messages in thread
From: Benno Lossin @ 2025-06-12 7:43 UTC (permalink / raw)
To: Abhinav Ananthu, Miguel Ojeda, Alex Gaynor
Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Andreas Hindborg,
Alice Ryhl, Trevor Gross, Danilo Krummrich, rust-for-linux
On Thu Jun 12, 2025 at 8:09 AM CEST, Abhinav Ananthu wrote:
> 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.
>
> Reported-by: Miguel Ojeda <ojeda@kernel.org>
> Closes: https://lore.kernel.org/rust-for-linux/CANiq72=WpuGELzLbH-fxdOeJy9fiDFwatz6ynERDh=HP2z2MBw@mail.gmail.com/.
> Signed-off-by: Abhinav Ananthu <abhinav.ogl@gmail.com>
> ---
> rust/kernel/cpufreq.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/rust/kernel/cpufreq.rs b/rust/kernel/cpufreq.rs
> index b0a9c6182aec..7ef2f64d8f34 100644
> --- a/rust/kernel/cpufreq.rs
> +++ b/rust/kernel/cpufreq.rs
> @@ -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
> from_result(|| {
> let mut policy = PolicyCpu::from_cpu(cpu as u32)?;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCHv2 rust-for-linux] fix : Update the bios_limit_callback to use
2025-06-12 7:43 ` Benno Lossin
@ 2025-06-12 8:46 ` Abhinav Ananthu
2025-06-12 9:38 ` Miguel Ojeda
0 siblings, 1 reply; 4+ messages in thread
From: Abhinav Ananthu @ 2025-06-12 8:46 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor
Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
rust-for-linux, Abhinav Ananthu
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.
Reported-by: Miguel Ojeda <ojeda@kernel.org>
Closes: https://lore.kernel.org/rust-for-linux/CANiq72=WpuGELzLbH-fxdOeJy9fiDFwatz6ynERDh=HP2z2MBw@mail.gmail.com/.
Signed-off-by: Abhinav Ananthu <abhinav.ogl@gmail.com>
---
rust/kernel/cpufreq.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rust/kernel/cpufreq.rs b/rust/kernel/cpufreq.rs
index b0a9c6182aec..e97607ed86c2 100644
--- a/rust/kernel/cpufreq.rs
+++ b/rust/kernel/cpufreq.rs
@@ -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(cpu as u32)?;
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCHv2 rust-for-linux] fix : Update the bios_limit_callback to use
2025-06-12 8:46 ` [PATCHv2 rust-for-linux] fix : Update the bios_limit_callback to use Abhinav Ananthu
@ 2025-06-12 9:38 ` Miguel Ojeda
0 siblings, 0 replies; 4+ messages in thread
From: Miguel Ojeda @ 2025-06-12 9:38 UTC (permalink / raw)
To: Abhinav Ananthu, Viresh Kumar
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-pm,
Rafael J. Wysocki
On Thu, Jun 12, 2025 at 10:47 AM Abhinav Ananthu <abhinav.ogl@gmail.com> wrote:
>
> 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.
>
> Reported-by: Miguel Ojeda <ojeda@kernel.org>
> Closes: https://lore.kernel.org/rust-for-linux/CANiq72=WpuGELzLbH-fxdOeJy9fiDFwatz6ynERDh=HP2z2MBw@mail.gmail.com/.
> Signed-off-by: Abhinav Ananthu <abhinav.ogl@gmail.com>
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-12 9:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-12 6:09 [PATCH] cpufreq: rust: Use C FFI types in bios_limit_callback Abhinav Ananthu
2025-06-12 7:43 ` Benno Lossin
2025-06-12 8:46 ` [PATCHv2 rust-for-linux] fix : Update the bios_limit_callback to use Abhinav Ananthu
2025-06-12 9:38 ` Miguel Ojeda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).