[PATCH] rust: pci: use c_* types via kernel prelude

herculoxz posted 1 patch 2 months, 1 week ago
rust/kernel/pci.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] rust: pci: use c_* types via kernel prelude
Posted by herculoxz 2 months, 1 week ago
From: Abhinav Ananthu <abhinav.ogl@gmail.com>

 Update PCI FFI callback signatures to use  from the ,
 instead of accessing it via . 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>
---
 rust/kernel/pci.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
index 5ce07999168e..fbeeaec4e044 100644
--- a/rust/kernel/pci.rs
+++ b/rust/kernel/pci.rs
@@ -61,7 +61,7 @@ impl<T: Driver + 'static> Adapter<T> {
     extern "C" fn probe_callback(
         pdev: *mut bindings::pci_dev,
         id: *const bindings::pci_device_id,
-    ) -> kernel::ffi::c_int {
+    ) -> c_int {
         // SAFETY: The PCI bus only ever calls the probe callback with a valid pointer to a
         // `struct pci_dev`.
         //
@@ -333,7 +333,7 @@ unsafe fn do_release(pdev: &Device, ioptr: usize, num: i32) {
         // `ioptr` is valid by the safety requirements.
         // `num` is valid by the safety requirements.
         unsafe {
-            bindings::pci_iounmap(pdev.as_raw(), ioptr as *mut kernel::ffi::c_void);
+            bindings::pci_iounmap(pdev.as_raw(), ioptr as *mut c_void);
             bindings::pci_release_region(pdev.as_raw(), num);
         }
     }
-- 
2.34.1
Re: [PATCH] rust: pci: use c_* types via kernel prelude
Posted by Danilo Krummrich 2 months, 1 week ago
Hi Abhinav,

On Tue Jul 29, 2025 at 2:29 AM CEST, herculoxz wrote:
> From: Abhinav Ananthu <abhinav.ogl@gmail.com>
>
>  Update PCI FFI callback signatures to use  from the ,
>  instead of accessing it via . This aligns with the Rust-for-Linux coding
>  guidelines and ensures ABI correctness when interfacing with C code.

Something seems to be odd with the commit message, it seems some parts are
missing.

Can you please fix this and send a v2? It's enough to send it after -rc1 is out.

Thanks,
Danilo
Re: [PATCH] rust: pci: use c_* types via kernel prelude
Posted by Miguel Ojeda 2 months, 1 week ago
On Tue, Jul 29, 2025 at 11:45 AM Danilo Krummrich <dakr@kernel.org> wrote:
>
> Something seems to be odd with the commit message, it seems some parts are
> missing.

The "ensures ABI correctness when interfacing with C code" should also
be changed -- it is true that we want to use the identifiers from the
prelude, but the ABI was fine here, since it was already using
`kernel::`.

i.e. otherwise, it would have been a fix.

Cheers,
Miguel