Re: [PATCH] rust: serdev: use ThisModule::as_ptr() instead of field access
From: Markus Probst
Date: Thu Aug 13 2026 - 12:06:40 EST
On Thu, 2026-08-13 at 17:24 +0200, Danilo Krummrich wrote:
> The THIS_MODULE series [1] applied to rust-next moved ThisModule from
> lib.rs into a module.rs submodule, making the tuple struct field private
> outside the module. This breaks the module.0 field access in serdev in
> driver-core-next.
>
> Update the call to __serdev_device_driver_register() to use the public
> module.as_ptr() accessor to fix the build.
I encounter 2 errors when building with both driver-core-next and rust-
next
error[E0616]: field `0` of struct `module::ThisModule` is private
--> rust/kernel/serdev.rs:90:89
|
90 | to_result(unsafe {
bindings::__serdev_device_driver_register(sdrv.get(), module.0) })
|
^ private field
error[E0599]: no method named `__pinned_init` found for associated type
`impl pin_init::PinInit<<T as serdev::Driver>::Data<'_>, error::Error>
+ '_` in the current scope
--> rust/kernel/serdev.rs:200:40
|
200 | let result = unsafe {
data.__pinned_init(driver.as_mut_ptr()) };
| ^^^^^^^^^^^^^ method not
found in `impl pin_init::PinInit<<T as serdev::Driver>::Data<'_>,
error::Error> + '_`
error: aborting due to 2 previous errors
>
> Link: https://lore.kernel.org/all/20260811-fix-fops-owner-v10-0-7e71776f9dbe@xxxxxxxxx/ [1]
> Closes: https://lore.kernel.org/all/DKNAS52KYWLD.M15VEC6U0F6R@xxxxxxxxxx/
> Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>
> ---
> rust/kernel/serdev.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/rust/kernel/serdev.rs b/rust/kernel/serdev.rs
> index c0cd24481ee3..eecb1117095c 100644
> --- a/rust/kernel/serdev.rs
> +++ b/rust/kernel/serdev.rs
> @@ -87,7 +87,7 @@ unsafe fn register(
> }
>
> // SAFETY: `sdrv` is guaranteed to be a valid `DriverType`.
> - to_result(unsafe { bindings::__serdev_device_driver_register(sdrv.get(), module.0) })
> + to_result(unsafe { bindings::__serdev_device_driver_register(sdrv.get(), module.as_ptr()) })
> }
>
> unsafe fn unregister(sdrv: &Opaque<Self::DriverType>) {
>
> base-commit: 8364d0e36cbbdfe9adb65a170a70cbe3cdb02ff9
The first error disappears with this patch.
Reviewed-by: Markus Probst <markus.probst@xxxxxxxxx>
Should I send a patch regarding the 2. error?
It seems the `PinInit::__pinned_init` function is not only deprecated,
but also behind the `#[cfg(not(kernel))]` flag, which causes the error.
Thanks
- Markus Probst
Attachment:
signature.asc
Description: This is a digitally signed message part