diff mbox series

[PATH,RFC,net-next,8/8] net: phy: Add build warning if assumptions get broken

Message ID 1536961136-30453-9-git-send-email-andrew@lunn.ch
State RFC, archived
Delegated to: David Miller
Headers show
Series Continue towards using linkmode in phylib | expand

Commit Message

Andrew Lunn Sept. 14, 2018, 9:38 p.m. UTC
The macro magic to build constant bitmaps of supported PHY features
breaks when we have more than 63 ETHTOOL_LINK_MODE bits. Make the
breakage loud, not a subtle bug, when we get to that condition.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/phy/phy_device.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Florian Fainelli Sept. 15, 2018, 9:31 p.m. UTC | #1
On 09/14/18 14:38, Andrew Lunn wrote:
> The macro magic to build constant bitmaps of supported PHY features
> breaks when we have more than 63 ETHTOOL_LINK_MODE bits. Make the
> breakage loud, not a subtle bug, when we get to that condition.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
diff mbox series

Patch

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index eed61ee1d394..7bee59c7834b 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -2297,6 +2297,13 @@  static int __init phy_init(void)
 {
 	int rc;
 
+	/* The phy_basic_features, phy_gbit_features etc, above, only
+	 * work for values up to 63. Ensure we get a loud error if
+	 * this threshold is exceeded, and the necessary changes are
+	 * made.
+	 */
+	BUILD_BUG_ON(__ETHTOOL_LINK_MODE_LAST > 63);
+
 	rc = mdio_bus_init();
 	if (rc)
 		return rc;