summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMichael Chan <mchan@broadcom.com>2012-09-28 07:12:41 +0000
committerDavid S. Miller <davem@davemloft.net>2012-09-30 02:10:35 -0400
commit6513859479b0fe1232cddd100db269191c1691e1 (patch)
tree87f847d79b9b0912b890cb105ce251ccbe9d65c8 /drivers
parentd8f4cd3880eff5a382ca6771062e91b58b2955db (diff)
tg3: Refactor tg3_close()
by introducing tg3_stop() that does the opposite of tg3_start(). This function will be useful when adding the support for changing the numbe of rx and tx rings. Reviewed-by: Nithin Nayak Sujir <nsujir@broadcom.com> Reviewed-by: Benjamin Li <benli@broadcom.com> Signed-off-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c70
1 files changed, 38 insertions, 32 deletions
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 9bd99ce46e5..3f2197e41a5 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -10448,6 +10448,43 @@ err_out1:
return err;
}
+static void tg3_stop(struct tg3 *tp)
+{
+ int i;
+
+ tg3_napi_disable(tp);
+ tg3_reset_task_cancel(tp);
+
+ netif_tx_disable(tp->dev);
+
+ tg3_timer_stop(tp);
+
+ tg3_hwmon_close(tp);
+
+ tg3_phy_stop(tp);
+
+ tg3_full_lock(tp, 1);
+
+ tg3_disable_ints(tp);
+
+ tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
+ tg3_free_rings(tp);
+ tg3_flag_clear(tp, INIT_COMPLETE);
+
+ tg3_full_unlock(tp);
+
+ for (i = tp->irq_cnt - 1; i >= 0; i--) {
+ struct tg3_napi *tnapi = &tp->napi[i];
+ free_irq(tnapi->irq_vec, tnapi);
+ }
+
+ tg3_ints_fini(tp);
+
+ tg3_napi_fini(tp);
+
+ tg3_free_consistent(tp);
+}
+
static int tg3_open(struct net_device *dev)
{
struct tg3 *tp = netdev_priv(dev);
@@ -10490,45 +10527,14 @@ static int tg3_open(struct net_device *dev)
static int tg3_close(struct net_device *dev)
{
- int i;
struct tg3 *tp = netdev_priv(dev);
- tg3_napi_disable(tp);
- tg3_reset_task_cancel(tp);
-
- netif_tx_stop_all_queues(dev);
-
- tg3_timer_stop(tp);
-
- tg3_hwmon_close(tp);
-
- tg3_phy_stop(tp);
-
- tg3_full_lock(tp, 1);
-
- tg3_disable_ints(tp);
-
- tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
- tg3_free_rings(tp);
- tg3_flag_clear(tp, INIT_COMPLETE);
-
- tg3_full_unlock(tp);
-
- for (i = tp->irq_cnt - 1; i >= 0; i--) {
- struct tg3_napi *tnapi = &tp->napi[i];
- free_irq(tnapi->irq_vec, tnapi);
- }
-
- tg3_ints_fini(tp);
+ tg3_stop(tp);
/* Clear stats across close / open calls */
memset(&tp->net_stats_prev, 0, sizeof(tp->net_stats_prev));
memset(&tp->estats_prev, 0, sizeof(tp->estats_prev));
- tg3_napi_fini(tp);
-
- tg3_free_consistent(tp);
-
tg3_power_down(tp);
netif_carrier_off(tp->dev);