r8152: check RTL8152_UNPLUG

When the device is unplugged, the driver would try to disable the
device. Add checking the flag of RTL8152_UNPLUG to skip setting
the device when it is unplugged. This could shorten the time of
unloading the driver.

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by hayeswang and committed by David S. Miller 6871438c cec9ae50

+48
+48
drivers/net/usb/r8152.c
··· 929 struct r8152 *tp = netdev_priv(netdev); 930 int ret; 931 932 if (phy_id != R8152_PHY_ID) 933 return -EINVAL; 934 ··· 951 void write_mii_word(struct net_device *netdev, int phy_id, int reg, int val) 952 { 953 struct r8152 *tp = netdev_priv(netdev); 954 955 if (phy_id != R8152_PHY_ID) 956 return; ··· 1968 1969 static int rtl8152_enable(struct r8152 *tp) 1970 { 1971 set_tx_qlen(tp); 1972 rtl_set_eee_plus(tp); 1973 ··· 2003 2004 static int rtl8153_enable(struct r8152 *tp) 2005 { 2006 set_tx_qlen(tp); 2007 rtl_set_eee_plus(tp); 2008 r8153_set_rx_agg(tp); ··· 2017 { 2018 u32 ocp_data; 2019 int i; 2020 2021 ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); 2022 ocp_data &= ~RCR_ACPT_ALL; ··· 2248 { 2249 u32 ocp_data; 2250 int i; 2251 2252 ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); 2253 ocp_data &= ~RCR_ACPT_ALL; ··· 2480 u32 ocp_data; 2481 int i; 2482 2483 rxdy_gated_en(tp, true); 2484 r8153_teredo_off(tp); 2485 ··· 2710 2711 static void rtl8152_down(struct r8152 *tp) 2712 { 2713 r8152_power_cut_en(tp, false); 2714 r8152b_disable_aldps(tp); 2715 r8152b_enter_oob(tp); ··· 2723 2724 static void rtl8153_down(struct r8152 *tp) 2725 { 2726 r8153_u1u2en(tp, false); 2727 r8153_power_cut_en(tp, false); 2728 r8153_disable_aldps(tp); ··· 2937 { 2938 u32 ocp_data; 2939 2940 if (tp->version == RTL_VER_01) { 2941 ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE); 2942 ocp_data &= ~LED_MODE_MASK; ··· 2974 { 2975 u32 ocp_data; 2976 int i; 2977 2978 r8153_u1u2en(tp, false); 2979 ··· 3252 struct mii_ioctl_data *data = if_mii(rq); 3253 int res; 3254 3255 res = usb_autopm_get_interface(tp->intf); 3256 if (res < 0) 3257 goto out; ··· 3335 3336 static void rtl8152_unload(struct r8152 *tp) 3337 { 3338 if (tp->version != RTL_VER_01) 3339 r8152_power_cut_en(tp, true); 3340 } 3341 3342 static void rtl8153_unload(struct r8152 *tp) 3343 { 3344 r8153_power_cut_en(tp, true); 3345 } 3346
··· 929 struct r8152 *tp = netdev_priv(netdev); 930 int ret; 931 932 + if (test_bit(RTL8152_UNPLUG, &tp->flags)) 933 + return -ENODEV; 934 + 935 if (phy_id != R8152_PHY_ID) 936 return -EINVAL; 937 ··· 948 void write_mii_word(struct net_device *netdev, int phy_id, int reg, int val) 949 { 950 struct r8152 *tp = netdev_priv(netdev); 951 + 952 + if (test_bit(RTL8152_UNPLUG, &tp->flags)) 953 + return; 954 955 if (phy_id != R8152_PHY_ID) 956 return; ··· 1962 1963 static int rtl8152_enable(struct r8152 *tp) 1964 { 1965 + if (test_bit(RTL8152_UNPLUG, &tp->flags)) 1966 + return -ENODEV; 1967 + 1968 set_tx_qlen(tp); 1969 rtl_set_eee_plus(tp); 1970 ··· 1994 1995 static int rtl8153_enable(struct r8152 *tp) 1996 { 1997 + if (test_bit(RTL8152_UNPLUG, &tp->flags)) 1998 + return -ENODEV; 1999 + 2000 set_tx_qlen(tp); 2001 rtl_set_eee_plus(tp); 2002 r8153_set_rx_agg(tp); ··· 2005 { 2006 u32 ocp_data; 2007 int i; 2008 + 2009 + if (test_bit(RTL8152_UNPLUG, &tp->flags)) { 2010 + rtl_drop_queued_tx(tp); 2011 + return; 2012 + } 2013 2014 ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); 2015 ocp_data &= ~RCR_ACPT_ALL; ··· 2231 { 2232 u32 ocp_data; 2233 int i; 2234 + 2235 + if (test_bit(RTL8152_UNPLUG, &tp->flags)) 2236 + return; 2237 2238 ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); 2239 ocp_data &= ~RCR_ACPT_ALL; ··· 2460 u32 ocp_data; 2461 int i; 2462 2463 + if (test_bit(RTL8152_UNPLUG, &tp->flags)) 2464 + return; 2465 + 2466 rxdy_gated_en(tp, true); 2467 r8153_teredo_off(tp); 2468 ··· 2687 2688 static void rtl8152_down(struct r8152 *tp) 2689 { 2690 + if (test_bit(RTL8152_UNPLUG, &tp->flags)) { 2691 + rtl_drop_queued_tx(tp); 2692 + return; 2693 + } 2694 + 2695 r8152_power_cut_en(tp, false); 2696 r8152b_disable_aldps(tp); 2697 r8152b_enter_oob(tp); ··· 2695 2696 static void rtl8153_down(struct r8152 *tp) 2697 { 2698 + if (test_bit(RTL8152_UNPLUG, &tp->flags)) { 2699 + rtl_drop_queued_tx(tp); 2700 + return; 2701 + } 2702 + 2703 r8153_u1u2en(tp, false); 2704 r8153_power_cut_en(tp, false); 2705 r8153_disable_aldps(tp); ··· 2904 { 2905 u32 ocp_data; 2906 2907 + if (test_bit(RTL8152_UNPLUG, &tp->flags)) 2908 + return; 2909 + 2910 if (tp->version == RTL_VER_01) { 2911 ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE); 2912 ocp_data &= ~LED_MODE_MASK; ··· 2938 { 2939 u32 ocp_data; 2940 int i; 2941 + 2942 + if (test_bit(RTL8152_UNPLUG, &tp->flags)) 2943 + return; 2944 2945 r8153_u1u2en(tp, false); 2946 ··· 3213 struct mii_ioctl_data *data = if_mii(rq); 3214 int res; 3215 3216 + if (test_bit(RTL8152_UNPLUG, &tp->flags)) 3217 + return -ENODEV; 3218 + 3219 res = usb_autopm_get_interface(tp->intf); 3220 if (res < 0) 3221 goto out; ··· 3293 3294 static void rtl8152_unload(struct r8152 *tp) 3295 { 3296 + if (test_bit(RTL8152_UNPLUG, &tp->flags)) 3297 + return; 3298 + 3299 if (tp->version != RTL_VER_01) 3300 r8152_power_cut_en(tp, true); 3301 } 3302 3303 static void rtl8153_unload(struct r8152 *tp) 3304 { 3305 + if (test_bit(RTL8152_UNPLUG, &tp->flags)) 3306 + return; 3307 + 3308 r8153_power_cut_en(tp, true); 3309 } 3310