[V2,3/3] net: phy: DP83822: check for supported interface modes in config_init

Message ID 20220522134146.120312-3-michael@amarulasolutions.com
State New
Headers show
Series
  • [V2,1/3] net: phy: DP83822: Clean up config_init code
Related show

Commit Message

Michael Trimarchi May 22, 2022, 1:41 p.m. UTC
Let config_init check for unsupported interface modes

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
---
 drivers/net/phy/dp83822.c | 5 +++++
 1 file changed, 5 insertions(+)

Patch

diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c
index 0b35f6d1a08e..beb3203aaf9f 100644
--- a/drivers/net/phy/dp83822.c
+++ b/drivers/net/phy/dp83822.c
@@ -387,6 +387,11 @@  static int dp83822_config_init(struct phy_device *phydev)
 	int err = 0;
 	int bmcr;
 
+	if (!phy_interface_is_rgmii(phydev) &&
+	    phy->interface != PHY_INTERFACE_MODE_RMII &&
+	    phy->interface != PHY_INTERFACE_MODE_MII)
+		return -ENODEV;
+
 	if (phy_interface_is_rgmii(phydev)) {
 		trx_int_delay = phy_get_internal_delay(phydev, dev, NULL, 0,
 						      true);