mac80211: track work started through callbacks
authorJohannes Berg <johannes@sipsolutions.net>
Mon, 25 Jan 2010 12:36:36 +0000 (13:36 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 25 Jan 2010 21:36:29 +0000 (16:36 -0500)
Currently, the remain_on_channel work callback needs
to track in its own data structure whether the work
was just started or not. By reordering some code this
becomes unnecessary, the generic wk->started variable
can still be 'false' on the first invocation and only
be 'true' on actual timeout invocations, so that the
extra variable can be removed.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/mac80211/ieee80211_i.h
net/mac80211/work.c

index c18f576f18481fa31b587fdbd84a8c5e84edaa2b..3067fbd69d6360e51c1832032317a39180b1ad5e 100644 (file)
@@ -299,7 +299,6 @@ struct ieee80211_work {
                } assoc;
                struct {
                        u32 duration;
-                       bool started;
                } remain;
        };
 
index df8277cdb4d00f3b15237fe4931e61599a55ae95..7e708d5c88b4e156586413a23c3d9e4f2c638920 100644 (file)
@@ -535,8 +535,7 @@ ieee80211_remain_on_channel_timeout(struct ieee80211_work *wk)
         * First time we run, do nothing -- the generic code will
         * have switched to the right channel etc.
         */
-       if (!wk->remain.started) {
-               wk->remain.started = true;
+       if (!wk->started) {
                wk->timeout = jiffies + msecs_to_jiffies(wk->remain.duration);
 
                cfg80211_ready_on_channel(wk->sdata->dev, (unsigned long) wk,
@@ -821,15 +820,17 @@ static void ieee80211_work_work(struct work_struct *work)
        mutex_lock(&local->work_mtx);
 
        list_for_each_entry_safe(wk, tmp, &local->work_list, list) {
+               bool started = wk->started;
+
                /* mark work as started if it's on the current off-channel */
-               if (!wk->started && local->tmp_channel &&
+               if (!started && local->tmp_channel &&
                    wk->chan == local->tmp_channel &&
                    wk->chan_type == local->tmp_channel_type) {
-                       wk->started = true;
+                       started = true;
                        wk->timeout = jiffies;
                }
 
-               if (!wk->started && !local->tmp_channel) {
+               if (!started && !local->tmp_channel) {
                        /*
                         * TODO: could optimize this by leaving the
                         *       station vifs in awake mode if they
@@ -842,12 +843,12 @@ static void ieee80211_work_work(struct work_struct *work)
                        local->tmp_channel = wk->chan;
                        local->tmp_channel_type = wk->chan_type;
                        ieee80211_hw_config(local, 0);
-                       wk->started = true;
+                       started = true;
                        wk->timeout = jiffies;
                }
 
                /* don't try to work with items that aren't started */
-               if (!wk->started)
+               if (!started)
                        continue;
 
                if (time_is_after_jiffies(wk->timeout)) {
@@ -882,6 +883,8 @@ static void ieee80211_work_work(struct work_struct *work)
                        break;
                }
 
+               wk->started = started;
+
                switch (rma) {
                case WORK_ACT_NONE:
                        /* might have changed the timeout */