diff options
author | hayeswang <hayeswang@realtek.com> | 2014-04-11 05:54:31 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-04-12 01:59:38 -0400 |
commit | 6871438cc4e5307ccda70fa2a246a546300ac9fa (patch) | |
tree | c9e22594e72552ef669f65fb565cee0064acb3ba | |
parent | cec9ae50ccb1491efee90dc8e9998e29e43652b6 (diff) |
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>
-rw-r--r-- | drivers/net/usb/r8152.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 18e12a3f7fc3..3fbfb0869030 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c | |||
@@ -929,6 +929,9 @@ static int read_mii_word(struct net_device *netdev, int phy_id, int reg) | |||
929 | struct r8152 *tp = netdev_priv(netdev); | 929 | struct r8152 *tp = netdev_priv(netdev); |
930 | int ret; | 930 | int ret; |
931 | 931 | ||
932 | if (test_bit(RTL8152_UNPLUG, &tp->flags)) | ||
933 | return -ENODEV; | ||
934 | |||
932 | if (phy_id != R8152_PHY_ID) | 935 | if (phy_id != R8152_PHY_ID) |
933 | return -EINVAL; | 936 | return -EINVAL; |
934 | 937 | ||
@@ -949,6 +952,9 @@ void write_mii_word(struct net_device *netdev, int phy_id, int reg, int val) | |||
949 | { | 952 | { |
950 | struct r8152 *tp = netdev_priv(netdev); | 953 | struct r8152 *tp = netdev_priv(netdev); |
951 | 954 | ||
955 | if (test_bit(RTL8152_UNPLUG, &tp->flags)) | ||
956 | return; | ||
957 | |||
952 | if (phy_id != R8152_PHY_ID) | 958 | if (phy_id != R8152_PHY_ID) |
953 | return; | 959 | return; |
954 | 960 | ||
@@ -1962,6 +1968,9 @@ static int rtl_enable(struct r8152 *tp) | |||
1962 | 1968 | ||
1963 | static int rtl8152_enable(struct r8152 *tp) | 1969 | static int rtl8152_enable(struct r8152 *tp) |
1964 | { | 1970 | { |
1971 | if (test_bit(RTL8152_UNPLUG, &tp->flags)) | ||
1972 | return -ENODEV; | ||
1973 | |||
1965 | set_tx_qlen(tp); | 1974 | set_tx_qlen(tp); |
1966 | rtl_set_eee_plus(tp); | 1975 | rtl_set_eee_plus(tp); |
1967 | 1976 | ||
@@ -1994,6 +2003,9 @@ static void r8153_set_rx_agg(struct r8152 *tp) | |||
1994 | 2003 | ||
1995 | static int rtl8153_enable(struct r8152 *tp) | 2004 | static int rtl8153_enable(struct r8152 *tp) |
1996 | { | 2005 | { |
2006 | if (test_bit(RTL8152_UNPLUG, &tp->flags)) | ||
2007 | return -ENODEV; | ||
2008 | |||
1997 | set_tx_qlen(tp); | 2009 | set_tx_qlen(tp); |
1998 | rtl_set_eee_plus(tp); | 2010 | rtl_set_eee_plus(tp); |
1999 | r8153_set_rx_agg(tp); | 2011 | r8153_set_rx_agg(tp); |
@@ -2006,6 +2018,11 @@ static void rtl8152_disable(struct r8152 *tp) | |||
2006 | u32 ocp_data; | 2018 | u32 ocp_data; |
2007 | int i; | 2019 | int i; |
2008 | 2020 | ||
2021 | if (test_bit(RTL8152_UNPLUG, &tp->flags)) { | ||
2022 | rtl_drop_queued_tx(tp); | ||
2023 | return; | ||
2024 | } | ||
2025 | |||
2009 | ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); | 2026 | ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); |
2010 | ocp_data &= ~RCR_ACPT_ALL; | 2027 | ocp_data &= ~RCR_ACPT_ALL; |
2011 | ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); | 2028 | ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); |
@@ -2232,6 +2249,9 @@ static void r8152b_exit_oob(struct r8152 *tp) | |||
2232 | u32 ocp_data; | 2249 | u32 ocp_data; |
2233 | int i; | 2250 | int i; |
2234 | 2251 | ||
2252 | if (test_bit(RTL8152_UNPLUG, &tp->flags)) | ||
2253 | return; | ||
2254 | |||
2235 | ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); | 2255 | ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); |
2236 | ocp_data &= ~RCR_ACPT_ALL; | 2256 | ocp_data &= ~RCR_ACPT_ALL; |
2237 | ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); | 2257 | ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); |
@@ -2460,6 +2480,9 @@ static void r8153_first_init(struct r8152 *tp) | |||
2460 | u32 ocp_data; | 2480 | u32 ocp_data; |
2461 | int i; | 2481 | int i; |
2462 | 2482 | ||
2483 | if (test_bit(RTL8152_UNPLUG, &tp->flags)) | ||
2484 | return; | ||
2485 | |||
2463 | rxdy_gated_en(tp, true); | 2486 | rxdy_gated_en(tp, true); |
2464 | r8153_teredo_off(tp); | 2487 | r8153_teredo_off(tp); |
2465 | 2488 | ||
@@ -2687,6 +2710,11 @@ out: | |||
2687 | 2710 | ||
2688 | static void rtl8152_down(struct r8152 *tp) | 2711 | static void rtl8152_down(struct r8152 *tp) |
2689 | { | 2712 | { |
2713 | if (test_bit(RTL8152_UNPLUG, &tp->flags)) { | ||
2714 | rtl_drop_queued_tx(tp); | ||
2715 | return; | ||
2716 | } | ||
2717 | |||
2690 | r8152_power_cut_en(tp, false); | 2718 | r8152_power_cut_en(tp, false); |
2691 | r8152b_disable_aldps(tp); | 2719 | r8152b_disable_aldps(tp); |
2692 | r8152b_enter_oob(tp); | 2720 | r8152b_enter_oob(tp); |
@@ -2695,6 +2723,11 @@ static void rtl8152_down(struct r8152 *tp) | |||
2695 | 2723 | ||
2696 | static void rtl8153_down(struct r8152 *tp) | 2724 | static void rtl8153_down(struct r8152 *tp) |
2697 | { | 2725 | { |
2726 | if (test_bit(RTL8152_UNPLUG, &tp->flags)) { | ||
2727 | rtl_drop_queued_tx(tp); | ||
2728 | return; | ||
2729 | } | ||
2730 | |||
2698 | r8153_u1u2en(tp, false); | 2731 | r8153_u1u2en(tp, false); |
2699 | r8153_power_cut_en(tp, false); | 2732 | r8153_power_cut_en(tp, false); |
2700 | r8153_disable_aldps(tp); | 2733 | r8153_disable_aldps(tp); |
@@ -2904,6 +2937,9 @@ static void r8152b_init(struct r8152 *tp) | |||
2904 | { | 2937 | { |
2905 | u32 ocp_data; | 2938 | u32 ocp_data; |
2906 | 2939 | ||
2940 | if (test_bit(RTL8152_UNPLUG, &tp->flags)) | ||
2941 | return; | ||
2942 | |||
2907 | if (tp->version == RTL_VER_01) { | 2943 | if (tp->version == RTL_VER_01) { |
2908 | ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE); | 2944 | ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE); |
2909 | ocp_data &= ~LED_MODE_MASK; | 2945 | ocp_data &= ~LED_MODE_MASK; |
@@ -2939,6 +2975,9 @@ static void r8153_init(struct r8152 *tp) | |||
2939 | u32 ocp_data; | 2975 | u32 ocp_data; |
2940 | int i; | 2976 | int i; |
2941 | 2977 | ||
2978 | if (test_bit(RTL8152_UNPLUG, &tp->flags)) | ||
2979 | return; | ||
2980 | |||
2942 | r8153_u1u2en(tp, false); | 2981 | r8153_u1u2en(tp, false); |
2943 | 2982 | ||
2944 | for (i = 0; i < 500; i++) { | 2983 | for (i = 0; i < 500; i++) { |
@@ -3213,6 +3252,9 @@ static int rtl8152_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) | |||
3213 | struct mii_ioctl_data *data = if_mii(rq); | 3252 | struct mii_ioctl_data *data = if_mii(rq); |
3214 | int res; | 3253 | int res; |
3215 | 3254 | ||
3255 | if (test_bit(RTL8152_UNPLUG, &tp->flags)) | ||
3256 | return -ENODEV; | ||
3257 | |||
3216 | res = usb_autopm_get_interface(tp->intf); | 3258 | res = usb_autopm_get_interface(tp->intf); |
3217 | if (res < 0) | 3259 | if (res < 0) |
3218 | goto out; | 3260 | goto out; |
@@ -3293,12 +3335,18 @@ static void r8152b_get_version(struct r8152 *tp) | |||
3293 | 3335 | ||
3294 | static void rtl8152_unload(struct r8152 *tp) | 3336 | static void rtl8152_unload(struct r8152 *tp) |
3295 | { | 3337 | { |
3338 | if (test_bit(RTL8152_UNPLUG, &tp->flags)) | ||
3339 | return; | ||
3340 | |||
3296 | if (tp->version != RTL_VER_01) | 3341 | if (tp->version != RTL_VER_01) |
3297 | r8152_power_cut_en(tp, true); | 3342 | r8152_power_cut_en(tp, true); |
3298 | } | 3343 | } |
3299 | 3344 | ||
3300 | static void rtl8153_unload(struct r8152 *tp) | 3345 | static void rtl8153_unload(struct r8152 *tp) |
3301 | { | 3346 | { |
3347 | if (test_bit(RTL8152_UNPLUG, &tp->flags)) | ||
3348 | return; | ||
3349 | |||
3302 | r8153_power_cut_en(tp, true); | 3350 | r8153_power_cut_en(tp, true); |
3303 | } | 3351 | } |
3304 | 3352 | ||