diff options
author | David Woodhouse <dwmw2@infradead.org> | 2007-12-13 21:48:00 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:07:26 -0500 |
commit | d9f88705a7ce2f9ef13d6656ee715493a663edfc (patch) | |
tree | f287e8ab83c28bc99e4c37fef08b56ed82fae12f /drivers | |
parent | 4ad36d780caf34630d1a4cc39f9bc11017f5b81d (diff) |
libertas: don't exit worker thread until kthread_stop() is called
The kthread code can't cope with a thread exiting of its own accord and
then someone calling kthread_stop() for it. When the thread detects that
it needs to die, make it wait for kthread_stop() to be called.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/libertas/main.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c index 5d2bf539d4b9..b51513fb59ec 100644 --- a/drivers/net/wireless/libertas/main.c +++ b/drivers/net/wireless/libertas/main.c | |||
@@ -662,8 +662,10 @@ static int lbs_thread(void *data) | |||
662 | set_current_state(TASK_INTERRUPTIBLE); | 662 | set_current_state(TASK_INTERRUPTIBLE); |
663 | spin_lock_irq(&priv->driver_lock); | 663 | spin_lock_irq(&priv->driver_lock); |
664 | 664 | ||
665 | if (priv->surpriseremoved) | 665 | if (kthread_should_stop()) |
666 | shouldsleep = 0; /* Bye */ | 666 | shouldsleep = 0; /* Bye */ |
667 | else if (priv->surpriseremoved) | ||
668 | shouldsleep = 1; /* We need to wait until we're _told_ to die */ | ||
667 | else if (priv->psstate == PS_STATE_SLEEP) | 669 | else if (priv->psstate == PS_STATE_SLEEP) |
668 | shouldsleep = 1; /* Sleep mode. Nothing we can do till it wakes */ | 670 | shouldsleep = 1; /* Sleep mode. Nothing we can do till it wakes */ |
669 | else if (priv->intcounter) | 671 | else if (priv->intcounter) |
@@ -699,12 +701,15 @@ static int lbs_thread(void *data) | |||
699 | lbs_deb_thread("main-thread 333: intcounter=%d currenttxskb=%p dnld_sent=%d\n", | 701 | lbs_deb_thread("main-thread 333: intcounter=%d currenttxskb=%p dnld_sent=%d\n", |
700 | priv->intcounter, priv->currenttxskb, priv->dnld_sent); | 702 | priv->intcounter, priv->currenttxskb, priv->dnld_sent); |
701 | 703 | ||
702 | if (kthread_should_stop() || priv->surpriseremoved) { | 704 | if (kthread_should_stop()) { |
703 | lbs_deb_thread("main-thread: break from main thread: surpriseremoved=0x%x\n", | 705 | lbs_deb_thread("main-thread: break from main thread\n"); |
704 | priv->surpriseremoved); | ||
705 | break; | 706 | break; |
706 | } | 707 | } |
707 | 708 | ||
709 | if (priv->surpriseremoved) { | ||
710 | lbs_deb_thread("adapter removed; waiting to die...\n"); | ||
711 | continue; | ||
712 | } | ||
708 | 713 | ||
709 | spin_lock_irq(&priv->driver_lock); | 714 | spin_lock_irq(&priv->driver_lock); |
710 | 715 | ||