Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1495927imm; Mon, 3 Sep 2018 01:52:31 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYvY33cfnq0qVH7yRBR0lvZinNRnlN4AJSIlsvkbPIbasDJ9+xdDfb2FNb2yfw4aD6IA+vX X-Received: by 2002:a62:4299:: with SMTP id h25-v6mr22823241pfd.73.1535964751183; Mon, 03 Sep 2018 01:52:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535964751; cv=none; d=google.com; s=arc-20160816; b=rW7qDq8G20qUR/uExirI8EkFFTf6M/nkdmmWENz/GyNgdgy8Y8lnqbJ5lAKV4KqLxD +TUVACDls/Eukuz6tfZEU3cpRlrJoH7xrDsFG8GJ7YPOQw/eFIWaIiKG3YuvGDDs3hKS jauB7atRjqWX27iMb3C2LJ+L0jKOAwmGvrcpOssnymAlIrXbxkL3o99L2kE3EQEo7+nu Clvm91Q+IetXZj97+MAz7ydOQf/bFczV6rZEa4kvctdiTh5xx8Zk7143G/DH14XmiEM1 pzzC1Zaims+YOUfee3vyGWotFQY52ySxXl/ngztE+IiMnRPHJvrqmTqetOcOy/Cp+B0Z lcTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=WWxy3/cTpcKjKMPX9+NyIKyNsRa1dTO508erho0NMLM=; b=eaW77bCHgN1n4J+ckZkdbn3CeARQ2y4lzOz521HdvQgXg22lbgkP28YEE2FCTso35K WgbtvVFHZm3ctdEoBOeAN3GY7uYiz1IZwvqWmvsVKX7531o7hsNTEc/jkmIqzIiJYPrq 1ut7Y443Pr3tsWY43UnuyP4S8I3Zq47ypaqPhlKAIz27FYe2Ux1LLxqACsHcWubq0rIg AGAeIm1JfvIYDrxVAvY8RLUKnf6iChrwhSeL7/3amTQwqV/NEksfHHXRZ8hMMrJIdB7v TOrlCNzsuOClbNvxsTUITPAOTO2bEFRAJWD6m7pk4tHRLukoyeDqITTp9u9+UFNkZgg+ H1gw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v8-v6si16793469pff.248.2018.09.03.01.52.15; Mon, 03 Sep 2018 01:52:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727250AbeICNIa (ORCPT + 99 others); Mon, 3 Sep 2018 09:08:30 -0400 Received: from mail.bootlin.com ([62.4.15.54]:53337 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726203AbeICNIa (ORCPT ); Mon, 3 Sep 2018 09:08:30 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 645A222A3E; Mon, 3 Sep 2018 10:49:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (AAubervilliers-681-1-92-107.w90-88.abo.wanadoo.fr [90.88.33.107]) by mail.bootlin.com (Postfix) with ESMTPSA id 19D9320DEA; Mon, 3 Sep 2018 10:49:11 +0200 (CEST) From: Quentin Schulz To: davem@davemloft.net, robh+dt@kernel.org, mark.rutland@arm.com, andrew@lunn.ch, f.fainelli@gmail.com Cc: allan.nielsen@microchip.com, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Quentin Schulz Subject: [PATCH net-next v2 2/7] net: phy: mscc: factorize function for getting LED mode from DT Date: Mon, 3 Sep 2018 10:48:48 +0200 Message-Id: <20180903084853.18092-2-quentin.schulz@bootlin.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180903084853.18092-1-quentin.schulz@bootlin.com> References: <20180903084853.18092-1-quentin.schulz@bootlin.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Microsemi PHYs support different LED modes depending on the variant, so let's factorize the code so we just have to give the supported modes while the logic behind getting the mode remains identical. Signed-off-by: Quentin Schulz --- added in v2 drivers/net/phy/mscc.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c index af433f226ef4..aa37e8547cd0 100644 --- a/drivers/net/phy/mscc.c +++ b/drivers/net/phy/mscc.c @@ -104,8 +104,24 @@ enum rgmii_rx_clock_delay { #define DOWNSHIFT_COUNT_MAX 5 #define MAX_LEDS 4 +#define VSC85XX_SUPP_LED_MODES (BIT(VSC8531_LINK_ACTIVITY) | \ + BIT(VSC8531_LINK_1000_ACTIVITY) | \ + BIT(VSC8531_LINK_100_ACTIVITY) | \ + BIT(VSC8531_LINK_10_ACTIVITY) | \ + BIT(VSC8531_LINK_100_1000_ACTIVITY) | \ + BIT(VSC8531_LINK_10_1000_ACTIVITY) | \ + BIT(VSC8531_LINK_10_100_ACTIVITY) | \ + BIT(VSC8531_DUPLEX_COLLISION) | \ + BIT(VSC8531_COLLISION) | \ + BIT(VSC8531_ACTIVITY) | \ + BIT(VSC8531_AUTONEG_FAULT) | \ + BIT(VSC8531_SERIAL_MODE) | \ + BIT(VSC8531_FORCE_LED_OFF) | \ + BIT(VSC8531_FORCE_LED_ON)) + struct vsc8531_private { int rate_magic; + u16 supp_led_modes; u8 leds_mode[MAX_LEDS]; u8 nleds; }; @@ -401,6 +417,7 @@ static int vsc85xx_dt_led_mode_get(struct phy_device *phydev, char *led, u8 default_mode) { + struct vsc8531_private *priv = phydev->priv; struct device *dev = &phydev->mdio.dev; struct device_node *of_node = dev->of_node; u8 led_mode; @@ -411,7 +428,7 @@ static int vsc85xx_dt_led_mode_get(struct phy_device *phydev, led_mode = default_mode; err = of_property_read_u8(of_node, led, &led_mode); - if (!err && (led_mode > 15 || led_mode == 7 || led_mode == 11)) { + if (!err && !(BIT(led_mode) & priv->supp_led_modes)) { phydev_err(phydev, "DT %s invalid\n", led); return -EINVAL; } @@ -655,6 +672,7 @@ static int vsc85xx_probe(struct phy_device *phydev) vsc8531->rate_magic = rate_magic; vsc8531->nleds = 2; + vsc8531->supp_led_modes = VSC85XX_SUPP_LED_MODES; return vsc85xx_dt_led_modes_get(phydev, default_mode); } -- 2.17.1