Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751326AbdL2MjM (ORCPT ); Fri, 29 Dec 2017 07:39:12 -0500 Received: from aibo.runbox.com ([91.220.196.211]:60138 "EHLO aibo.runbox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751108AbdL2MjK (ORCPT ); Fri, 29 Dec 2017 07:39:10 -0500 From: Egil Hjelmeland To: andrew@lunn.ch, vivien.didelot@savoirfairelinux.com, f.fainelli@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Egil Hjelmeland Subject: [PATCH net-next 2/2] net: dsa: lan9303: Adjust phy_addr_base expressions Date: Fri, 29 Dec 2017 13:38:24 +0100 Message-Id: <20171229123824.28452-3-privat@egil-hjelmeland.no> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171229123824.28452-1-privat@egil-hjelmeland.no> References: <20171229123824.28452-1-privat@egil-hjelmeland.no> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1400 Lines: 46 Simplify calculation of chip->phy_addr_base in lan9303_detect_phy_setup(). Use GENMASK to calculate phys_mii_mask from LAN9303_NUM_PORTS and phy_addr_base. Signed-off-by: Egil Hjelmeland --- drivers/net/dsa/lan9303-core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c index 3088cdc5d205..4efb772dbc7e 100644 --- a/drivers/net/dsa/lan9303-core.c +++ b/drivers/net/dsa/lan9303-core.c @@ -495,10 +495,7 @@ static int lan9303_detect_phy_setup(struct lan9303 *chip) return reg; } - if ((reg != 0) && (reg != 0xffff)) - chip->phy_addr_base = 1; - else - chip->phy_addr_base = 0; + chip->phy_addr_base = reg != 0 && reg != 0xffff; dev_dbg(chip->dev, "Phy setup '%s' detected\n", chip->phy_addr_base ? "1-2-3" : "0-1-2"); @@ -1283,13 +1280,16 @@ static const struct dsa_switch_ops lan9303_switch_ops = { static int lan9303_register_switch(struct lan9303 *chip) { + int base; + chip->ds = dsa_switch_alloc(chip->dev, LAN9303_NUM_PORTS); if (!chip->ds) return -ENOMEM; chip->ds->priv = chip; chip->ds->ops = &lan9303_switch_ops; - chip->ds->phys_mii_mask = chip->phy_addr_base ? 0xe : 0x7; + base = chip->phy_addr_base; + chip->ds->phys_mii_mask = GENMASK(LAN9303_NUM_PORTS - 1 + base, base); return dsa_register_switch(chip->ds); } -- 2.14.1