From nobody Sun Feb 8 18:24:44 2026 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F7E22773D3; Wed, 21 Jan 2026 21:13:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769029991; cv=none; b=NQHKQiduIydUwML5FuI2EDtvczOPH+tOjBlYeAWriORisLJo8wZmLfvV6kcDoGXvp5F7P982phRX+elcuSVI5aUL+ac8nTzZdPJoXTjDpsGbf4r2VVtNdQgqCVhu98W/ylI1p0Six8kmCindjqrTtoyx+/1kIjVPEEWQl+BjxcY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769029991; c=relaxed/simple; bh=rTBdgbSR21dbK7W1PBFG2/WELIE+BRCOHhtTd/t/ma4=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=q6GcFmmHE/smoe/8db1G97hmY0aQixag+c6rSUwI9l6ubiljjE2fx9DnFQt8bsPujYqbqJW7yF0Vz5/YJ4EGYWRQTntd0pc1BwgPMuBmr1IbBapdr7DQ0z3wPq1oygvT0TA8ogWVytRLDK7IrKMOhi4MXhJDtq5kEd59neXbmNo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.99) (envelope-from ) id 1vifVb-000000004n1-1z2f; Wed, 21 Jan 2026 21:12:59 +0000 Date: Wed, 21 Jan 2026 21:12:56 +0000 From: Daniel Golle To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonas Jelonek , Markus Stockhausen Subject: [PATCH RFC net-next] net: phy: add (*register_phy)() hook to struct mii_bus Message-ID: <34ac2837b01f53ace02c613a57a03a74d9a056b0.1769029647.git.daniel@makrotopia.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Some MDIO busses require to program PHY polling registers depending on the PHY type. RealTek switch SoCs are the most prominent example of a DSA switch which doesn't allow to program MAC speed, duplex and flow-control settings without using PHY polling to do so. Hence there is a need to inform the MDIO bus driver that a PHY has been registered on the bus, as otherwise the bus driver will have to reinvent and duplicate all the bus scanning logic for Clause-22 and Clause-45 PHYs. Provide a simple hook in struct mii_bus which is called right after a PHY has been registered on the bus. Alternative ways which would allow to do the same things without having to change any kernel code would of course be very welcome. Link: https://github.com/openwrt/openwrt/pull/21515#discussion_r2714069716 Signed-off-by: Daniel Golle --- drivers/net/phy/phy_device.c | 8 ++++++++ include/linux/phy.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index f624218bf3664..97c7b69f7031b 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1130,8 +1130,16 @@ int phy_device_register(struct phy_device *phydev) goto out; } =20 + if (phydev->mdio.bus->register_phy) { + err =3D phydev->mdio.bus->register_phy(phydev); + if (err) + goto register_hook_err; + } + return 0; =20 + register_hook_err: + device_del(&phydev->mdio.dev); out: /* Assert the reset signal */ phy_device_reset(phydev, 1); diff --git a/include/linux/phy.h b/include/linux/phy.h index 5972f19af16da..1d38e27d20389 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -377,6 +377,9 @@ struct mii_bus { /** @reset: Perform a reset of the bus */ int (*reset)(struct mii_bus *bus); =20 + /** @register_phy: Called for each PHY detected on the bus */ + int (*register_phy)(struct phy_device *phydev); + /** @stats: Statistic counters per device on the bus */ struct mdio_bus_stats stats[PHY_MAX_ADDR]; =20 --=20 2.52.0