[net-next RFC PATCH 0/3] net: phy: detach PHY driver OPs from phy_driver struct
Trevor Gross
tmgross at umich.edu
Sat Feb 17 14:37:39 PST 2024
On Sat, Feb 17, 2024 at 2:41 PM Christian Marangi <ansuelsmth at gmail.com> wrote:
>
> I took care to compile-test all the PHY, only exception is the unique
> RUST driver, where I still have to learn that funny language and
> I didn't had time to update it, so that is the only driver that
> I think require some fixup.
This will only need an update in the abstraction at
rust/kernel/net/phy.rs, roughly (untested)
@@ -5,15 +5,22 @@ pub const fn create_phy_driver<T: Driver>() -> DriverV
flags: T::FLAGS,
phy_id: T::PHY_DEVICE_ID.id,
phy_id_mask: T::PHY_DEVICE_ID.mask_as_int(),
- soft_reset: if T::HAS_SOFT_RESET {
- Some(Adapter::<T>::soft_reset_callback)
- } else {
- None
+ phy_driver_ops: &bindings::phy_driver_ops {
+ soft_reset: if T::HAS_SOFT_RESET {
+ Some(Adapter::<T>::soft_reset_callback)
+ } else {
+ None
+ },
+ get_features: if T::HAS_GET_FEATURES {
+ Some(Adapter::<T>::get_features_callback)
+ } else {
+ None
+ },
+ // ... Other fields now in phy_driver_ops
+
+ // SAFETY: The rest is zeroed out to finalize `struct
phy_driver_ops`,
+ // which expects null function pointers for unused fields
+ ..unsafe {
core::mem::MaybeUninit::<bindings::phy_driver_ops>::zeroed().assume_init()
}
},
- get_features: if T::HAS_GET_FEATURES {
- Some(Adapter::<T>::get_features_callback)
- } else {
- None
- },
}))
}
We can send a patch if needed once this series moves out of RFC.
- Trevor
More information about the Linux-mediatek
mailing list