[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231117093908.2515105-1-aliceryhl@google.com>
Date: Fri, 17 Nov 2023 09:39:08 +0000
From: Alice Ryhl <aliceryhl@...gle.com>
To: fujita.tomonori@...il.com
Cc: 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, Alice Ryhl <aliceryhl@...gle.com>
Subject: Re: [PATCH net-next v7 2/5] rust: net::phy add module_phy_driver macro
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)*) => {
> + ::kernel::bindings::mdio_device_id {
Here, I recommend `$crate` instead of `::kernel`.
> +/// #[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".
Alice
Powered by blists - more mailing lists