net: wireless: bcmdhd: Make responce waiting uninterruptible
Dmitry Shmidt [Tue, 29 May 2012 22:05:33 +0000 (15:05 -0700)]
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

drivers/net/wireless/bcmdhd/dhd_linux.c
drivers/net/wireless/bcmdhd/dhd_sdio.c

index 93050b8..6ba7df1 100644 (file)
@@ -672,16 +672,12 @@ dhd_timeout_expired(dhd_timeout_t *tmo)
        } else {
                wait_queue_head_t delay_wait;
                DECLARE_WAITQUEUE(wait, current);
-               int pending;
                init_waitqueue_head(&delay_wait);
                add_wait_queue(&delay_wait, &wait);
                set_current_state(TASK_INTERRUPTIBLE);
                schedule_timeout(1);
-               pending = signal_pending(current);
                remove_wait_queue(&delay_wait, &wait);
                set_current_state(TASK_RUNNING);
-               if (pending)
-                       return 1;       /* Interrupted */
        }
 
        return 0;
@@ -3914,7 +3910,6 @@ int
 dhd_os_ioctl_resp_wait(dhd_pub_t *pub, uint *condition, bool *pending)
 {
        dhd_info_t * dhd = (dhd_info_t *)(pub->info);
-       DECLARE_WAITQUEUE(wait, current);
        int timeout = dhd_ioctl_timeout_msec;
 
        /* Convert timeout in millsecond to jiffies */
@@ -3924,23 +3919,7 @@ dhd_os_ioctl_resp_wait(dhd_pub_t *pub, uint *condition, bool *pending)
        timeout = timeout * HZ / 1000;
 #endif
 
-       /* Wait until control frame is available */
-       add_wait_queue(&dhd->ioctl_resp_wait, &wait);
-       set_current_state(TASK_INTERRUPTIBLE);
-
-       /* Memory barrier to support multi-processing
-        * As the variable "condition", which points to dhd->rxlen (dhd_bus_rxctl[dhd_sdio.c])
-        * Can be changed by another processor.
-        */
-       smp_mb();
-       while (!(*condition) && timeout) {
-               timeout = schedule_timeout(timeout);
-               smp_mb();
-       }
-
-       set_current_state(TASK_RUNNING);
-       remove_wait_queue(&dhd->ioctl_resp_wait, &wait);
-
+       timeout = wait_event_timeout(dhd->ioctl_resp_wait, (*condition), timeout);
        return timeout;
 }
 
@@ -3950,7 +3929,7 @@ dhd_os_ioctl_resp_wake(dhd_pub_t *pub)
        dhd_info_t *dhd = (dhd_info_t *)(pub->info);
 
        if (waitqueue_active(&dhd->ioctl_resp_wait)) {
-               wake_up_interruptible(&dhd->ioctl_resp_wait);
+               wake_up(&dhd->ioctl_resp_wait);
        }
 
        return 0;
@@ -4299,8 +4278,13 @@ void dhd_wait_for_event(dhd_pub_t *dhd, bool *lockvar)
 {
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
        struct dhd_info *dhdinfo =  dhd->info;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
+       int timeout = msecs_to_jiffies(2000);
+#else
+       int timeout = 2 * HZ;
+#endif
        dhd_os_sdunlock(dhd);
-       wait_event_interruptible_timeout(dhdinfo->ctrl_wait, (*lockvar == FALSE), HZ * 2);
+       wait_event_timeout(dhdinfo->ctrl_wait, (*lockvar == FALSE), timeout);
        dhd_os_sdlock(dhd);
 #endif
        return;
@@ -4311,7 +4295,7 @@ void dhd_wait_event_wakeup(dhd_pub_t *dhd)
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
        struct dhd_info *dhdinfo =  dhd->info;
        if (waitqueue_active(&dhdinfo->ctrl_wait))
-               wake_up_interruptible(&dhdinfo->ctrl_wait);
+               wake_up(&dhdinfo->ctrl_wait);
 #endif
        return;
 }
index 4e6f9c8..2cac95f 100644 (file)
@@ -3124,9 +3124,9 @@ dhd_bus_init(dhd_pub_t *dhdp, bool enforce_mutex)
        dhd_timeout_start(&tmo, DHD_WAIT_F2RDY * 1000);
 
        ready = 0;
-       while (ready != enable && !dhd_timeout_expired(&tmo))
-               ready = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_IORDY, NULL);
-
+       do {
+               ready = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_IORDY, NULL);
+       } while (ready != enable && !dhd_timeout_expired(&tmo));
 
        DHD_INFO(("%s: enable 0x%02x, ready 0x%02x (waited %uus)\n",
                  __FUNCTION__, enable, ready, tmo.elapsed));