Re: [PATCH] rust: serdev: use ThisModule::as_ptr() instead of field access
"Gary Guo" <[email protected]>
| Newsgroups | org.kernel.vger.rust-for-linux,dev.linux.lists.driver-core,org.kernel.vger.linux-kernel,org.kernel.vger.linux-serial |
|---|---|
| Message-ID | <[email protected]> |
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/[email protected]/
Best,
Gary