Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B557C43334 for ; Sat, 18 Jun 2022 10:29:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233054AbiFRK24 (ORCPT ); Sat, 18 Jun 2022 06:28:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231136AbiFRK2n (ORCPT ); Sat, 18 Jun 2022 06:28:43 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA04F1F634 for ; Sat, 18 Jun 2022 03:28:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=AReTznhYlBBc/1gPtDr2b6snkCs4EKArIx70nJYY4uo=; b=W68eIb5fTItL8NFaSBsQv1S7OF FVm6tnWv1pfqZcrjGA0mQ+68vpgjKlF86zIsmFLWvugzKr98ZZYwysQIX5CMhPLV1yQ7tuE6vfE33 mgAmGzQi05pe37aLHdYhYS/SUGVP0adCA8MWJtJ0vcL/0RzI4dKGz1DUJ/5xr8qnOBBk/GucOpDhM Unx6c8VTyR+V8UFde51BdOcsaGP1a6Qkyg7Dh3KT+QlnBEMfv9dZxrptc749fjY6SggBY4t4zf8n7 a0H+rXE3ktMPVXtJwegKLzGTFaM8BjzQhCYHP0tbzW7mfk1bpbRLQ1OBEJcaR50KwVgO/6wqeUXl4 QtGTp1uw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:44604 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1o2Vgz-0004At-Tb; Sat, 18 Jun 2022 11:28:37 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1o2Vgz-0026By-B9; Sat, 18 Jun 2022 11:28:37 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jose Abreu , netdev@vger.kernel.org, Paolo Abeni Subject: [PATCH net-next 2/4] net: phy: use mii_bmcr_encode_fixed() MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" Message-Id: Sender: Russell King Date: Sat, 18 Jun 2022 11:28:37 +0100 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org phylib can make use of the newly introduced mii_bmcr_encode_fixed() macro, so let's convert it over. Signed-off-by: Russell King (Oracle) --- drivers/net/phy/phy_device.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 431a8719c635..7885bceff773 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2001,18 +2001,12 @@ EXPORT_SYMBOL(genphy_config_eee_advert); */ int genphy_setup_forced(struct phy_device *phydev) { - u16 ctl = 0; + u16 ctl; phydev->pause = 0; phydev->asym_pause = 0; - if (SPEED_1000 == phydev->speed) - ctl |= BMCR_SPEED1000; - else if (SPEED_100 == phydev->speed) - ctl |= BMCR_SPEED100; - - if (DUPLEX_FULL == phydev->duplex) - ctl |= BMCR_FULLDPLX; + ctl = mii_bmcr_encode_fixed(phydev->speed, phydev->duplex); return phy_modify(phydev, MII_BMCR, ~(BMCR_LOOPBACK | BMCR_ISOLATE | BMCR_PDOWN), ctl); @@ -2614,13 +2608,7 @@ int genphy_loopback(struct phy_device *phydev, bool enable) u16 val, ctl = BMCR_LOOPBACK; int ret; - if (phydev->speed == SPEED_1000) - ctl |= BMCR_SPEED1000; - else if (phydev->speed == SPEED_100) - ctl |= BMCR_SPEED100; - - if (phydev->duplex == DUPLEX_FULL) - ctl |= BMCR_FULLDPLX; + ctl |= mii_bmcr_encode_fixed(phydev->speed, phydev->duplex); phy_modify(phydev, MII_BMCR, ~0, ctl); -- 2.30.2