aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/main.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2007-12-08 12:42:59 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:06:17 -0500
commit59f3e4bf1e3bc385d91a993d75865f99baa0486d (patch)
tree50c6fd9ca64c6d82b584919ea8b4938c98fdd299 /drivers/net/wireless/libertas/main.c
parent448a51ae0684c146c9f9ba4e178ab2182512258f (diff)
libertas: clean up lbs_thread() to make it slightly more readable
No semantic changes. 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.c92
1 files changed, 36 insertions, 56 deletions
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 500357ba48d..f595664f98c 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -795,70 +795,60 @@ static int lbs_thread(void *data)
795 init_waitqueue_entry(&wait, current); 795 init_waitqueue_entry(&wait, current);
796 796
797 set_freezable(); 797 set_freezable();
798
798 for (;;) { 799 for (;;) {
799 lbs_deb_thread( "main-thread 111: intcounter=%d " 800 lbs_deb_thread( "main-thread 111: intcounter=%d currenttxskb=%p dnld_sent=%d\n",
800 "currenttxskb=%p dnld_sent=%d\n", 801 adapter->intcounter, adapter->currenttxskb, priv->dnld_sent);
801 adapter->intcounter,
802 adapter->currenttxskb, priv->dnld_sent);
803 802
804 add_wait_queue(&priv->waitq, &wait); 803 add_wait_queue(&priv->waitq, &wait);
805 set_current_state(TASK_INTERRUPTIBLE); 804 set_current_state(TASK_INTERRUPTIBLE);
806 spin_lock_irq(&adapter->driver_lock); 805 spin_lock_irq(&adapter->driver_lock);
806
807 if ((adapter->psstate == PS_STATE_SLEEP) || 807 if ((adapter->psstate == PS_STATE_SLEEP) ||
808 (!adapter->intcounter 808 (!adapter->intcounter && (priv->dnld_sent || adapter->cur_cmd || list_empty(&adapter->cmdpendingq)))) {
809 && (priv->dnld_sent || adapter->cur_cmd || 809 lbs_deb_thread("main-thread sleeping... Conn=%d IntC=%d PS_mode=%d PS_State=%d\n",
810 list_empty(&adapter->cmdpendingq)))) { 810 adapter->connect_status, adapter->intcounter,
811 lbs_deb_thread( 811 adapter->psmode, adapter->psstate);
812 "main-thread sleeping... Conn=%d IntC=%d PS_mode=%d PS_State=%d\n",
813 adapter->connect_status, adapter->intcounter,
814 adapter->psmode, adapter->psstate);
815 spin_unlock_irq(&adapter->driver_lock); 812 spin_unlock_irq(&adapter->driver_lock);
816 schedule(); 813 schedule();
817 } else 814 } else
818 spin_unlock_irq(&adapter->driver_lock); 815 spin_unlock_irq(&adapter->driver_lock);
819 816
820 lbs_deb_thread( 817 lbs_deb_thread("main-thread 222 (waking up): intcounter=%d currenttxskb=%p dnld_sent=%d\n",
821 "main-thread 222 (waking up): intcounter=%d currenttxskb=%p " 818 adapter->intcounter, adapter->currenttxskb, priv->dnld_sent);
822 "dnld_sent=%d\n", adapter->intcounter,
823 adapter->currenttxskb, priv->dnld_sent);
824 819
825 set_current_state(TASK_RUNNING); 820 set_current_state(TASK_RUNNING);
826 remove_wait_queue(&priv->waitq, &wait); 821 remove_wait_queue(&priv->waitq, &wait);
827 try_to_freeze(); 822 try_to_freeze();
828 823
829 lbs_deb_thread("main-thread 333: intcounter=%d currenttxskb=%p " 824 lbs_deb_thread("main-thread 333: intcounter=%d currenttxskb=%p dnld_sent=%d\n",
830 "dnld_sent=%d\n", 825 adapter->intcounter, adapter->currenttxskb, priv->dnld_sent);
831 adapter->intcounter,
832 adapter->currenttxskb, priv->dnld_sent);
833 826
834 if (kthread_should_stop() 827 if (kthread_should_stop() || adapter->surpriseremoved) {
835 || adapter->surpriseremoved) { 828 lbs_deb_thread("main-thread: break from main thread: surpriseremoved=0x%x\n",
836 lbs_deb_thread( 829 adapter->surpriseremoved);
837 "main-thread: break from main thread: surpriseremoved=0x%x\n",
838 adapter->surpriseremoved);
839 break; 830 break;
840 } 831 }
841 832
842 833
843 spin_lock_irq(&adapter->driver_lock); 834 spin_lock_irq(&adapter->driver_lock);
835
844 if (adapter->intcounter) { 836 if (adapter->intcounter) {
845 u8 int_status; 837 u8 int_status;
838
846 adapter->intcounter = 0; 839 adapter->intcounter = 0;
847 int_status = priv->hw_get_int_status(priv, &ireg); 840 int_status = priv->hw_get_int_status(priv, &ireg);
848 841
849 if (int_status) { 842 if (int_status) {
850 lbs_deb_thread( 843 lbs_deb_thread("main-thread: reading HOST_INT_STATUS_REG failed\n");
851 "main-thread: reading HOST_INT_STATUS_REG failed\n");
852 spin_unlock_irq(&adapter->driver_lock); 844 spin_unlock_irq(&adapter->driver_lock);
853 continue; 845 continue;
854 } 846 }
855 adapter->hisregcpy |= ireg; 847 adapter->hisregcpy |= ireg;
856 } 848 }
857 849
858 lbs_deb_thread("main-thread 444: intcounter=%d currenttxskb=%p " 850 lbs_deb_thread("main-thread 444: intcounter=%d currenttxskb=%p dnld_sent=%d\n",
859 "dnld_sent=%d\n", 851 adapter->intcounter, adapter->currenttxskb, priv->dnld_sent);
860 adapter->intcounter,
861 adapter->currenttxskb, priv->dnld_sent);
862 852
863 /* command response? */ 853 /* command response? */
864 if (adapter->hisregcpy & MRVDRV_CMD_UPLD_RDY) { 854 if (adapter->hisregcpy & MRVDRV_CMD_UPLD_RDY) {
@@ -877,8 +867,7 @@ static int lbs_thread(void *data)
877 adapter->hisregcpy &= ~MRVDRV_CARDEVENT; 867 adapter->hisregcpy &= ~MRVDRV_CARDEVENT;
878 868
879 if (priv->hw_read_event_cause(priv)) { 869 if (priv->hw_read_event_cause(priv)) {
880 lbs_pr_alert( 870 lbs_pr_alert("main-thread: hw_read_event_cause failed\n");
881 "main-thread: hw_read_event_cause failed\n");
882 spin_unlock_irq(&adapter->driver_lock); 871 spin_unlock_irq(&adapter->driver_lock);
883 continue; 872 continue;
884 } 873 }
@@ -888,30 +877,21 @@ static int lbs_thread(void *data)
888 spin_unlock_irq(&adapter->driver_lock); 877 spin_unlock_irq(&adapter->driver_lock);
889 878
890 /* Check if we need to confirm Sleep Request received previously */ 879 /* Check if we need to confirm Sleep Request received previously */
891 if (adapter->psstate == PS_STATE_PRE_SLEEP) { 880 if (adapter->psstate == PS_STATE_PRE_SLEEP &&
892 if (!priv->dnld_sent && !adapter->cur_cmd) { 881 !priv->dnld_sent && !adapter->cur_cmd) {
893 if (adapter->connect_status == 882 if (adapter->connect_status == LBS_CONNECTED) {
894 LBS_CONNECTED) { 883 lbs_deb_thread("main_thread: PRE_SLEEP--intcounter=%d currenttxskb=%p dnld_sent=%d cur_cmd=%p, confirm now\n",
895 lbs_deb_thread( 884 adapter->intcounter, adapter->currenttxskb, priv->dnld_sent, adapter->cur_cmd);
896 "main_thread: PRE_SLEEP--intcounter=%d currenttxskb=%p " 885
897 "dnld_sent=%d cur_cmd=%p, confirm now\n", 886 lbs_ps_confirm_sleep(priv, (u16) adapter->psmode);
898 adapter->intcounter, 887 } else {
899 adapter->currenttxskb, 888 /* workaround for firmware sending
900 priv->dnld_sent, 889 * deauth/linkloss event immediately
901 adapter->cur_cmd); 890 * after sleep request; remove this
902 891 * after firmware fixes it
903 lbs_ps_confirm_sleep(priv, 892 */
904 (u16) adapter->psmode); 893 adapter->psstate = PS_STATE_AWAKE;
905 } else { 894 lbs_pr_alert("main-thread: ignore PS_SleepConfirm in non-connected state\n");
906 /* workaround for firmware sending
907 * deauth/linkloss event immediately
908 * after sleep request, remove this
909 * after firmware fixes it
910 */
911 adapter->psstate = PS_STATE_AWAKE;
912 lbs_pr_alert(
913 "main-thread: ignore PS_SleepConfirm in non-connected state\n");
914 }
915 } 895 }
916 } 896 }
917 897