Re: [PATCH] rust: serdev: use ThisModule::as_ptr() instead of field access
Markus Probst <[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, 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/[email protected]/ [1]
> Closes: https://lore.kernel.org/all/[email protected]/
> Signed-off-by: Danilo Krummrich <[email protected]>
> ---
> 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 <[email protected]>
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
signature.asc
(application/pgp-signature, 870 B)
-----BEGIN PGP SIGNATURE----- iQJPBAABCAA5FiEEgnQYxPSsWOdyMMRzNHYf+OetQ9IFAmp96G4bFIAAAAAABAAO bWFudTIsMi41KzEuMTIsMiwyAAoJEDR2H/jnrUPSksMP/3SvodzkQyosoXvZaADn boKoGg+8er8fdb/5T1cUJ/xD5/V/yKJBHmPxawTisVdXyNO3HF31tPysrI7lKr9u GYN6tGW8BmVSNeNs155ULMnf6HbZeQ7wNCZAghu5MAO5+b02L6r0u4MS0PAehc2a oObpt60cWMrUh9Q1DNjNrDYXHJ6sEcVYtvMUVSNU98qBRuwczPdoQRpLsurapFl3 kDh4PsH4Kvv284hs9OsS87DAj9r0atlJRwcOMUR72biYkuNMRuzjxc40efI5dLxi /znjB2LlQdwWOm8WplHl6csVYRKb5pBDcWrQ2xLHho16MupI98J6YQoMmISFsFqK IK08CyuaahhHYUSmIAjKxMUCk2IJYvJoeLGfNRvXR9nWomKySvs8nVpDUtvAAj0I eKqO5IgDwy8CuejeMREWi5jp4y5P7WhUFOZO0L2mGkVPUIyk8LnXKsQ3eQIySks6 meEMCPZzj3knjzfNutk5Kf2inHlpxsCFefTHehXIxWZ/PUaP+0JoX+CyB40UgqDl p5WBI64ahByqsIMaXus0vX6uQnUnz3YI8sQ+NX4NSCIhtvfXg3klv+Z4eFKE5fVi Zk6Uq6Q9LAMxWsNT30CYsb4dbv8aGE/H1v6dCQRVKa134Nlx3cSR97bLu3Bwr7hg NCZmkfPj+MjZ1KZ+8e1gI+T1 =sx6c -----END PGP SIGNATURE-----