* Re: [PATCH] rust: serdev: use ThisModule::as_ptr() instead of field access
2026-08-13 15:24 [PATCH] rust: serdev: use ThisModule::as_ptr() instead of field access Danilo Krummrich
@ 2026-08-13 15:53 ` Markus Probst
2026-08-13 16:08 ` Gary Guo
2026-08-13 16:10 ` Danilo Krummrich
2026-08-13 16:08 ` Gary Guo
2026-08-13 23:20 ` Danilo Krummrich
2 siblings, 2 replies; 6+ messages in thread
From: Markus Probst @ 2026-08-13 15:53 UTC (permalink / raw)
To: Danilo Krummrich, gregkh, rafael, ojeda, boqun, gary, bjorn3_gh,
lossin, a.hindborg, aliceryhl, tmgross, daniel.almeida, tamird,
acourbot, work
Cc: driver-core, linux-serial, rust-for-linux, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2611 bytes --]
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@linux.dev/ [1]
> Closes: https://lore.kernel.org/all/DKNAS52KYWLD.M15VEC6U0F6R@kernel.org/
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
> ---
> 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@posteo.de>
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 #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 870 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] rust: serdev: use ThisModule::as_ptr() instead of field access
2026-08-13 15:53 ` Markus Probst
@ 2026-08-13 16:08 ` Gary Guo
2026-08-13 16:10 ` Danilo Krummrich
1 sibling, 0 replies; 6+ messages in thread
From: Gary Guo @ 2026-08-13 16:08 UTC (permalink / raw)
To: Markus Probst, Danilo Krummrich, gregkh, rafael, ojeda, boqun,
gary, bjorn3_gh, lossin, a.hindborg, aliceryhl, tmgross,
daniel.almeida, tamird, acourbot, work
Cc: driver-core, linux-serial, rust-for-linux, linux-kernel
On Thu Aug 13, 2026 at 4:53 PM BST, Markus Probst wrote:
> 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
>
> [snip]
>
> 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
This is a semantic conflict that cannot be solved on a single tree and has to be
done on the merge commit.
A resolution is already on linux-next, see
https://lore.kernel.org/rust-for-linux/20260807074729.108159-1-ojeda@kernel.org/
Best,
Gary
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] rust: serdev: use ThisModule::as_ptr() instead of field access
2026-08-13 15:53 ` Markus Probst
2026-08-13 16:08 ` Gary Guo
@ 2026-08-13 16:10 ` Danilo Krummrich
1 sibling, 0 replies; 6+ messages in thread
From: Danilo Krummrich @ 2026-08-13 16:10 UTC (permalink / raw)
To: Markus Probst
Cc: gregkh, rafael, ojeda, boqun, gary, bjorn3_gh, lossin, a.hindborg,
aliceryhl, tmgross, daniel.almeida, tamird, acourbot, work,
driver-core, linux-serial, rust-for-linux, linux-kernel
On Thu Aug 13, 2026 at 5:53 PM CEST, Markus Probst wrote:
> Should I send a patch regarding the 2. error?
The second one can't be fixed with a patch in either of the trees, as it is a
real merge conflict.
This one is only fixable in the driver-core tree, since as_ptr() is a
preexisting method.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rust: serdev: use ThisModule::as_ptr() instead of field access
2026-08-13 15:24 [PATCH] rust: serdev: use ThisModule::as_ptr() instead of field access Danilo Krummrich
2026-08-13 15:53 ` Markus Probst
@ 2026-08-13 16:08 ` Gary Guo
2026-08-13 23:20 ` Danilo Krummrich
2 siblings, 0 replies; 6+ messages in thread
From: Gary Guo @ 2026-08-13 16:08 UTC (permalink / raw)
To: Danilo Krummrich, markus.probst, gregkh, rafael, ojeda, boqun,
gary, bjorn3_gh, lossin, a.hindborg, aliceryhl, tmgross,
daniel.almeida, tamird, acourbot, work
Cc: driver-core, linux-serial, rust-for-linux, linux-kernel
On Thu Aug 13, 2026 at 4:24 PM BST, 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.
>
> Link: https://lore.kernel.org/all/20260811-fix-fops-owner-v10-0-7e71776f9dbe@linux.dev/ [1]
> Closes: https://lore.kernel.org/all/DKNAS52KYWLD.M15VEC6U0F6R@kernel.org/
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
> ---
> rust/kernel/serdev.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rust: serdev: use ThisModule::as_ptr() instead of field access
2026-08-13 15:24 [PATCH] rust: serdev: use ThisModule::as_ptr() instead of field access Danilo Krummrich
2026-08-13 15:53 ` Markus Probst
2026-08-13 16:08 ` Gary Guo
@ 2026-08-13 23:20 ` Danilo Krummrich
2 siblings, 0 replies; 6+ messages in thread
From: Danilo Krummrich @ 2026-08-13 23:20 UTC (permalink / raw)
To: Danilo Krummrich
Cc: markus.probst, gregkh, rafael, ojeda, boqun, gary, bjorn3_gh,
lossin, a.hindborg, aliceryhl, tmgross, daniel.almeida, tamird,
acourbot, work, driver-core, linux-serial, rust-for-linux,
linux-kernel
On Thu, 13 Aug 2026 17:24:41 +0200, Danilo Krummrich wrote:
> [PATCH] rust: serdev: use ThisModule::as_ptr() instead of field access
Applied, thanks!
Branch: driver-core-next
Tree: git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git
[1/1] rust: serdev: use ThisModule::as_ptr() instead of field access
commit: ddca0cd80096
The patch will appear in the next linux-next integration (typically within 24
hours on weekdays).
The patch is queued up for the upcoming merge window for the next major kernel
release.
^ permalink raw reply [flat|nested] 6+ messages in thread