aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/p54
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2009-05-28 03:48:16 -0400
committerDavid S. Miller <davem@davemloft.net>2009-05-28 03:48:16 -0400
commita1091aae19b1d9c85d91c86915a611387f67a26b (patch)
treea8f76e0b2346565da54acacc2a91aa8300de2289 /drivers/net/wireless/p54
parentae71fabbe55552afc01f2bc797bee6838db22485 (diff)
p54: Use SKB list handling helpers instead of by-hand code.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/wireless/p54')
-rw-r--r--drivers/net/wireless/p54/p54common.c46
1 files changed, 19 insertions, 27 deletions
diff --git a/drivers/net/wireless/p54/p54common.c b/drivers/net/wireless/p54/p54common.c
index 48d81d98e12d..b618bd14583f 100644
--- a/drivers/net/wireless/p54/p54common.c
+++ b/drivers/net/wireless/p54/p54common.c
@@ -823,30 +823,30 @@ void p54_free_skb(struct ieee80211_hw *dev, struct sk_buff *skb)
823 struct p54_tx_info *range; 823 struct p54_tx_info *range;
824 unsigned long flags; 824 unsigned long flags;
825 825
826 if (unlikely(!skb || !dev || !skb_queue_len(&priv->tx_queue))) 826 if (unlikely(!skb || !dev || skb_queue_empty(&priv->tx_queue)))
827 return; 827 return;
828 828
829 /* 829 /* There used to be a check here to see if the SKB was on the
830 * don't try to free an already unlinked skb 830 * TX queue or not. This can never happen because all SKBs we
831 * see here successfully went through p54_assign_address()
832 * which means the SKB is on the ->tx_queue.
831 */ 833 */
832 if (unlikely((!skb->next) || (!skb->prev)))
833 return;
834 834
835 spin_lock_irqsave(&priv->tx_queue.lock, flags); 835 spin_lock_irqsave(&priv->tx_queue.lock, flags);
836 info = IEEE80211_SKB_CB(skb); 836 info = IEEE80211_SKB_CB(skb);
837 range = (void *)info->rate_driver_data; 837 range = (void *)info->rate_driver_data;
838 if (skb->prev != (struct sk_buff *)&priv->tx_queue) { 838 if (!skb_queue_is_first(&priv->tx_queue, skb)) {
839 struct ieee80211_tx_info *ni; 839 struct ieee80211_tx_info *ni;
840 struct p54_tx_info *mr; 840 struct p54_tx_info *mr;
841 841
842 ni = IEEE80211_SKB_CB(skb->prev); 842 ni = IEEE80211_SKB_CB(skb_queue_prev(&priv->tx_queue, skb));
843 mr = (struct p54_tx_info *)ni->rate_driver_data; 843 mr = (struct p54_tx_info *)ni->rate_driver_data;
844 } 844 }
845 if (skb->next != (struct sk_buff *)&priv->tx_queue) { 845 if (!skb_queue_is_last(&priv->tx_queue, skb)) {
846 struct ieee80211_tx_info *ni; 846 struct ieee80211_tx_info *ni;
847 struct p54_tx_info *mr; 847 struct p54_tx_info *mr;
848 848
849 ni = IEEE80211_SKB_CB(skb->next); 849 ni = IEEE80211_SKB_CB(skb_queue_next(&priv->tx_queue, skb));
850 mr = (struct p54_tx_info *)ni->rate_driver_data; 850 mr = (struct p54_tx_info *)ni->rate_driver_data;
851 } 851 }
852 __skb_unlink(skb, &priv->tx_queue); 852 __skb_unlink(skb, &priv->tx_queue);
@@ -864,15 +864,13 @@ static struct sk_buff *p54_find_tx_entry(struct ieee80211_hw *dev,
864 unsigned long flags; 864 unsigned long flags;
865 865
866 spin_lock_irqsave(&priv->tx_queue.lock, flags); 866 spin_lock_irqsave(&priv->tx_queue.lock, flags);
867 entry = priv->tx_queue.next; 867 skb_queue_walk(&priv->tx_queue, entry) {
868 while (entry != (struct sk_buff *)&priv->tx_queue) {
869 struct p54_hdr *hdr = (struct p54_hdr *) entry->data; 868 struct p54_hdr *hdr = (struct p54_hdr *) entry->data;
870 869
871 if (hdr->req_id == req_id) { 870 if (hdr->req_id == req_id) {
872 spin_unlock_irqrestore(&priv->tx_queue.lock, flags); 871 spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
873 return entry; 872 return entry;
874 } 873 }
875 entry = entry->next;
876 } 874 }
877 spin_unlock_irqrestore(&priv->tx_queue.lock, flags); 875 spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
878 return NULL; 876 return NULL;
@@ -890,24 +888,22 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb)
890 int count, idx; 888 int count, idx;
891 889
892 spin_lock_irqsave(&priv->tx_queue.lock, flags); 890 spin_lock_irqsave(&priv->tx_queue.lock, flags);
893 entry = (struct sk_buff *) priv->tx_queue.next; 891 skb_queue_walk(&priv->tx_queue, entry) {
894 while (entry != (struct sk_buff *)&priv->tx_queue) {
895 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(entry); 892 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(entry);
896 struct p54_hdr *entry_hdr; 893 struct p54_hdr *entry_hdr;
897 struct p54_tx_data *entry_data; 894 struct p54_tx_data *entry_data;
898 unsigned int pad = 0, frame_len; 895 unsigned int pad = 0, frame_len;
899 896
900 range = (void *)info->rate_driver_data; 897 range = (void *)info->rate_driver_data;
901 if (range->start_addr != addr) { 898 if (range->start_addr != addr)
902 entry = entry->next;
903 continue; 899 continue;
904 }
905 900
906 if (entry->next != (struct sk_buff *)&priv->tx_queue) { 901 if (!skb_queue_is_last(&priv->tx_queue, entry)) {
907 struct ieee80211_tx_info *ni; 902 struct ieee80211_tx_info *ni;
908 struct p54_tx_info *mr; 903 struct p54_tx_info *mr;
909 904
910 ni = IEEE80211_SKB_CB(entry->next); 905 ni = IEEE80211_SKB_CB(skb_queue_next(&priv->tx_queue,
906 entry));
911 mr = (struct p54_tx_info *)ni->rate_driver_data; 907 mr = (struct p54_tx_info *)ni->rate_driver_data;
912 } 908 }
913 909
@@ -1168,23 +1164,21 @@ static int p54_assign_address(struct ieee80211_hw *dev, struct sk_buff *skb,
1168 } 1164 }
1169 } 1165 }
1170 1166
1171 entry = priv->tx_queue.next; 1167 skb_queue_walk(&priv->tx_queue, entry) {
1172 while (left--) {
1173 u32 hole_size; 1168 u32 hole_size;
1174 info = IEEE80211_SKB_CB(entry); 1169 info = IEEE80211_SKB_CB(entry);
1175 range = (void *)info->rate_driver_data; 1170 range = (void *)info->rate_driver_data;
1176 hole_size = range->start_addr - last_addr; 1171 hole_size = range->start_addr - last_addr;
1177 if (!target_skb && hole_size >= len) { 1172 if (!target_skb && hole_size >= len) {
1178 target_skb = entry->prev; 1173 target_skb = skb_queue_prev(&priv->tx_queue, entry);
1179 hole_size -= len; 1174 hole_size -= len;
1180 target_addr = last_addr; 1175 target_addr = last_addr;
1181 } 1176 }
1182 largest_hole = max(largest_hole, hole_size); 1177 largest_hole = max(largest_hole, hole_size);
1183 last_addr = range->end_addr; 1178 last_addr = range->end_addr;
1184 entry = entry->next;
1185 } 1179 }
1186 if (!target_skb && priv->rx_end - last_addr >= len) { 1180 if (!target_skb && priv->rx_end - last_addr >= len) {
1187 target_skb = priv->tx_queue.prev; 1181 target_skb = skb_peek_tail(&priv->tx_queue);
1188 largest_hole = max(largest_hole, priv->rx_end - last_addr - len); 1182 largest_hole = max(largest_hole, priv->rx_end - last_addr - len);
1189 if (!skb_queue_empty(&priv->tx_queue)) { 1183 if (!skb_queue_empty(&priv->tx_queue)) {
1190 info = IEEE80211_SKB_CB(target_skb); 1184 info = IEEE80211_SKB_CB(target_skb);
@@ -2090,7 +2084,6 @@ out:
2090static void p54_stop(struct ieee80211_hw *dev) 2084static void p54_stop(struct ieee80211_hw *dev)
2091{ 2085{
2092 struct p54_common *priv = dev->priv; 2086 struct p54_common *priv = dev->priv;
2093 struct sk_buff *skb;
2094 2087
2095 mutex_lock(&priv->conf_mutex); 2088 mutex_lock(&priv->conf_mutex);
2096 priv->mode = NL80211_IFTYPE_UNSPECIFIED; 2089 priv->mode = NL80211_IFTYPE_UNSPECIFIED;
@@ -2105,8 +2098,7 @@ static void p54_stop(struct ieee80211_hw *dev)
2105 p54_tx_cancel(dev, priv->cached_beacon); 2098 p54_tx_cancel(dev, priv->cached_beacon);
2106 2099
2107 priv->stop(dev); 2100 priv->stop(dev);
2108 while ((skb = skb_dequeue(&priv->tx_queue))) 2101 skb_queue_purge(&priv->tx_queue);
2109 kfree_skb(skb);
2110 priv->cached_beacon = NULL; 2102 priv->cached_beacon = NULL;
2111 priv->tsf_high32 = priv->tsf_low32 = 0; 2103 priv->tsf_high32 = priv->tsf_low32 = 0;
2112 mutex_unlock(&priv->conf_mutex); 2104 mutex_unlock(&priv->conf_mutex);