Re: [PATCH net-next v4 1/2] rust: net: phy: take &self in methods that do not need phy_device->lock
From: FUJITA Tomonori
Date: Mon Nov 30 2026 - 04:47:03 EST
On Thu, 26 Nov 2026 23:08:32 +0900
SeungJong Ha <engineer.jjhama@xxxxxxxxx> wrote:
> -/// - Referencing a `phy_device` using this struct asserts that you are in
> -/// a context where all methods defined on this struct are safe to call.
> -/// - This struct always has a valid `self.0.mdio.dev`.
> +/// - `self.0` is a valid `phy_device`, and `self.0.mdio.dev` is a valid `struct device`.
> +/// - For the lifetime of a `&mut Device`, no other thread accesses the state of the `phy_device`
> +/// that `phy_device->lock` protects.
read_paged() relies on phydev->drv being set, but this is not in the
invariant. Can you add "self.0.drv points to a valid phy_driver" here
for &mut Device, and the same to the safety requirements of
from_raw_mut()? The callers can say that PHYLIB calls them through
phydev->drv, and the SAFETY comment in read_paged() can refer to the
invariant.