aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiner Kallweit <hkallweit1@gmail.com>2018-02-22 15:37:48 -0500
committerDavid S. Miller <davem@davemloft.net>2018-02-23 12:29:19 -0500
commit9dbe7896d95af114fcb5554b53cf796ca9293b13 (patch)
tree121c89d2d1448abe27fe3e650b8d573c294bf54b
parent7edf6d314cd061e1d0a1b7bc0b511d64322c3f72 (diff)
r8169: simplify and improve check for dash
r8168_check_dash() returns false anyway for all chip versions not supporting dash. So we can simplify the check conditions. In addition change the check functions to return bool instead of int, because they actually return a bool value. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/realtek/r8169.c39
1 files changed, 9 insertions, 30 deletions
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 91a03d575c75..96db3283eecf 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -1472,19 +1472,19 @@ static void rtl8168_driver_stop(struct rtl8169_private *tp)
1472 } 1472 }
1473} 1473}
1474 1474
1475static int r8168dp_check_dash(struct rtl8169_private *tp) 1475static bool r8168dp_check_dash(struct rtl8169_private *tp)
1476{ 1476{
1477 u16 reg = rtl8168_get_ocp_reg(tp); 1477 u16 reg = rtl8168_get_ocp_reg(tp);
1478 1478
1479 return (ocp_read(tp, 0x0f, reg) & 0x00008000) ? 1 : 0; 1479 return !!(ocp_read(tp, 0x0f, reg) & 0x00008000);
1480} 1480}
1481 1481
1482static int r8168ep_check_dash(struct rtl8169_private *tp) 1482static bool r8168ep_check_dash(struct rtl8169_private *tp)
1483{ 1483{
1484 return (ocp_read(tp, 0x0f, 0x128) & 0x00000001) ? 1 : 0; 1484 return !!(ocp_read(tp, 0x0f, 0x128) & 0x00000001);
1485} 1485}
1486 1486
1487static int r8168_check_dash(struct rtl8169_private *tp) 1487static bool r8168_check_dash(struct rtl8169_private *tp)
1488{ 1488{
1489 switch (tp->mac_version) { 1489 switch (tp->mac_version) {
1490 case RTL_GIGA_MAC_VER_27: 1490 case RTL_GIGA_MAC_VER_27:
@@ -1496,7 +1496,7 @@ static int r8168_check_dash(struct rtl8169_private *tp)
1496 case RTL_GIGA_MAC_VER_51: 1496 case RTL_GIGA_MAC_VER_51:
1497 return r8168ep_check_dash(tp); 1497 return r8168ep_check_dash(tp);
1498 default: 1498 default:
1499 return 0; 1499 return false;
1500 } 1500 }
1501} 1501}
1502 1502
@@ -4982,15 +4982,8 @@ static void r8168_pll_power_down(struct rtl8169_private *tp)
4982{ 4982{
4983 void __iomem *ioaddr = tp->mmio_addr; 4983 void __iomem *ioaddr = tp->mmio_addr;
4984 4984
4985 if ((tp->mac_version == RTL_GIGA_MAC_VER_27 || 4985 if (r8168_check_dash(tp))
4986 tp->mac_version == RTL_GIGA_MAC_VER_28 ||
4987 tp->mac_version == RTL_GIGA_MAC_VER_31 ||
4988 tp->mac_version == RTL_GIGA_MAC_VER_49 ||
4989 tp->mac_version == RTL_GIGA_MAC_VER_50 ||
4990 tp->mac_version == RTL_GIGA_MAC_VER_51) &&
4991 r8168_check_dash(tp)) {
4992 return; 4986 return;
4993 }
4994 4987
4995 if ((tp->mac_version == RTL_GIGA_MAC_VER_23 || 4988 if ((tp->mac_version == RTL_GIGA_MAC_VER_23 ||
4996 tp->mac_version == RTL_GIGA_MAC_VER_24) && 4989 tp->mac_version == RTL_GIGA_MAC_VER_24) &&
@@ -8202,15 +8195,8 @@ static void rtl_remove_one(struct pci_dev *pdev)
8202 struct net_device *dev = pci_get_drvdata(pdev); 8195 struct net_device *dev = pci_get_drvdata(pdev);
8203 struct rtl8169_private *tp = netdev_priv(dev); 8196 struct rtl8169_private *tp = netdev_priv(dev);
8204 8197
8205 if ((tp->mac_version == RTL_GIGA_MAC_VER_27 || 8198 if (r8168_check_dash(tp))
8206 tp->mac_version == RTL_GIGA_MAC_VER_28 ||
8207 tp->mac_version == RTL_GIGA_MAC_VER_31 ||
8208 tp->mac_version == RTL_GIGA_MAC_VER_49 ||
8209 tp->mac_version == RTL_GIGA_MAC_VER_50 ||
8210 tp->mac_version == RTL_GIGA_MAC_VER_51) &&
8211 r8168_check_dash(tp)) {
8212 rtl8168_driver_stop(tp); 8199 rtl8168_driver_stop(tp);
8213 }
8214 8200
8215 netif_napi_del(&tp->napi); 8201 netif_napi_del(&tp->napi);
8216 8202
@@ -8640,15 +8626,8 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
8640 rtl_chip_infos[chipset].jumbo_tx_csum ? "ok" : "ko"); 8626 rtl_chip_infos[chipset].jumbo_tx_csum ? "ok" : "ko");
8641 } 8627 }
8642 8628
8643 if ((tp->mac_version == RTL_GIGA_MAC_VER_27 || 8629 if (r8168_check_dash(tp))
8644 tp->mac_version == RTL_GIGA_MAC_VER_28 ||
8645 tp->mac_version == RTL_GIGA_MAC_VER_31 ||
8646 tp->mac_version == RTL_GIGA_MAC_VER_49 ||
8647 tp->mac_version == RTL_GIGA_MAC_VER_50 ||
8648 tp->mac_version == RTL_GIGA_MAC_VER_51) &&
8649 r8168_check_dash(tp)) {
8650 rtl8168_driver_start(tp); 8630 rtl8168_driver_start(tp);
8651 }
8652 8631
8653 netif_carrier_off(dev); 8632 netif_carrier_off(dev);
8654 8633