aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2007-12-09 23:44:43 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:06:30 -0500
commitb8d40bc9c9099943cbcf18d285bf241f1f080a44 (patch)
treeeca2597edab39a71174bef7a193b2ba5fa0b06c8 /drivers/net/wireless
parent45c24903b7026ec99c059d690f3618e3f95f2790 (diff)
libertas: refactor the 'should I sleep?' decision in lbs_thread()
This was making my brain hurt. Signed-off-by: David Woodhouse <dwmw2@infradead.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/libertas/main.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index e9c6b4ffd8e1..42b64b5ad083 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -722,6 +722,8 @@ static int lbs_thread(void *data)
722 set_freezable(); 722 set_freezable();
723 723
724 for (;;) { 724 for (;;) {
725 int shouldsleep;
726
725 lbs_deb_thread( "main-thread 111: intcounter=%d currenttxskb=%p dnld_sent=%d\n", 727 lbs_deb_thread( "main-thread 111: intcounter=%d currenttxskb=%p dnld_sent=%d\n",
726 priv->intcounter, priv->currenttxskb, priv->dnld_sent); 728 priv->intcounter, priv->currenttxskb, priv->dnld_sent);
727 729
@@ -729,8 +731,22 @@ static int lbs_thread(void *data)
729 set_current_state(TASK_INTERRUPTIBLE); 731 set_current_state(TASK_INTERRUPTIBLE);
730 spin_lock_irq(&priv->driver_lock); 732 spin_lock_irq(&priv->driver_lock);
731 733
732 if ((priv->psstate == PS_STATE_SLEEP) || 734 if (priv->surpriseremoved)
733 (!priv->intcounter && (priv->dnld_sent || priv->cur_cmd || list_empty(&priv->cmdpendingq)))) { 735 shouldsleep = 0; /* Bye */
736 else if (priv->psstate == PS_STATE_SLEEP)
737 shouldsleep = 1; /* Sleep mode. Nothing we can do till it wakes */
738 else if (priv->intcounter)
739 shouldsleep = 0; /* Interrupt pending. Deal with it now */
740 else if (priv->dnld_sent)
741 shouldsleep = 1; /* Something is en route to the device already */
742 else if (priv->cur_cmd)
743 shouldsleep = 1; /* Can't send a command; one already running */
744 else if (!list_empty(&priv->cmdpendingq))
745 shouldsleep = 0; /* We have a command to send */
746 else
747 shouldsleep = 1; /* No command */
748
749 if (shouldsleep) {
734 lbs_deb_thread("main-thread sleeping... Conn=%d IntC=%d PS_mode=%d PS_State=%d\n", 750 lbs_deb_thread("main-thread sleeping... Conn=%d IntC=%d PS_mode=%d PS_State=%d\n",
735 priv->connect_status, priv->intcounter, 751 priv->connect_status, priv->intcounter,
736 priv->psmode, priv->psstate); 752 priv->psmode, priv->psstate);