rust: finish using custom FFI integer types
authorMiguel Ojeda <ojeda@kernel.org>
Sun, 15 Dec 2024 21:43:53 +0000 (22:43 +0100)
committerMiguel Ojeda <ojeda@kernel.org>
Mon, 16 Dec 2024 20:48:45 +0000 (21:48 +0100)
In the last kernel cycle we migrated most of the `core::ffi` cases in
commit d072acda4862 ("rust: use custom FFI integer types"):

    Currently FFI integer types are defined in libcore. This commit
    creates the `ffi` crate and asks bindgen to use that crate for FFI
    integer types instead of `core::ffi`.

    This commit is preparatory and no type changes are made in this
    commit yet.

Finish now the few remaining/new cases so that we perform the actual
remapping in the next commit as planned.

Acked-by: Jocelyn Falempe <jfalempe@redhat.com> # drm
Link: https://lore.kernel.org/rust-for-linux/CANiq72m_rg42SvZK=bF2f0yEoBLVA33UBhiAsv8THhVu=G2dPA@mail.gmail.com/
Link: https://lore.kernel.org/all/cc9253fa-9d5f-460b-9841-94948fb6580c@redhat.com/
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
drivers/gpu/drm/drm_panic_qr.rs
rust/kernel/device.rs
rust/kernel/miscdevice.rs
rust/kernel/security.rs
rust/kernel/seq_file.rs
samples/rust/rust_print_main.rs

index ef2d490965ba20ffe20dda1cc064df6956fa9d05..bcf248f69252c2d8c0ec2aeb6e4826f2a97247b7 100644 (file)
@@ -931,7 +931,7 @@ impl QrImage<'_> {
 /// They must remain valid for the duration of the function call.
 #[no_mangle]
 pub unsafe extern "C" fn drm_panic_qr_generate(
-    url: *const i8,
+    url: *const kernel::ffi::c_char,
     data: *mut u8,
     data_len: usize,
     data_size: usize,
index c926e0c2b8528c289ebd0f9849c04e1b6eec30a4..d5e6a19ff6b7ba3b5be2ce512525c4573f94fb88 100644 (file)
@@ -173,10 +173,10 @@ impl Device {
         #[cfg(CONFIG_PRINTK)]
         unsafe {
             bindings::_dev_printk(
-                klevel as *const _ as *const core::ffi::c_char,
+                klevel as *const _ as *const crate::ffi::c_char,
                 self.as_raw(),
                 c_str!("%pA").as_char_ptr(),
-                &msg as *const _ as *const core::ffi::c_void,
+                &msg as *const _ as *const crate::ffi::c_void,
             )
         };
     }
index 7e2a79b3ae263659b7e0781c05cb130d10c8accb..fbd7613803847b57848e1fc090c9ccfcb990e963 100644 (file)
 use crate::{
     bindings,
     error::{to_result, Error, Result, VTABLE_DEFAULT_ERROR},
+    ffi::{c_int, c_long, c_uint, c_ulong},
     prelude::*,
     str::CStr,
     types::{ForeignOwnable, Opaque},
 };
-use core::{
-    ffi::{c_int, c_long, c_uint, c_ulong},
-    marker::PhantomData,
-    mem::MaybeUninit,
-    pin::Pin,
-};
+use core::{marker::PhantomData, mem::MaybeUninit, pin::Pin};
 
 /// Options for creating a misc device.
 #[derive(Copy, Clone)]
index 2522868862a1bf7791f85ba17180c21d83671f0c..ea4c58c8170336be84ceb8776289ab29b2c50afa 100644 (file)
@@ -19,7 +19,7 @@ use crate::{
 /// successful call to `security_secid_to_secctx`, that has not yet been destroyed by calling
 /// `security_release_secctx`.
 pub struct SecurityCtx {
-    secdata: *mut core::ffi::c_char,
+    secdata: *mut crate::ffi::c_char,
     seclen: usize,
 }
 
index 6ca29d576d029d5c7829ca7250762b83ee02935a..04947c6729792ba644cd53ed1e6d5ac4ed870d03 100644 (file)
@@ -36,7 +36,7 @@ impl SeqFile {
             bindings::seq_printf(
                 self.inner.get(),
                 c_str!("%pA").as_char_ptr(),
-                &args as *const _ as *const core::ffi::c_void,
+                &args as *const _ as *const crate::ffi::c_void,
             );
         }
     }
index aed90a6feecfa7e02c72cdb6ef6e194236b96643..7935b4772ec6cee7f5826460012652a158f07838 100644 (file)
@@ -83,7 +83,7 @@ impl Drop for RustPrint {
 }
 
 mod trace {
-    use core::ffi::c_int;
+    use kernel::ffi::c_int;
 
     kernel::declare_trace! {
         /// # Safety