summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/libertas/main.c
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 15:06:30 -0800
commitb8d40bc9c9099943cbcf18d285bf241f1f080a44 (patch)
treeeca2597edab39a71174bef7a193b2ba5fa0b06c8 /drivers/net/wireless/libertas/main.c
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/libertas/main.c')
-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)
set_freezable();
for (;;) {
+ int shouldsleep;
+
lbs_deb_thread( "main-thread 111: intcounter=%d currenttxskb=%p dnld_sent=%d\n",
priv->intcounter, priv->currenttxskb, priv->dnld_sent);
@@ -729,8 +731,22 @@ static int lbs_thread(void *data)
set_current_state(TASK_INTERRUPTIBLE);
spin_lock_irq(&priv->driver_lock);
- if ((priv->psstate == PS_STATE_SLEEP) ||
- (!priv->intcounter && (priv->dnld_sent || priv->cur_cmd || list_empty(&priv->cmdpendingq)))) {
+ if (priv->surpriseremoved)
+ shouldsleep = 0; /* Bye */
+ else if (priv->psstate == PS_STATE_SLEEP)
+ shouldsleep = 1; /* Sleep mode. Nothing we can do till it wakes */
+ else if (priv->intcounter)
+ shouldsleep = 0; /* Interrupt pending. Deal with it now */
+ else if (priv->dnld_sent)
+ shouldsleep = 1; /* Something is en route to the device already */
+ else if (priv->cur_cmd)
+ shouldsleep = 1; /* Can't send a command; one already running */
+ else if (!list_empty(&priv->cmdpendingq))
+ shouldsleep = 0; /* We have a command to send */
+ else
+ shouldsleep = 1; /* No command */
+
+ if (shouldsleep) {
lbs_deb_thread("main-thread sleeping... Conn=%d IntC=%d PS_mode=%d PS_State=%d\n",
priv->connect_status, priv->intcounter,
priv->psmode, priv->psstate);