@@ -624,6 +624,7 @@ struct rtl8169_private {
624624
625625 unsigned supports_gmii :1 ;
626626 unsigned aspm_manageable :1 ;
627+ unsigned dash_enabled :1 ;
627628 dma_addr_t counters_phys_addr ;
628629 struct rtl8169_counters * counters ;
629630 struct rtl8169_tc_offsets tc_offset ;
@@ -1253,14 +1254,26 @@ static bool r8168ep_check_dash(struct rtl8169_private *tp)
12531254 return r8168ep_ocp_read (tp , 0x128 ) & BIT (0 );
12541255}
12551256
1256- static enum rtl_dash_type rtl_check_dash (struct rtl8169_private * tp )
1257+ static bool rtl_dash_is_enabled (struct rtl8169_private * tp )
1258+ {
1259+ switch (tp -> dash_type ) {
1260+ case RTL_DASH_DP :
1261+ return r8168dp_check_dash (tp );
1262+ case RTL_DASH_EP :
1263+ return r8168ep_check_dash (tp );
1264+ default :
1265+ return false;
1266+ }
1267+ }
1268+
1269+ static enum rtl_dash_type rtl_get_dash_type (struct rtl8169_private * tp )
12571270{
12581271 switch (tp -> mac_version ) {
12591272 case RTL_GIGA_MAC_VER_28 :
12601273 case RTL_GIGA_MAC_VER_31 :
1261- return r8168dp_check_dash ( tp ) ? RTL_DASH_DP : RTL_DASH_NONE ;
1274+ return RTL_DASH_DP ;
12621275 case RTL_GIGA_MAC_VER_51 ... RTL_GIGA_MAC_VER_53 :
1263- return r8168ep_check_dash ( tp ) ? RTL_DASH_EP : RTL_DASH_NONE ;
1276+ return RTL_DASH_EP ;
12641277 default :
12651278 return RTL_DASH_NONE ;
12661279 }
@@ -1453,7 +1466,7 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
14531466
14541467 device_set_wakeup_enable (tp_to_dev (tp ), wolopts );
14551468
1456- if (tp -> dash_type == RTL_DASH_NONE ) {
1469+ if (! tp -> dash_enabled ) {
14571470 rtl_set_d3_pll_down (tp , !wolopts );
14581471 tp -> dev -> wol_enabled = wolopts ? 1 : 0 ;
14591472 }
@@ -2512,7 +2525,7 @@ static void rtl_wol_enable_rx(struct rtl8169_private *tp)
25122525
25132526static void rtl_prepare_power_down (struct rtl8169_private * tp )
25142527{
2515- if (tp -> dash_type != RTL_DASH_NONE )
2528+ if (tp -> dash_enabled )
25162529 return ;
25172530
25182531 if (tp -> mac_version == RTL_GIGA_MAC_VER_32 ||
@@ -4869,7 +4882,7 @@ static int rtl8169_runtime_idle(struct device *device)
48694882{
48704883 struct rtl8169_private * tp = dev_get_drvdata (device );
48714884
4872- if (tp -> dash_type != RTL_DASH_NONE )
4885+ if (tp -> dash_enabled )
48734886 return - EBUSY ;
48744887
48754888 if (!netif_running (tp -> dev ) || !netif_carrier_ok (tp -> dev ))
@@ -4895,8 +4908,7 @@ static void rtl_shutdown(struct pci_dev *pdev)
48954908 /* Restore original MAC address */
48964909 rtl_rar_set (tp , tp -> dev -> perm_addr );
48974910
4898- if (system_state == SYSTEM_POWER_OFF &&
4899- tp -> dash_type == RTL_DASH_NONE ) {
4911+ if (system_state == SYSTEM_POWER_OFF && !tp -> dash_enabled ) {
49004912 pci_wake_from_d3 (pdev , tp -> saved_wolopts );
49014913 pci_set_power_state (pdev , PCI_D3hot );
49024914 }
@@ -5254,7 +5266,8 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
52545266 rc = pci_disable_link_state (pdev , PCIE_LINK_STATE_L1 );
52555267 tp -> aspm_manageable = !rc ;
52565268
5257- tp -> dash_type = rtl_check_dash (tp );
5269+ tp -> dash_type = rtl_get_dash_type (tp );
5270+ tp -> dash_enabled = rtl_dash_is_enabled (tp );
52585271
52595272 tp -> cp_cmd = RTL_R16 (tp , CPlusCmd ) & CPCMD_MASK ;
52605273
@@ -5325,7 +5338,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
53255338 /* configure chip for default features */
53265339 rtl8169_set_features (dev , dev -> features );
53275340
5328- if (tp -> dash_type == RTL_DASH_NONE ) {
5341+ if (! tp -> dash_enabled ) {
53295342 rtl_set_d3_pll_down (tp , true);
53305343 } else {
53315344 rtl_set_d3_pll_down (tp , false);
@@ -5365,7 +5378,8 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
53655378 "ok" : "ko" );
53665379
53675380 if (tp -> dash_type != RTL_DASH_NONE ) {
5368- netdev_info (dev , "DASH enabled\n" );
5381+ netdev_info (dev , "DASH %s\n" ,
5382+ tp -> dash_enabled ? "enabled" : "disabled" );
53695383 rtl8168_driver_start (tp );
53705384 }
53715385
0 commit comments