mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-29 17:22:07 +00:00
rust: net::phy always define device_table in module_phy_driver macro
device_table in module_phy_driver macro is defined only when the driver is built as a module. So a PHY driver imports phy::DeviceId module in the following way then hits `unused import` warning when it's compiled as built-in: use kernel::net::phy::DeviceId; kernel::module_phy_driver! { drivers: [PhyQT2025], device_table: [ DeviceId::new_with_driver::<PhyQT2025>(), ], Put device_table in a const. It's not included in the kernel image if unused (when the driver is compiled as built-in), and the compiler doesn't complain. Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20240930134038.1309-1-fujita.tomonori@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
5fad1c1a09
commit
3ed8d344e0
@ -848,9 +848,7 @@ const fn as_int(&self) -> u32 {
|
||||
/// }
|
||||
/// };
|
||||
///
|
||||
/// #[cfg(MODULE)]
|
||||
/// #[no_mangle]
|
||||
/// static __mod_mdio__phydev_device_table: [::kernel::bindings::mdio_device_id; 2] = [
|
||||
/// const _DEVICE_TABLE: [::kernel::bindings::mdio_device_id; 2] = [
|
||||
/// ::kernel::bindings::mdio_device_id {
|
||||
/// phy_id: 0x00000001,
|
||||
/// phy_id_mask: 0xffffffff,
|
||||
@ -860,6 +858,9 @@ const fn as_int(&self) -> u32 {
|
||||
/// phy_id_mask: 0,
|
||||
/// },
|
||||
/// ];
|
||||
/// #[cfg(MODULE)]
|
||||
/// #[no_mangle]
|
||||
/// static __mod_mdio__phydev_device_table: [::kernel::bindings::mdio_device_id; 2] = _DEVICE_TABLE;
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! module_phy_driver {
|
||||
@ -871,9 +872,7 @@ macro_rules! module_phy_driver {
|
||||
|
||||
(@device_table [$($dev:expr),+]) => {
|
||||
// SAFETY: C will not read off the end of this constant since the last element is zero.
|
||||
#[cfg(MODULE)]
|
||||
#[no_mangle]
|
||||
static __mod_mdio__phydev_device_table: [$crate::bindings::mdio_device_id;
|
||||
const _DEVICE_TABLE: [$crate::bindings::mdio_device_id;
|
||||
$crate::module_phy_driver!(@count_devices $($dev),+) + 1] = [
|
||||
$($dev.mdio_device_id()),+,
|
||||
$crate::bindings::mdio_device_id {
|
||||
@ -881,6 +880,11 @@ macro_rules! module_phy_driver {
|
||||
phy_id_mask: 0
|
||||
}
|
||||
];
|
||||
|
||||
#[cfg(MODULE)]
|
||||
#[no_mangle]
|
||||
static __mod_mdio__phydev_device_table: [$crate::bindings::mdio_device_id;
|
||||
$crate::module_phy_driver!(@count_devices $($dev),+) + 1] = _DEVICE_TABLE;
|
||||
};
|
||||
|
||||
(drivers: [$($driver:ident),+ $(,)?], device_table: [$($dev:expr),+ $(,)?], $($f:tt)*) => {
|
||||
|
Loading…
Reference in New Issue
Block a user