linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] rust: pci: Use explicit types in FFI callbacks
@ 2025-07-29 10:29 herculoxz
  2025-07-29 10:52 ` Miguel Ojeda
  2025-07-29 16:35 ` Benno Lossin
  0 siblings, 2 replies; 5+ messages in thread
From: herculoxz @ 2025-07-29 10:29 UTC (permalink / raw)
  To: linux-pci
  Cc: rust-for-linux, linux-kernel, dakr, bhelgaas, kwilczynski, ojeda,
	alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin, a.hindborg,
	aliceryhl, tmgross, Abhinav Ananthu

From: Abhinav Ananthu <abhinav.ogl@gmail.com>

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.

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] rust: pci: Use explicit types in FFI callbacks
  2025-07-29 10:29 [PATCH v2] rust: pci: Use explicit types in FFI callbacks herculoxz
@ 2025-07-29 10:52 ` Miguel Ojeda
  2025-07-29 14:45   ` Danilo Krummrich
  2025-07-29 16:35 ` Benno Lossin
  1 sibling, 1 reply; 5+ messages in thread
From: Miguel Ojeda @ 2025-07-29 10:52 UTC (permalink / raw)
  To: herculoxz
  Cc: linux-pci, rust-for-linux, linux-kernel, dakr, bhelgaas,
	kwilczynski, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross

On Tue, Jul 29, 2025 at 12:30 PM herculoxz <abhinav.ogl@gmail.com> wrote:
>
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] rust: pci: Use explicit types in FFI callbacks
  2025-07-29 10:52 ` Miguel Ojeda
@ 2025-07-29 14:45   ` Danilo Krummrich
  2025-07-30  7:56     ` Alice Ryhl
  0 siblings, 1 reply; 5+ messages in thread
From: Danilo Krummrich @ 2025-07-29 14:45 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: herculoxz, linux-pci, rust-for-linux, linux-kernel, bhelgaas,
	kwilczynski, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross

On Tue Jul 29, 2025 at 12:52 PM CEST, Miguel Ojeda wrote:
> On Tue, Jul 29, 2025 at 12:30 PM herculoxz <abhinav.ogl@gmail.com> wrote:
>>
>> 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.

> (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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] rust: pci: Use explicit types in FFI callbacks
  2025-07-29 10:29 [PATCH v2] rust: pci: Use explicit types in FFI callbacks herculoxz
  2025-07-29 10:52 ` Miguel Ojeda
@ 2025-07-29 16:35 ` Benno Lossin
  1 sibling, 0 replies; 5+ messages in thread
From: Benno Lossin @ 2025-07-29 16:35 UTC (permalink / raw)
  To: herculoxz, linux-pci
  Cc: rust-for-linux, linux-kernel, dakr, bhelgaas, kwilczynski, ojeda,
	alex.gaynor, boqun.feng, gary, bjorn3_gh, a.hindborg, aliceryhl,
	tmgross

On Tue Jul 29, 2025 at 12:29 PM CEST, herculoxz wrote:
> From: Abhinav Ananthu <abhinav.ogl@gmail.com>
>
> 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.
>
> Signed-off-by: Abhinav Ananthu <abhinav.ogl@gmail.com>

Reviewed-by: Benno Lossin <lossin@kernel.org>

---
Cheers,
Benno

> ---
>  rust/kernel/pci.rs | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] rust: pci: Use explicit types in FFI callbacks
  2025-07-29 14:45   ` Danilo Krummrich
@ 2025-07-30  7:56     ` Alice Ryhl
  0 siblings, 0 replies; 5+ messages in thread
From: Alice Ryhl @ 2025-07-30  7:56 UTC (permalink / raw)
  To: Danilo Krummrich
  Cc: Miguel Ojeda, herculoxz, linux-pci, rust-for-linux, linux-kernel,
	bhelgaas, kwilczynski, ojeda, alex.gaynor, boqun.feng, gary,
	bjorn3_gh, lossin, a.hindborg, tmgross

On Tue, Jul 29, 2025 at 04:45:50PM +0200, Danilo Krummrich wrote:
> On Tue Jul 29, 2025 at 12:52 PM CEST, Miguel Ojeda wrote:
> > On Tue, Jul 29, 2025 at 12:30 PM herculoxz <abhinav.ogl@gmail.com> wrote:
> >>
> >> 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.
> 
> > (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.

With the above changes:

Reviewed-by: Alice Ryhl <aliceryhl@google.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-07-30  7:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-29 10:29 [PATCH v2] rust: pci: Use explicit types in FFI callbacks herculoxz
2025-07-29 10:52 ` Miguel Ojeda
2025-07-29 14:45   ` Danilo Krummrich
2025-07-30  7:56     ` Alice Ryhl
2025-07-29 16:35 ` Benno Lossin

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).