summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNishanth Menon <nm@ti.com>2023-04-14 17:06:45 -0500
committerTom Rini <trini@konsulko.com>2023-05-05 17:48:44 -0400
commit09005c2fb288decb4010f062fdc87d0b82e57584 (patch)
tree373d329312ff9f0ae57c04fbe594818c74297a5d /include
parentf1a63f7181784e6de92a9759e7d61e5ce9c00582 (diff)
downloadu-boot-09005c2fb288decb4010f062fdc87d0b82e57584.tar.gz
net: phy: Make phy_interface_is_rgmii a switch statement
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 wasn't 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 use the enums directly, drivers such as dp83867, dp83869, marvell, micrel_ksz90x1 etc use this api. Reported-by: Tom Rini <trini@konsulko.com> Reviewed-by: Marek Vasut <marek.vasut+renesas@mailbox.org> Reviewed-by: Marek BehĂșn <kabel@kernel.org> Signed-off-by: Nishanth Menon <nm@ti.com> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/phy.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/include/phy.h b/include/phy.h
index cb87d1d4fc..247223d92b 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;
+ }
}
bool phy_interface_is_ncsi(void);