[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231119.195035.2131772627066676234.fujita.tomonori@gmail.com>
Date: Sun, 19 Nov 2023 19:50:35 +0900 (JST)
From: FUJITA Tomonori <fujita.tomonori@...il.com>
To: aliceryhl@...gle.com
Cc: fujita.tomonori@...il.com, andrew@...n.ch, benno.lossin@...ton.me,
miguel.ojeda.sandonis@...il.com, netdev@...r.kernel.org,
rust-for-linux@...r.kernel.org, tmgross@...ch.edu, wedsonaf@...il.com
Subject: Re: [PATCH net-next v7 2/5] rust: net::phy add module_phy_driver
macro
On Fri, 17 Nov 2023 09:39:08 +0000
Alice Ryhl <aliceryhl@...gle.com> wrote:
> FUJITA Tomonori <fujita.tomonori@...il.com> writes:
>> This macro creates an array of kernel's `struct phy_driver` and
>> registers it. This also corresponds to the kernel's
>> `MODULE_DEVICE_TABLE` macro, which embeds the information for module
>> loading into the module binary file.
>>
>> A PHY driver should use this macro.
>>
>> Signed-off-by: FUJITA Tomonori <fujita.tomonori@...il.com>
>
> Reviewed-by: Alice Ryhl <aliceryhl@...gle.com>
>
> A few minor nits:
>
>> + (drivers: [$($driver:ident),+], device_table: [$($dev:expr),+], $($f:tt)*) => {
>
> Here, you can add $(,)? to allow trailing commas when the macro is used.
> Like this:
>
> (drivers: [$($driver:ident),+ $(,)?], device_table: [$($dev:expr),+ $(,)?], $($f:tt)*) => {
Updated.
>
>> + ::kernel::bindings::mdio_device_id {
>
> Here, I recommend `$crate` instead of `::kernel`.
I copied the code that Benno wrote, IIRC. Either is fine by me. Why
`$crate` is better here?
Also better to replace other `::kernel` in this macro?
>> +/// #[no_mangle]
>> +/// static __mod_mdio__phydev_device_table: [::kernel::bindings::mdio_device_id; 2] = [
>> +/// ::kernel::bindings::mdio_device_id {
>> +/// phy_id: 0x003b1861,
>> +/// phy_id_mask: 0xffffffff,
>> +/// },
>> +/// ::kernel::bindings::mdio_device_id {
>> +/// phy_id: 0,
>> +/// phy_id_mask: 0,
>> +/// },
>> +/// ];
>
> I'd probably put a safety comment on the `#[no_mangle]` invocation to say that
> "C will not read off the end of this constant since the last element is zero".
Added.
Thanks a lot!
Powered by blists - more mailing lists