[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231020.065103.1042445600809743171.fujita.tomonori@gmail.com>
Date: Fri, 20 Oct 2023 06:51:03 +0900 (JST)
From: FUJITA Tomonori <fujita.tomonori@...il.com>
To: benno.lossin@...ton.me
Cc: fujita.tomonori@...il.com, netdev@...r.kernel.org,
rust-for-linux@...r.kernel.org, andrew@...n.ch,
miguel.ojeda.sandonis@...il.com, tmgross@...ch.edu, boqun.feng@...il.com,
wedsonaf@...il.com, greg@...ah.com
Subject: Re: [PATCH net-next v5 1/5] rust: core abstractions for network
PHY drivers
On Thu, 19 Oct 2023 16:37:46 +0000
Benno Lossin <benno.lossin@...ton.me> wrote:
> On 19.10.23 17:32, FUJITA Tomonori wrote:
>>> 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) })?;
>>>
>>>> })?;
>>
>> 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?
>>>>> I suppose that it would be ok to call the register function multiple
>>>>> times, since it only is on module startup/shutdown and it is not
>>>>> performance critical.
>>>>
>>>> I think that we can use the current implantation using Reservation
>>>> struct until someone requests manual creation. I doubt that we will
>>>> need to support such.
>>>
>>> I would like to remove the mutable static variable and simplify
>>> the macro.
>>
>> It's worse than having public unsafe function (phy_drivers_unregister)?
>
> Why would that function have to be public?
If we don't make ThisModule.0 public, phy_drivers_unregister has to be
public.
Powered by blists - more mailing lists