rt2x00: Introduce beacon_update_locked that requires caller locking
authorHelmut Schaa <helmut.schaa@googlemail.com>
Sun, 30 Jan 2011 12:16:28 +0000 (13:16 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 31 Jan 2011 20:06:22 +0000 (15:06 -0500)
Introduce a beacon_update_locked function that does not acquire the
according beacon mutex to allow beacon updates from atomic context. The
caller has to take care of synchronization.

No functional changes. Just preparation for beacon updates from tasklet
context.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rt2x00/rt2x00lib.h
drivers/net/wireless/rt2x00/rt2x00queue.c

index 6c6a8f15870e1bf459513e652545729525915304..2d94cbaf5f4aac1c52f9049c70c6b5d06f88b899 100644 (file)
@@ -157,13 +157,23 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
                               bool local);
 
 /**
- * rt2x00queue_update_beacon - Send new beacon from mac80211 to hardware
+ * rt2x00queue_update_beacon - Send new beacon from mac80211
+ *     to hardware. Handles locking by itself (mutex).
  * @rt2x00dev: Pointer to &struct rt2x00_dev.
  * @vif: Interface for which the beacon should be updated.
  */
 int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
                              struct ieee80211_vif *vif);
 
+/**
+ * rt2x00queue_update_beacon_locked - Send new beacon from mac80211
+ *     to hardware. Caller needs to ensure locking.
+ * @rt2x00dev: Pointer to &struct rt2x00_dev.
+ * @vif: Interface for which the beacon should be updated.
+ */
+int rt2x00queue_update_beacon_locked(struct rt2x00_dev *rt2x00dev,
+                                    struct ieee80211_vif *vif);
+
 /**
  * rt2x00queue_clear_beacon - Clear beacon in hardware
  * @rt2x00dev: Pointer to &struct rt2x00_dev.
index 24bcdb47a46581fddc2c77cb35400f434725076e..7d7fbe0315af11ba08539518fc153fa4929521f1 100644 (file)
@@ -593,8 +593,8 @@ int rt2x00queue_clear_beacon(struct rt2x00_dev *rt2x00dev,
        return 0;
 }
 
-int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
-                             struct ieee80211_vif *vif)
+int rt2x00queue_update_beacon_locked(struct rt2x00_dev *rt2x00dev,
+                                    struct ieee80211_vif *vif)
 {
        struct rt2x00_intf *intf = vif_to_intf(vif);
        struct skb_frame_desc *skbdesc;
@@ -603,18 +603,14 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
        if (unlikely(!intf->beacon))
                return -ENOBUFS;
 
-       mutex_lock(&intf->beacon_skb_mutex);
-
        /*
         * Clean up the beacon skb.
         */
        rt2x00queue_free_skb(intf->beacon);
 
        intf->beacon->skb = ieee80211_beacon_get(rt2x00dev->hw, vif);
-       if (!intf->beacon->skb) {
-               mutex_unlock(&intf->beacon_skb_mutex);
+       if (!intf->beacon->skb)
                return -ENOMEM;
-       }
 
        /*
         * Copy all TX descriptor information into txdesc,
@@ -635,9 +631,21 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
         */
        rt2x00dev->ops->lib->write_beacon(intf->beacon, &txdesc);
 
+       return 0;
+
+}
+
+int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
+                             struct ieee80211_vif *vif)
+{
+       struct rt2x00_intf *intf = vif_to_intf(vif);
+       int ret;
+
+       mutex_lock(&intf->beacon_skb_mutex);
+       ret = rt2x00queue_update_beacon_locked(rt2x00dev, vif);
        mutex_unlock(&intf->beacon_skb_mutex);
 
-       return 0;
+       return ret;
 }
 
 void rt2x00queue_for_each_entry(struct data_queue *queue,