rust: pci: Use explicit types in FFI callbacks
PATCH v2 1/1 rust: pci: Use explicit types in FFI callbacks
From: Abhinav Ananthu <[email protected]>
Update PCI FFI callback signatures to use c_int from the prelude, instead of accessing it via kernel::ffi::c_int.
This follows Rust-for-Linux coding guidelines and improves ABI correctness when interfacing with C code.
--- rust/kernel/pci.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
rust/kernel/pci.rs +2 -2
@@ -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 (), ioptras *mut kernel::ffi::c_void ); + bindings::pci_iounmap (pdev.as_raw (), ioptras *mut c_void ); bindings::pci_release_region (pdev.as_raw (), num); } }
Signature · 1 line
2.34.1
Quoted 3 lines · herculoxz
and improves ABI
correctness when interfacing with C code.
I think this still sounds like it is fixing an ABI issue -- I would probably just remove that second sentence.
(But no need for a v3 -- I think it can be fixed on apply unless Danilo wants it).
Thanks!
Cheers,
Miguel
Danilo Krummrich
maintainerQuoted 7 lines · Miguel Ojeda
Quoted 3 lines · herculoxz
and improves ABI
correctness when interfacing with C code.I think this still sounds like it is fixing an ABI issue -- I would probably just remove that second sentence.
I agree, the types exported via prelude are the ones from kernel::ffi.
Quoted 2 lines
(But no need for a v3 -- I think it can be fixed on apply unless Danilo wants it).
Yeah, I can fix it up when applying the patch.
I also think the subject from v1, i.e. "use c_* types via kernel prelude", was better. This one is a bit misleading, the types in the FFI callbacks are already explicit.
Unless I hear otherwise, I will also revert the subject to the one of v1 when I apply the patch.
Thanks,
Danilo
Quoted 14 lines · Danilo Krummrich
Quoted 7 lines · Miguel Ojeda
Quoted 3 lines · herculoxz
and improves ABI
correctness when interfacing with C code.I think this still sounds like it is fixing an ABI issue -- I would probably just remove that second sentence.
I agree, the types exported via prelude are the ones from
kernel::ffi.Quoted 2 lines
(But no need for a v3 -- I think it can be fixed on apply unless Danilo wants it).
Quoted 8 lines
Yeah, I can fix it up when applying the patch.
I also think the subject from v1, i.e. "use c_* types via kernel prelude", was better. This one is a bit misleading, the types in the FFI callbacks are already explicit.
Unless I hear otherwise, I will also revert the subject to the one of v1 when I apply the patch.
With the above changes:
Quoted 9 lines · herculoxz
From: Abhinav Ananthu <[email protected]>
Update PCI FFI callback signatures to use
c_intfrom the prelude, instead of accessing it viakernel::ffi::c_int.This follows Rust-for-Linux coding guidelines and improves ABI correctness when interfacing with C code.
Signed-off-by Abhinav Ananthu <[email protected]>
---
Cheers,
Benno
Quoted 3 lines
--- rust/kernel/pci.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)