From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heiner Kallweit Subject: [PATCH RFC 18/18] r8168: use link speed information as maintained by phylib Date: Thu, 21 Dec 2017 21:50:55 +0100 Message-ID: <98e89d73-7d9d-61f6-f3be-ea53b557b7b0@gmail.com> References: <83321b2e-8402-26c5-9703-3fe795cc893d@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: David Miller , "netdev@vger.kernel.org" To: Andrew Lunn , Realtek linux nic maintainers , Chun-Hao Lin Return-path: Received: from mail-wm0-f67.google.com ([74.125.82.67]:38101 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753521AbdLUUv2 (ORCPT ); Thu, 21 Dec 2017 15:51:28 -0500 Received: by mail-wm0-f67.google.com with SMTP id 64so18148869wme.3 for ; Thu, 21 Dec 2017 12:51:28 -0800 (PST) In-Reply-To: <83321b2e-8402-26c5-9703-3fe795cc893d@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: Let's use the speed information as maintained by phylib instead of reading it directly from a register. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8168.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8168.c b/drivers/net/ethernet/realtek/r8168.c index 765c60bc1..6c57af825 100644 --- a/drivers/net/ethernet/realtek/r8168.c +++ b/drivers/net/ethernet/realtek/r8168.c @@ -618,16 +618,6 @@ enum rtl_register_content { INTT_2 = 0x0002, // 8168 INTT_3 = 0x0003, // 8168 - /* rtl8168_PHYstatus */ - TBI_Enable = 0x80, - TxFlowCtrl = 0x40, - RxFlowCtrl = 0x20, - _1000bpsF = 0x10, - _100bps = 0x08, - _10bps = 0x04, - LinkStatus = 0x02, - FullDup = 0x01, - /* ResetCounterCommand */ CounterReset = 0x1, @@ -1544,20 +1534,20 @@ static void rtl8168_irq_mask_and_ack(struct rtl8168_private *tp) static void rtl_link_chg_patch(struct rtl8168_private *tp) { - void __iomem *ioaddr = tp->mmio_addr; struct net_device *dev = tp->dev; + struct phy_device *phydev = dev->phydev; if (!netif_running(dev)) return; if (tp->mac_version == RTL_GIGA_MAC_VER_34 || tp->mac_version == RTL_GIGA_MAC_VER_38) { - if (RTL_R8(PHYstatus) & _1000bpsF) { + if (phydev->speed == SPEED_1000) { rtl_eri_write(tp, 0x1bc, ERIAR_MASK_1111, 0x00000011, ERIAR_EXGMAC); rtl_eri_write(tp, 0x1dc, ERIAR_MASK_1111, 0x00000005, ERIAR_EXGMAC); - } else if (RTL_R8(PHYstatus) & _100bps) { + } else if (phydev->speed == SPEED_100) { rtl_eri_write(tp, 0x1bc, ERIAR_MASK_1111, 0x0000001f, ERIAR_EXGMAC); rtl_eri_write(tp, 0x1dc, ERIAR_MASK_1111, 0x00000005, @@ -1575,7 +1565,7 @@ static void rtl_link_chg_patch(struct rtl8168_private *tp) ERIAR_EXGMAC); } else if (tp->mac_version == RTL_GIGA_MAC_VER_35 || tp->mac_version == RTL_GIGA_MAC_VER_36) { - if (RTL_R8(PHYstatus) & _1000bpsF) { + if (phydev->speed == SPEED_1000) { rtl_eri_write(tp, 0x1bc, ERIAR_MASK_1111, 0x00000011, ERIAR_EXGMAC); rtl_eri_write(tp, 0x1dc, ERIAR_MASK_1111, 0x00000005, @@ -1587,7 +1577,7 @@ static void rtl_link_chg_patch(struct rtl8168_private *tp) ERIAR_EXGMAC); } } else if (tp->mac_version == RTL_GIGA_MAC_VER_37) { - if (RTL_R8(PHYstatus) & _10bps) { + if (phydev->speed == SPEED_10) { rtl_eri_write(tp, 0x1d0, ERIAR_MASK_0011, 0x4d02, ERIAR_EXGMAC); rtl_eri_write(tp, 0x1dc, ERIAR_MASK_0011, 0x0060, -- 2.15.1