Re: [PATCH net-next v7 1/5] rust: core abstractions for network PHY drivers

Andrew Lunn
2023-10-27T22:36:40Z

> Hmm... but does it mean even `set_speed()` has the similar issue?
>
> let phydev: *mut phy_device = self.0.get();
> unsafe { (*phydev).speed = ...; }
>
> The `(*phydev)` creates a `&mut` IIUC. So we need the following maybe?
>
> let phydev: *mut phy_device = self.0.get();
> unsafe { *addr_mut_of!((*phydev).speed) = ...; }
>
> because at least from phylib core guarantee, we know no one accessing
> `speed` in the same time. However, yes, bit fields are tricky...

Speed is not a bitfield. Its a plain boring int. link is however a bit
field.

Andrew