aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorChristian Lamparter <chunkeey@web.de>2008-10-14 21:56:20 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-10-31 19:00:32 -0400
commit0f1be978910092bed5d8dac0774e5cf85d4b4e12 (patch)
tree9f7f19b7a56dfefcca0f29a28371466dbd0ac025 /drivers
parent0fdd7c5d2defe8c6873eb8a40a880eb0dc59573d (diff)
p54: refactor statistic timer code
Signed-off-by: Christian Lamparter <chunkeey@web.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/p54/p54common.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/drivers/net/wireless/p54/p54common.c b/drivers/net/wireless/p54/p54common.c
index 7ddb93bb60a1..fcde424adb05 100644
--- a/drivers/net/wireless/p54/p54common.c
+++ b/drivers/net/wireless/p54/p54common.c
@@ -1151,19 +1151,32 @@ static int p54_set_edcf(struct ieee80211_hw *dev)
1151 return 0; 1151 return 0;
1152} 1152}
1153 1153
1154static int p54_start(struct ieee80211_hw *dev) 1154static int p54_init_stats(struct ieee80211_hw *dev)
1155{ 1155{
1156 struct p54_common *priv = dev->priv; 1156 struct p54_common *priv = dev->priv;
1157 int err; 1157 struct p54_control_hdr *hdr;
1158 struct p54_statistics *stats;
1158 1159
1159 if (!priv->cached_stats) { 1160 priv->cached_stats = kzalloc(priv->tx_hdr_len +
1160 priv->cached_stats = kzalloc(sizeof(struct p54_statistics) + 1161 sizeof(*hdr) + sizeof(*stats), GFP_KERNEL);
1161 priv->tx_hdr_len + sizeof(struct p54_control_hdr),
1162 GFP_KERNEL);
1163 1162
1164 if (!priv->cached_stats) 1163 if (!priv->cached_stats)
1165 return -ENOMEM; 1164 return -ENOMEM;
1166 } 1165
1166 hdr = (void *) priv->cached_stats + priv->tx_hdr_len;
1167 hdr->magic1 = cpu_to_le16(0x8000);
1168 hdr->len = cpu_to_le16(sizeof(*stats));
1169 hdr->type = cpu_to_le16(P54_CONTROL_TYPE_STAT_READBACK);
1170 hdr->retry1 = hdr->retry2 = 0;
1171
1172 mod_timer(&priv->stats_timer, jiffies + HZ);
1173 return 0;
1174}
1175
1176static int p54_start(struct ieee80211_hw *dev)
1177{
1178 struct p54_common *priv = dev->priv;
1179 int err;
1167 1180
1168 err = priv->open(dev); 1181 err = priv->open(dev);
1169 if (!err) 1182 if (!err)
@@ -1174,7 +1187,7 @@ static int p54_start(struct ieee80211_hw *dev)
1174 P54_SET_QUEUE(priv->qos_params[3], 0x0007, 0x000f, 0x03ff, 0); 1187 P54_SET_QUEUE(priv->qos_params[3], 0x0007, 0x000f, 0x03ff, 0);
1175 err = p54_set_edcf(dev); 1188 err = p54_set_edcf(dev);
1176 if (!err) 1189 if (!err)
1177 mod_timer(&priv->stats_timer, jiffies + HZ); 1190 err = p54_init_stats(dev);
1178 1191
1179 return err; 1192 return err;
1180} 1193}
@@ -1185,6 +1198,8 @@ static void p54_stop(struct ieee80211_hw *dev)
1185 struct sk_buff *skb; 1198 struct sk_buff *skb;
1186 1199
1187 del_timer(&priv->stats_timer); 1200 del_timer(&priv->stats_timer);
1201 kfree(priv->cached_stats);
1202 priv->cached_stats = NULL;
1188 while ((skb = skb_dequeue(&priv->tx_queue))) 1203 while ((skb = skb_dequeue(&priv->tx_queue)))
1189 kfree_skb(skb); 1204 kfree_skb(skb);
1190 priv->stop(dev); 1205 priv->stop(dev);
@@ -1346,11 +1361,7 @@ static void p54_statistics_timer(unsigned long data)
1346 struct p54_statistics *stats; 1361 struct p54_statistics *stats;
1347 1362
1348 BUG_ON(!priv->cached_stats); 1363 BUG_ON(!priv->cached_stats);
1349 1364 hdr = (void *) priv->cached_stats + priv->tx_hdr_len;
1350 hdr = (void *)priv->cached_stats + priv->tx_hdr_len;
1351 hdr->magic1 = cpu_to_le16(0x8000);
1352 hdr->len = cpu_to_le16(sizeof(*stats));
1353 hdr->type = cpu_to_le16(P54_CONTROL_TYPE_STAT_READBACK);
1354 p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + sizeof(*stats)); 1365 p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + sizeof(*stats));
1355 1366
1356 priv->tx(dev, hdr, sizeof(*hdr) + sizeof(*stats), 0); 1367 priv->tx(dev, hdr, sizeof(*hdr) + sizeof(*stats), 0);