wlcore: Prevent interaction with HW after recovery is queued
[cascardo/linux.git] / drivers / net / wireless / ti / wlcore / debugfs.c
index 80dbc53..3b7e0e8 100644 (file)
@@ -62,11 +62,14 @@ void wl1271_debugfs_update_stats(struct wl1271 *wl)
 
        mutex_lock(&wl->mutex);
 
+       if (unlikely(wl->state != WLCORE_STATE_ON))
+               goto out;
+
        ret = wl1271_ps_elp_wakeup(wl);
        if (ret < 0)
                goto out;
 
-       if (wl->state == WL1271_STATE_ON && !wl->plt &&
+       if (!wl->plt &&
            time_after(jiffies, wl->stats.fw_stats_update +
                       msecs_to_jiffies(WL1271_DEBUGFS_STATS_LIFETIME))) {
                wl1271_acx_statistics(wl, wl->stats.fw_stats);
@@ -286,7 +289,7 @@ static ssize_t dynamic_ps_timeout_write(struct file *file,
 
        wl->conf.conn.dynamic_ps_timeout = value;
 
-       if (wl->state == WL1271_STATE_OFF)
+       if (unlikely(wl->state != WLCORE_STATE_ON))
                goto out;
 
        ret = wl1271_ps_elp_wakeup(wl);
@@ -353,7 +356,7 @@ static ssize_t forced_ps_write(struct file *file,
 
        wl->conf.conn.forced_ps = value;
 
-       if (wl->state == WL1271_STATE_OFF)
+       if (unlikely(wl->state != WLCORE_STATE_ON))
                goto out;
 
        ret = wl1271_ps_elp_wakeup(wl);
@@ -999,7 +1002,7 @@ static ssize_t sleep_auth_write(struct file *file,
 
        wl->conf.conn.sta_sleep_auth = value;
 
-       if (wl->state == WL1271_STATE_OFF) {
+       if (unlikely(wl->state != WLCORE_STATE_ON)) {
                /* this will show up on "read" in case we are off */
                wl->sleep_auth = value;
                goto out;
@@ -1060,7 +1063,7 @@ static ssize_t dev_mem_read(struct file *file,
 
        mutex_lock(&wl->mutex);
 
-       if (wl->state == WL1271_STATE_OFF) {
+       if (unlikely(wl->state != WLCORE_STATE_ON)) {
                ret = -EFAULT;
                goto skip_read;
        }
@@ -1145,7 +1148,7 @@ static ssize_t dev_mem_write(struct file *file, const char __user *user_buf,
 
        mutex_lock(&wl->mutex);
 
-       if (wl->state == WL1271_STATE_OFF) {
+       if (unlikely(wl->state != WLCORE_STATE_ON)) {
                ret = -EFAULT;
                goto skip_write;
        }