[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z_jwXsQae9DjLWha@pollux>
Date: Fri, 11 Apr 2025 12:35:10 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: Christian Schrefl <chrisi.schrefl@...il.com>
Cc: Luis Chamberlain <mcgrof@...nel.org>,
Russ Weight <russ.weight@...ux.dev>,
Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org,
stable@...r.kernel.org
Subject: Re: [PATCH] rust: fix building firmware abstraction on 32bit arm
On Fri, Apr 11, 2025 at 09:14:48AM +0200, Christian Schrefl wrote:
> When trying to build the rust firmware abstractions on 32 bit arm the
> following build error occures:
>
> ```
> error[E0308]: mismatched types
> --> rust/kernel/firmware.rs:20:14
> |
> 20 | Self(bindings::request_firmware)
> | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found fn item
> | |
> | arguments to this function are incorrect
> |
> = note: expected fn pointer `unsafe extern "C" fn(_, *const i8, _) -> _`
> found fn item `unsafe extern "C" fn(_, *const u8, _) -> _ {request_firmware}`
This looks like you have local changes in your tree, running in this error. I
get the exact same errors when I apply the following diff:
diff --git a/rust/kernel/firmware.rs b/rust/kernel/firmware.rs
index f04b058b09b2..a67047e3aa6b 100644
--- a/rust/kernel/firmware.rs
+++ b/rust/kernel/firmware.rs
@@ -12,7 +12,7 @@
/// One of the following: `bindings::request_firmware`, `bindings::firmware_request_nowarn`,
/// `bindings::firmware_request_platform`, `bindings::request_firmware_direct`.
struct FwFunc(
- unsafe extern "C" fn(*mut *const bindings::firmware, *const u8, *mut bindings::device) -> i32,
+ unsafe extern "C" fn(*mut *const bindings::firmware, *const i8, *mut bindings::device) -> i32,
);
> note: tuple struct defined here
> --> rust/kernel/firmware.rs:14:8
> |
> 14 | struct FwFunc(
> | ^^^^^^
>
> error[E0308]: mismatched types
> --> rust/kernel/firmware.rs:24:14
> |
> 24 | Self(bindings::firmware_request_nowarn)
> | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found fn item
> | |
> | arguments to this function are incorrect
> |
> = note: expected fn pointer `unsafe extern "C" fn(_, *const i8, _) -> _`
> found fn item `unsafe extern "C" fn(_, *const u8, _) -> _ {firmware_request_nowarn}`
> note: tuple struct defined here
> --> rust/kernel/firmware.rs:14:8
> |
> 14 | struct FwFunc(
> | ^^^^^^
>
> error[E0308]: mismatched types
> --> rust/kernel/firmware.rs:64:45
> |
> 64 | let ret = unsafe { func.0(pfw as _, name.as_char_ptr(), dev.as_raw()) };
> | ------ ^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
> | |
> | arguments to this function are incorrect
> |
> = note: expected raw pointer `*const i8`
> found raw pointer `*const u8`
>
> error: aborting due to 3 previous errors
> ```
I did a test build with multi_v7_defconfig and I can't reproduce this issue.
I think the kernel does always use -funsigned-char, as also documented in commit
1bae8729e50a ("rust: map `long` to `isize` and `char` to `u8`")?
>
> To fix this error the char pointer type in `FwFunc` is converted to
> `ffi::c_char`.
>
> Fixes: de6582833db0 ("rust: add firmware abstractions")
> Cc: stable@...r.kernel.org # Backport only to 6.15 needed
>
> Signed-off-by: Christian Schrefl <chrisi.schrefl@...il.com>
> ---
> rust/kernel/firmware.rs | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/rust/kernel/firmware.rs b/rust/kernel/firmware.rs
> index f04b058b09b2d2397e26344d0e055b3aa5061432..1d6284316f2a4652ef3f76272670e5e29b0ff924 100644
> --- a/rust/kernel/firmware.rs
> +++ b/rust/kernel/firmware.rs
> @@ -5,14 +5,18 @@
> //! C header: [`include/linux/firmware.h`](srctree/include/linux/firmware.h)
>
> use crate::{bindings, device::Device, error::Error, error::Result, str::CStr};
> -use core::ptr::NonNull;
> +use core::{ffi, ptr::NonNull};
The change itself seems to be fine anyways, but I think we should use crate::ffi
instead.
Powered by blists - more mailing lists