aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/8139too.c
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-11-04 22:36:28 -0500
committerJeff Garzik <jgarzik@pobox.com>2005-11-04 22:36:28 -0500
commit38b492a21ac1b0f0a5ebed69c9e2ee6f4202f574 (patch)
tree4b22aa4991148a56c2455bc71d813291666490d2 /drivers/net/8139too.c
parenta15e0384dd22ee08f56d62761ce9d770488f6f4e (diff)
[netdrvr 8139too] use cancel_rearming_delayed_work() to cancel thread
Noted by Herbert Xu.
Diffstat (limited to 'drivers/net/8139too.c')
-rw-r--r--drivers/net/8139too.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index 9de58e249bc3..bcea9d41c32c 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -586,7 +586,8 @@ struct rtl8139_private {
586 dma_addr_t tx_bufs_dma; 586 dma_addr_t tx_bufs_dma;
587 signed char phys[4]; /* MII device addresses. */ 587 signed char phys[4]; /* MII device addresses. */
588 char twistie, twist_row, twist_col; /* Twister tune state. */ 588 char twistie, twist_row, twist_col; /* Twister tune state. */
589 unsigned int default_port:4; /* Last dev->if_port value. */ 589 unsigned int default_port : 4; /* Last dev->if_port value. */
590 unsigned int have_thread : 1;
590 spinlock_t lock; 591 spinlock_t lock;
591 spinlock_t rx_lock; 592 spinlock_t rx_lock;
592 chip_t chipset; 593 chip_t chipset;
@@ -594,7 +595,6 @@ struct rtl8139_private {
594 struct rtl_extra_stats xstats; 595 struct rtl_extra_stats xstats;
595 596
596 struct work_struct thread; 597 struct work_struct thread;
597 long time_to_die; /* -1 no thr, 0 thr active, 1 thr cancel */
598 598
599 struct mii_if_info mii; 599 struct mii_if_info mii;
600 unsigned int regs_len; 600 unsigned int regs_len;
@@ -1599,40 +1599,33 @@ static void rtl8139_thread (void *_data)
1599 struct net_device *dev = _data; 1599 struct net_device *dev = _data;
1600 struct rtl8139_private *tp = netdev_priv(dev); 1600 struct rtl8139_private *tp = netdev_priv(dev);
1601 1601
1602 if ((tp->time_to_die == 0) && 1602 if (rtnl_lock_interruptible() == 0) {
1603 (rtnl_lock_interruptible() == 0)) {
1604 rtl8139_thread_iter (dev, tp, tp->mmio_addr); 1603 rtl8139_thread_iter (dev, tp, tp->mmio_addr);
1605 rtnl_unlock (); 1604 rtnl_unlock ();
1606 } 1605 }
1607 1606
1608 if (tp->time_to_die == 0) 1607 schedule_delayed_work(&tp->thread, next_tick);
1609 schedule_delayed_work(&tp->thread, next_tick);
1610} 1608}
1611 1609
1612static void rtl8139_start_thread(struct rtl8139_private *tp) 1610static void rtl8139_start_thread(struct rtl8139_private *tp)
1613{ 1611{
1614 tp->twistie = 0; 1612 tp->twistie = 0;
1615 tp->time_to_die = -1;
1616 if (tp->chipset == CH_8139_K) 1613 if (tp->chipset == CH_8139_K)
1617 tp->twistie = 1; 1614 tp->twistie = 1;
1618 else if (tp->drv_flags & HAS_LNK_CHNG) 1615 else if (tp->drv_flags & HAS_LNK_CHNG)
1619 return; 1616 return;
1620 1617
1621 tp->time_to_die = 0; 1618 tp->have_thread = 1;
1622 1619
1623 schedule_delayed_work(&tp->thread, next_tick); 1620 schedule_delayed_work(&tp->thread, next_tick);
1624} 1621}
1625 1622
1626static void rtl8139_stop_thread(struct rtl8139_private *tp) 1623static void rtl8139_stop_thread(struct rtl8139_private *tp)
1627{ 1624{
1628 if (tp->time_to_die < 0) 1625 if (tp->have_thread) {
1629 return; 1626 cancel_rearming_delayed_work(&tp->thread);
1630 1627 tp->have_thread = 0;
1631 tp->time_to_die = 1; 1628 }
1632 wmb();
1633
1634 if (cancel_delayed_work(&tp->thread) == 0)
1635 flush_scheduled_work();
1636} 1629}
1637 1630
1638static inline void rtl8139_tx_clear (struct rtl8139_private *tp) 1631static inline void rtl8139_tx_clear (struct rtl8139_private *tp)