Skip to content

Commit 9dbe789

Browse files
hkallweitdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7edf6d3 commit 9dbe789

File tree

1 file changed

+9
-30
lines changed
  • drivers/net/ethernet/realtek

1 file changed

+9
-30
lines changed

drivers/net/ethernet/realtek/r8169.c

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,19 +1472,19 @@ static void rtl8168_driver_stop(struct rtl8169_private *tp)
14721472
}
14731473
}
14741474

1475-
static int r8168dp_check_dash(struct rtl8169_private *tp)
1475+
static bool r8168dp_check_dash(struct rtl8169_private *tp)
14761476
{
14771477
u16 reg = rtl8168_get_ocp_reg(tp);
14781478

1479-
return (ocp_read(tp, 0x0f, reg) & 0x00008000) ? 1 : 0;
1479+
return !!(ocp_read(tp, 0x0f, reg) & 0x00008000);
14801480
}
14811481

1482-
static int r8168ep_check_dash(struct rtl8169_private *tp)
1482+
static bool r8168ep_check_dash(struct rtl8169_private *tp)
14831483
{
1484-
return (ocp_read(tp, 0x0f, 0x128) & 0x00000001) ? 1 : 0;
1484+
return !!(ocp_read(tp, 0x0f, 0x128) & 0x00000001);
14851485
}
14861486

1487-
static int r8168_check_dash(struct rtl8169_private *tp)
1487+
static bool r8168_check_dash(struct rtl8169_private *tp)
14881488
{
14891489
switch (tp->mac_version) {
14901490
case RTL_GIGA_MAC_VER_27:
@@ -1496,7 +1496,7 @@ static int r8168_check_dash(struct rtl8169_private *tp)
14961496
case RTL_GIGA_MAC_VER_51:
14971497
return r8168ep_check_dash(tp);
14981498
default:
1499-
return 0;
1499+
return false;
15001500
}
15011501
}
15021502

@@ -4982,15 +4982,8 @@ static void r8168_pll_power_down(struct rtl8169_private *tp)
49824982
{
49834983
void __iomem *ioaddr = tp->mmio_addr;
49844984

4985-
if ((tp->mac_version == RTL_GIGA_MAC_VER_27 ||
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)) {
4985+
if (r8168_check_dash(tp))
49924986
return;
4993-
}
49944987

49954988
if ((tp->mac_version == RTL_GIGA_MAC_VER_23 ||
49964989
tp->mac_version == RTL_GIGA_MAC_VER_24) &&
@@ -8202,15 +8195,8 @@ static void rtl_remove_one(struct pci_dev *pdev)
82028195
struct net_device *dev = pci_get_drvdata(pdev);
82038196
struct rtl8169_private *tp = netdev_priv(dev);
82048197

8205-
if ((tp->mac_version == RTL_GIGA_MAC_VER_27 ||
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)) {
8198+
if (r8168_check_dash(tp))
82128199
rtl8168_driver_stop(tp);
8213-
}
82148200

82158201
netif_napi_del(&tp->napi);
82168202

@@ -8640,15 +8626,8 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
86408626
rtl_chip_infos[chipset].jumbo_tx_csum ? "ok" : "ko");
86418627
}
86428628

8643-
if ((tp->mac_version == RTL_GIGA_MAC_VER_27 ||
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)) {
8629+
if (r8168_check_dash(tp))
86508630
rtl8168_driver_start(tp);
8651-
}
86528631

86538632
netif_carrier_off(dev);
86548633

0 commit comments

Comments
 (0)