Thread (65 messages) 65 messages, 5 authors, 2023-10-24

Re: [PATCH net-next v5 1/5] rust: core abstractions for network PHY drivers

From: Benno Lossin <hidden>
Date: 2023-10-21 07:21:29
Also in: rust-for-linux

On 19.10.23 23:51, FUJITA Tomonori wrote:
On Thu, 19 Oct 2023 16:37:46 +0000
Benno Lossin [off-list ref] wrote:
quoted
On 19.10.23 17:32, FUJITA Tomonori wrote:
quoted
quoted
You can just do this (I omitted the `::kernel::` prefix for
readability, if you add this in the macro, please include it):

       // CAST: `DriverVTable` is `repr(transparent)` and wrapping `bindings::phy_driver`.
       let ptr = drv.as_mut_ptr().cast::<bindings::phy_driver>();
       let len = drv.len().try_into()?;
       // SAFETY: ...
       to_result(unsafe { bindings::phy_drivers_register(ptr, len, module.0) })?;
quoted
                   })?;
The above solves DriverVTable.0 but still the macro can't access to
kernel::ThisModule.0. I got the following error:
I think we could just provide an `as_ptr` getter function
for `ThisModule`. But need to check with the others.
ThisModule.0 is *mut bindings::module. Drivers should not use
bindings?
This is a special case, since it `module` is used on a lot of functions
(and it does not make sense to provide abstractions for those on
`ThisModule`). Additionally, `ThisModule` already has a public `from_raw`
function that takes a `*mut bindings::module`.

If you add a `as_ptr` function, please create a separate patch for it.

-- 
Cheers,
Benno
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help