
On Thu, 13 Apr 2023 23:24:33 -0500 Nishanth Menon nm@ti.com wrote:
Recent commit 75d28899e3e9 ("net: phy: Synchronize PHY interface modes with Linux") reordered the enum definitions. This exposed a problem in range checking functions to identify the interface type. Though this specific api was'nt impacted (all the RGMII definitions remained within range), this experience should be used to never to have to face this kind of challenge again.
While it is possible for the phy drivers to practically use the enum's directly, drivers such as dp83867, dp83869, marvell, micrel_ksz90x1 etc use the same.
Reported-by: Tom Rini trini@konsulko.com Signed-off-by: Nishanth Menon nm@ti.com
Changes since V1:
- Switch update based on feedback from Marek
V1: https://lore.kernel.org/r/20230413180713.2922524-3-nm@ti.com include/phy.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/include/phy.h b/include/phy.h index 51dadcf14478..600966bc8b20 100644 --- a/include/phy.h +++ b/include/phy.h @@ -361,8 +361,15 @@ int get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id); */ static inline bool phy_interface_is_rgmii(struct phy_device *phydev) {
- return phydev->interface >= PHY_INTERFACE_MODE_RGMII &&
phydev->interface <= PHY_INTERFACE_MODE_RGMII_TXID;
- switch (phydev->interface) {
- case PHY_INTERFACE_MODE_RGMII:
- case PHY_INTERFACE_MODE_RGMII_ID:
- case PHY_INTERFACE_MODE_RGMII_RXID:
- case PHY_INTERFACE_MODE_RGMII_TXID:
return 1;
- default:
return 0;
- }
}
/**
Reviewed-by: Marek Behún kabel@kernel.org