* [PATCH] rust: opp: use c_* types via kernel prelude
@ 2025-06-20 9:59 Abhinav Ananthu
2025-06-20 10:14 ` Miguel Ojeda
2025-06-23 4:22 ` Viresh Kumar
0 siblings, 2 replies; 3+ messages in thread
From: Abhinav Ananthu @ 2025-06-20 9:59 UTC (permalink / raw)
To: vireshk, nm, sboyd
Cc: ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin,
a.hindborg, aliceryhl, tmgross, dakr, linux-pm, rust-for-linux,
linux-kernel, Abhinav Ananthu, Viresh Kumar
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.
Signed-off-by: Abhinav Ananthu <abhinav.ogl@gmail.com>
Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
---
rust/kernel/opp.rs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/rust/kernel/opp.rs b/rust/kernel/opp.rs
index a566fc3e7dcb..846583da9a2f 100644
--- a/rust/kernel/opp.rs
+++ b/rust/kernel/opp.rs
@@ -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) };
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] rust: opp: use c_* types via kernel prelude
2025-06-20 9:59 [PATCH] rust: opp: use c_* types via kernel prelude Abhinav Ananthu
@ 2025-06-20 10:14 ` Miguel Ojeda
2025-06-23 4:22 ` Viresh Kumar
1 sibling, 0 replies; 3+ messages in thread
From: Miguel Ojeda @ 2025-06-20 10:14 UTC (permalink / raw)
To: Abhinav Ananthu
Cc: vireshk, nm, sboyd, ojeda, alex.gaynor, boqun.feng, gary,
bjorn3_gh, lossin, a.hindborg, aliceryhl, tmgross, dakr, linux-pm,
rust-for-linux, linux-kernel, Viresh Kumar
On Fri, Jun 20, 2025 at 12:00 PM Abhinav Ananthu <abhinav.ogl@gmail.com> wrote:
>
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] rust: opp: use c_* types via kernel prelude
2025-06-20 9:59 [PATCH] rust: opp: use c_* types via kernel prelude Abhinav Ananthu
2025-06-20 10:14 ` Miguel Ojeda
@ 2025-06-23 4:22 ` Viresh Kumar
1 sibling, 0 replies; 3+ messages in thread
From: Viresh Kumar @ 2025-06-23 4:22 UTC (permalink / raw)
To: Abhinav Ananthu
Cc: vireshk, nm, sboyd, ojeda, alex.gaynor, boqun.feng, gary,
bjorn3_gh, lossin, a.hindborg, aliceryhl, tmgross, dakr, linux-pm,
rust-for-linux, linux-kernel
On 20-06-25, 15:29, Abhinav Ananthu wrote:
> 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.
>
> Signed-off-by: Abhinav Ananthu <abhinav.ogl@gmail.com>
> Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> rust/kernel/opp.rs | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
Applied. Thanks.
--
viresh
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-23 4:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-20 9:59 [PATCH] rust: opp: use c_* types via kernel prelude Abhinav Ananthu
2025-06-20 10:14 ` Miguel Ojeda
2025-06-23 4:22 ` Viresh Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox