From patchwork Fri Sep 14 21:38:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 970120 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=lunn.ch Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=lunn.ch header.i=@lunn.ch header.b="GfTRUDs7"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42BpqY4C4Pz9s3x for ; Sat, 15 Sep 2018 07:41:13 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728302AbeIOC5a (ORCPT ); Fri, 14 Sep 2018 22:57:30 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:35229 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727807AbeIOC53 (ORCPT ); Fri, 14 Sep 2018 22:57:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=suBIVAqpCJi2LxPxLxB8/Qpgyp1i61Wa9iJ0J7iYJLA=; b=GfTRUDs7yNsd63AvwZm+xTuPsLwWwpPuvrepr+pHrOB0jhbl5MWm1HIX9KlnnMjzdb6hHf8AQnXWGKaTceQVHr3xDS0NHtZ+crym/sWEiM8/ltgI/TkBFpJt1r/PJ8+Nex73lX9RZCQLWsoNDJpbSsmAltKgQfCVRVN09qqeZ3Y=; Received: from andrew by vps0.lunn.ch with local (Exim 4.84_2) (envelope-from ) id 1g0vns-0007wQ-Ah; Fri, 14 Sep 2018 23:39:04 +0200 From: Andrew Lunn To: netdev Cc: Florian Fainelli , Andrew Lunn Subject: [PATH RFC net-next 8/8] net: phy: Add build warning if assumptions get broken Date: Fri, 14 Sep 2018 23:38:56 +0200 Message-Id: <1536961136-30453-9-git-send-email-andrew@lunn.ch> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1536961136-30453-1-git-send-email-andrew@lunn.ch> References: <1536961136-30453-1-git-send-email-andrew@lunn.ch> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Reviewed-by: Florian Fainelli --- drivers/net/phy/phy_device.c | 7 +++++++ 1 file changed, 7 insertions(+) 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;