Commit 59f3e4bf authored by David Woodhouse's avatar David Woodhouse Committed by David S. Miller

libertas: clean up lbs_thread() to make it slightly more readable

No semantic changes.
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 448a51ae
...@@ -795,70 +795,60 @@ static int lbs_thread(void *data) ...@@ -795,70 +795,60 @@ static int lbs_thread(void *data)
init_waitqueue_entry(&wait, current); init_waitqueue_entry(&wait, current);
set_freezable(); set_freezable();
for (;;) { for (;;) {
lbs_deb_thread( "main-thread 111: intcounter=%d " lbs_deb_thread( "main-thread 111: intcounter=%d currenttxskb=%p dnld_sent=%d\n",
"currenttxskb=%p dnld_sent=%d\n", adapter->intcounter, adapter->currenttxskb, priv->dnld_sent);
adapter->intcounter,
adapter->currenttxskb, priv->dnld_sent);
add_wait_queue(&priv->waitq, &wait); add_wait_queue(&priv->waitq, &wait);
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
spin_lock_irq(&adapter->driver_lock); spin_lock_irq(&adapter->driver_lock);
if ((adapter->psstate == PS_STATE_SLEEP) || if ((adapter->psstate == PS_STATE_SLEEP) ||
(!adapter->intcounter (!adapter->intcounter && (priv->dnld_sent || adapter->cur_cmd || list_empty(&adapter->cmdpendingq)))) {
&& (priv->dnld_sent || adapter->cur_cmd || lbs_deb_thread("main-thread sleeping... Conn=%d IntC=%d PS_mode=%d PS_State=%d\n",
list_empty(&adapter->cmdpendingq)))) { adapter->connect_status, adapter->intcounter,
lbs_deb_thread( adapter->psmode, adapter->psstate);
"main-thread sleeping... Conn=%d IntC=%d PS_mode=%d PS_State=%d\n",
adapter->connect_status, adapter->intcounter,
adapter->psmode, adapter->psstate);
spin_unlock_irq(&adapter->driver_lock); spin_unlock_irq(&adapter->driver_lock);
schedule(); schedule();
} else } else
spin_unlock_irq(&adapter->driver_lock); spin_unlock_irq(&adapter->driver_lock);
lbs_deb_thread( lbs_deb_thread("main-thread 222 (waking up): intcounter=%d currenttxskb=%p dnld_sent=%d\n",
"main-thread 222 (waking up): intcounter=%d currenttxskb=%p " adapter->intcounter, adapter->currenttxskb, priv->dnld_sent);
"dnld_sent=%d\n", adapter->intcounter,
adapter->currenttxskb, priv->dnld_sent);
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
remove_wait_queue(&priv->waitq, &wait); remove_wait_queue(&priv->waitq, &wait);
try_to_freeze(); try_to_freeze();
lbs_deb_thread("main-thread 333: intcounter=%d currenttxskb=%p " lbs_deb_thread("main-thread 333: intcounter=%d currenttxskb=%p dnld_sent=%d\n",
"dnld_sent=%d\n", adapter->intcounter, adapter->currenttxskb, priv->dnld_sent);
adapter->intcounter,
adapter->currenttxskb, priv->dnld_sent);
if (kthread_should_stop() if (kthread_should_stop() || adapter->surpriseremoved) {
|| adapter->surpriseremoved) { lbs_deb_thread("main-thread: break from main thread: surpriseremoved=0x%x\n",
lbs_deb_thread( adapter->surpriseremoved);
"main-thread: break from main thread: surpriseremoved=0x%x\n",
adapter->surpriseremoved);
break; break;
} }
spin_lock_irq(&adapter->driver_lock); spin_lock_irq(&adapter->driver_lock);
if (adapter->intcounter) { if (adapter->intcounter) {
u8 int_status; u8 int_status;
adapter->intcounter = 0; adapter->intcounter = 0;
int_status = priv->hw_get_int_status(priv, &ireg); int_status = priv->hw_get_int_status(priv, &ireg);
if (int_status) { if (int_status) {
lbs_deb_thread( lbs_deb_thread("main-thread: reading HOST_INT_STATUS_REG failed\n");
"main-thread: reading HOST_INT_STATUS_REG failed\n");
spin_unlock_irq(&adapter->driver_lock); spin_unlock_irq(&adapter->driver_lock);
continue; continue;
} }
adapter->hisregcpy |= ireg; adapter->hisregcpy |= ireg;
} }
lbs_deb_thread("main-thread 444: intcounter=%d currenttxskb=%p " lbs_deb_thread("main-thread 444: intcounter=%d currenttxskb=%p dnld_sent=%d\n",
"dnld_sent=%d\n", adapter->intcounter, adapter->currenttxskb, priv->dnld_sent);
adapter->intcounter,
adapter->currenttxskb, priv->dnld_sent);
/* command response? */ /* command response? */
if (adapter->hisregcpy & MRVDRV_CMD_UPLD_RDY) { if (adapter->hisregcpy & MRVDRV_CMD_UPLD_RDY) {
...@@ -877,8 +867,7 @@ static int lbs_thread(void *data) ...@@ -877,8 +867,7 @@ static int lbs_thread(void *data)
adapter->hisregcpy &= ~MRVDRV_CARDEVENT; adapter->hisregcpy &= ~MRVDRV_CARDEVENT;
if (priv->hw_read_event_cause(priv)) { if (priv->hw_read_event_cause(priv)) {
lbs_pr_alert( lbs_pr_alert("main-thread: hw_read_event_cause failed\n");
"main-thread: hw_read_event_cause failed\n");
spin_unlock_irq(&adapter->driver_lock); spin_unlock_irq(&adapter->driver_lock);
continue; continue;
} }
...@@ -888,30 +877,21 @@ static int lbs_thread(void *data) ...@@ -888,30 +877,21 @@ static int lbs_thread(void *data)
spin_unlock_irq(&adapter->driver_lock); spin_unlock_irq(&adapter->driver_lock);
/* Check if we need to confirm Sleep Request received previously */ /* Check if we need to confirm Sleep Request received previously */
if (adapter->psstate == PS_STATE_PRE_SLEEP) { if (adapter->psstate == PS_STATE_PRE_SLEEP &&
if (!priv->dnld_sent && !adapter->cur_cmd) { !priv->dnld_sent && !adapter->cur_cmd) {
if (adapter->connect_status == if (adapter->connect_status == LBS_CONNECTED) {
LBS_CONNECTED) { lbs_deb_thread("main_thread: PRE_SLEEP--intcounter=%d currenttxskb=%p dnld_sent=%d cur_cmd=%p, confirm now\n",
lbs_deb_thread( adapter->intcounter, adapter->currenttxskb, priv->dnld_sent, adapter->cur_cmd);
"main_thread: PRE_SLEEP--intcounter=%d currenttxskb=%p "
"dnld_sent=%d cur_cmd=%p, confirm now\n", lbs_ps_confirm_sleep(priv, (u16) adapter->psmode);
adapter->intcounter, } else {
adapter->currenttxskb, /* workaround for firmware sending
priv->dnld_sent, * deauth/linkloss event immediately
adapter->cur_cmd); * after sleep request; remove this
* after firmware fixes it
lbs_ps_confirm_sleep(priv, */
(u16) adapter->psmode); adapter->psstate = PS_STATE_AWAKE;
} else { lbs_pr_alert("main-thread: ignore PS_SleepConfirm in non-connected state\n");
/* workaround for firmware sending
* deauth/linkloss event immediately
* after sleep request, remove this
* after firmware fixes it
*/
adapter->psstate = PS_STATE_AWAKE;
lbs_pr_alert(
"main-thread: ignore PS_SleepConfirm in non-connected state\n");
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment