Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelv...
[deliverable/linux.git] / drivers / net / wireless / p54 / p54common.c
index 71394968d4504a609f93e171cb69faa1b025135a..b618bd14583f9489143de1e1654dad3a290c2598 100644 (file)
@@ -822,44 +822,37 @@ void p54_free_skb(struct ieee80211_hw *dev, struct sk_buff *skb)
        struct ieee80211_tx_info *info;
        struct p54_tx_info *range;
        unsigned long flags;
-       u32 freed = 0, last_addr = priv->rx_start;
 
-       if (unlikely(!skb || !dev || !skb_queue_len(&priv->tx_queue)))
+       if (unlikely(!skb || !dev || skb_queue_empty(&priv->tx_queue)))
                return;
 
-       /*
-        * don't try to free an already unlinked skb
+       /* There used to be a check here to see if the SKB was on the
+        * TX queue or not.  This can never happen because all SKBs we
+        * see here successfully went through p54_assign_address()
+        * which means the SKB is on the ->tx_queue.
         */
-       if (unlikely((!skb->next) || (!skb->prev)))
-               return;
 
        spin_lock_irqsave(&priv->tx_queue.lock, flags);
        info = IEEE80211_SKB_CB(skb);
        range = (void *)info->rate_driver_data;
-       if (skb->prev != (struct sk_buff *)&priv->tx_queue) {
+       if (!skb_queue_is_first(&priv->tx_queue, skb)) {
                struct ieee80211_tx_info *ni;
                struct p54_tx_info *mr;
 
-               ni = IEEE80211_SKB_CB(skb->prev);
+               ni = IEEE80211_SKB_CB(skb_queue_prev(&priv->tx_queue, skb));
                mr = (struct p54_tx_info *)ni->rate_driver_data;
-               last_addr = mr->end_addr;
        }
-       if (skb->next != (struct sk_buff *)&priv->tx_queue) {
+       if (!skb_queue_is_last(&priv->tx_queue, skb)) {
                struct ieee80211_tx_info *ni;
                struct p54_tx_info *mr;
 
-               ni = IEEE80211_SKB_CB(skb->next);
+               ni = IEEE80211_SKB_CB(skb_queue_next(&priv->tx_queue, skb));
                mr = (struct p54_tx_info *)ni->rate_driver_data;
-               freed = mr->start_addr - last_addr;
-       } else
-               freed = priv->rx_end - last_addr;
+       }
        __skb_unlink(skb, &priv->tx_queue);
        spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
        dev_kfree_skb_any(skb);
-
-       if (freed >= priv->headroom + sizeof(struct p54_hdr) + 48 +
-                    IEEE80211_MAX_RTS_THRESHOLD + priv->tailroom)
-               p54_wake_free_queues(dev);
+       p54_wake_free_queues(dev);
 }
 EXPORT_SYMBOL_GPL(p54_free_skb);
 
