[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231214154906.29436-3-ansuelsmth@gmail.com>
Date: Thu, 14 Dec 2023 16:49:05 +0100
From: Christian Marangi <ansuelsmth@...il.com>
To: Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Christian Marangi <ansuelsmth@...il.com>
Subject: [net-next PATCH v2 2/3] net: phy: add simple helper to return count of supported speeds
Add simple helper to return count of supported speeds for the passed PHY
device.
This can be useful to know the number of speed modes to dynamically
allocate a speed array for it.
Signed-off-by: Christian Marangi <ansuelsmth@...il.com>
---
drivers/net/phy/phy.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index a5fa077650e8..311560e72126 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -229,6 +229,18 @@ phy_find_valid(int speed, int duplex, unsigned long *supported)
return phy_lookup_setting(speed, duplex, supported, false);
}
+/**
+ * phy_supported_speeds_num - return the number of all speeds currently
+ * supported by a phy device
+ * @phy: The phy device to return supported speeds of.
+ *
+ * Description: Returns the number of supported speeds.
+ */
+unsigned int phy_supported_speeds_num(struct phy_device *phy)
+{
+ return phy_speeds(NULL, 0, phy->supported);
+}
+
/**
* phy_supported_speeds - return all speeds currently supported by a phy device
* @phy: The phy device to return supported speeds of.
--
2.40.1
Powered by blists - more mailing lists