@@ -871,15 +864,13 @@ static struct sk_buff *p54_find_tx_entry(struct ieee80211_hw *dev,
        unsigned long flags;
 
        spin_lock_irqsave(&priv->tx_queue.lock, flags);
-       entry = priv->tx_queue.next;
-       while (entry != (struct sk_buff *)&priv->tx_queue) {
+       skb_queue_walk(&priv->tx_queue, entry) {
                struct p54_hdr *hdr = (struct p54_hdr *) entry->data;
 
                if (hdr->req_id == req_id) {
                        spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
                        return entry;
                }
-               entry = entry->next;
        }
        spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
        return NULL;
@@ -893,37 +884,29 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb)
        struct sk_buff *entry;
        u32 addr = le32_to_cpu(hdr->req_id) - priv->headroom;
        struct p54_tx_info *range = NULL;
-       u32 freed = 0;
-       u32 last_addr = priv->rx_start;
        unsigned long flags;
        int count, idx;
 
        spin_lock_irqsave(&priv->tx_queue.lock, flags);
-       entry = (struct sk_buff *) priv->tx_queue.next;
-       while (entry != (struct sk_buff *)&priv->tx_queue) {
+       skb_queue_walk(&priv->tx_queue, entry) {
                struct ieee80211_tx_info *info = IEEE80211_SKB_CB(entry);
                struct p54_hdr *entry_hdr;
                struct p54_tx_data *entry_data;
                unsigned int pad = 0, frame_len;
 
                range = (void *)info->rate_driver_data;
-               if (range->start_addr != addr) {
-                       last_addr = range->end_addr;
-                       entry = entry->next;
+               if (range->start_addr != addr)
                        continue;
-               }
 
-               if (entry->next != (struct sk_buff *)&priv->tx_queue) {
+               if (!skb_queue_is_last(&priv->tx_queue, entry)) {
                        struct ieee80211_tx_info *ni;
                        struct p54_tx_info *mr;
 
-                       ni = IEEE80211_SKB_CB(entry->next);
+                       ni = IEEE80211_SKB_CB(skb_queue_next(&priv->tx_queue,
+                                                            entry));
                        mr = (struct p54_tx_info *)ni->rate_driver_data;
-                       freed = mr->start_addr - last_addr;
-               } else
-                       freed = priv->rx_end - last_addr;
+               }
 
-               last_addr = range->end_addr;
                __skb_unlink(entry, &priv->tx_queue);
                spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
 
@@ -1010,9 +993,7 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb)
        spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
 
 out:
-       if (freed >= priv->headroom + sizeof(struct p54_hdr) + 48 +
-                    IEEE80211_MAX_RTS_THRESHOLD + priv->tailroom)
-               p54_wake_free_queues(dev);
+       p54_wake_free_queues(dev);
 }
 
 static void p54_rx_eeprom_readback(struct ieee80211_hw *dev,
@@ -1183,23 +1164,21 @@ static int p54_assign_address(struct ieee80211_hw *dev, struct sk_buff *skb,
                }
        }
 
-       entry = priv->tx_queue.next;
-       while (left--) {
+       skb_queue_walk(&priv->tx_queue, entry) {
                u32 hole_size;
                info = IEEE80211_SKB_CB(entry);
                range = (void *)info->rate_driver_data;
                hole_size = range->start_addr - last_addr;
                if (!target_skb && hole_size >= len) {
-                       target_skb = entry->prev;
+                       target_skb = skb_queue_prev(&priv->tx_queue, entry);
                        hole_size -= len;
                        target_addr = last_addr;
                }
                largest_hole = max(largest_hole, hole_size);
                last_addr = range->end_addr;
-               entry = entry->next;
        }
        if (!target_skb && priv->rx_end - last_addr >= len) {
-               target_skb = priv->tx_queue.prev;
+               target_skb = skb_peek_tail(&priv->tx_queue);
                largest_hole = max(largest_hole, priv->rx_end - last_addr - len);
                if (!skb_queue_empty(&priv->tx_queue)) {
                        info = IEEE80211_SKB_CB(target_skb);
@@ -2105,7 +2084,6 @@ out:
 static void p54_stop(struct ieee80211_hw *dev)
 {
        struct p54_common *priv = dev->priv;
-       struct sk_buff *skb;
 
        mutex_lock(&priv->conf_mutex);
        priv->mode = NL80211_IFTYPE_UNSPECIFIED;
@@ -2120,8 +2098,7 @@ static void p54_stop(struct ieee80211_hw *dev)
                p54_tx_cancel(dev, priv->cached_beacon);
 
        priv->stop(dev);
-       while ((skb = skb_dequeue(&priv->tx_queue)))
-               kfree_skb(skb);
+       skb_queue_purge(&priv->tx_queue);
        priv->cached_beacon = NULL;
        priv->tsf_high32 = priv->tsf_low32 = 0;
        mutex_unlock(&priv->conf_mutex);
@@ -2204,41 +2181,6 @@ out:
        return ret;
 }
 
-static int p54_config_interface(struct ieee80211_hw *dev,
-                               struct ieee80211_vif *vif,
-                               struct ieee80211_if_conf *conf)
-{
-       struct p54_common *priv = dev->priv;
-       int ret = 0;
-
-       mutex_lock(&priv->conf_mutex);
-       if (conf->changed & IEEE80211_IFCC_BSSID) {
-               memcpy(priv->bssid, conf->bssid, ETH_ALEN);
-               ret = p54_setup_mac(dev);
-               if (ret)
-                       goto out;
-       }
-
-       if (conf->changed & IEEE80211_IFCC_BEACON) {
-               ret = p54_scan(dev, P54_SCAN_EXIT, 0);
-               if (ret)
-                       goto out;
-               ret = p54_setup_mac(dev);
-               if (ret)
-                       goto out;
-               ret = p54_beacon_update(dev, vif);
-               if (ret)
-                       goto out;
-               ret = p54_set_edcf(dev);
-               if (ret)
-                       goto out;
-       }
-
-out:
-       mutex_unlock(&priv->conf_mutex);
-       return ret;
-}
-
 static void p54_configure_filter(struct ieee80211_hw *dev,
                                 unsigned int changed_flags,
                                 unsigned int *total_flags,
@@ -2342,8 +2284,32 @@ static void p54_bss_info_changed(struct ieee80211_hw *dev,
                                 u32 changed)
 {
        struct p54_common *priv = dev->priv;
+       int ret;
+
+       mutex_lock(&priv->conf_mutex);
+       if (changed & BSS_CHANGED_BSSID) {
+               memcpy(priv->bssid, info->bssid, ETH_ALEN);
+               ret = p54_setup_mac(dev);
+               if (ret)
+                       goto out;
+       }
 
-       if (changed & BSS_CHANGED_ERP_SLOT) {
+       if (changed & BSS_CHANGED_BEACON) {
+               ret = p54_scan(dev, P54_SCAN_EXIT, 0);
+               if (ret)
+                       goto out;
+               ret = p54_setup_mac(dev);
+               if (ret)
+                       goto out;
+               ret = p54_beacon_update(dev, vif);
+               if (ret)
+                       goto out;
+       }
+       /* XXX: this mimics having two callbacks... clean up */
+ out:
+       mutex_unlock(&priv->conf_mutex);
+
+       if (changed & (BSS_CHANGED_ERP_SLOT | BSS_CHANGED_BEACON)) {
                priv->use_short_slot = info->use_short_slot;
                p54_set_edcf(dev);
        }
@@ -2364,7 +2330,6 @@ static void p54_bss_info_changed(struct ieee80211_hw *dev,
                        p54_setup_mac(dev);
                }
        }
-
 }
 
 static int p54_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd,
@@ -2619,7 +2584,6 @@ static const struct ieee80211_ops p54_ops = {
        .sta_notify             = p54_sta_notify,
        .set_key                = p54_set_key,
        .config                 = p54_config,
-       .config_interface       = p54_config_interface,
        .bss_info_changed       = p54_bss_info_changed,
        .configure_filter       = p54_configure_filter,
        .conf_tx                = p54_conf_tx,
This page took 0.033936 seconds and 5 git commands to generate.