Commit 0f1be978 authored by Christian Lamparter's avatar Christian Lamparter Committed by John W. Linville

p54: refactor statistic timer code

Signed-off-by: default avatarChristian Lamparter <chunkeey@web.de>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 0fdd7c5d
...@@ -1151,19 +1151,32 @@ static int p54_set_edcf(struct ieee80211_hw *dev) ...@@ -1151,19 +1151,32 @@ static int p54_set_edcf(struct ieee80211_hw *dev)
return 0; return 0;
} }
static int p54_start(struct ieee80211_hw *dev) static int p54_init_stats(struct ieee80211_hw *dev)
{ {
struct p54_common *priv = dev->priv; struct p54_common *priv = dev->priv;
int err; struct p54_control_hdr *hdr;
struct p54_statistics *stats;
if (!priv->cached_stats) { priv->cached_stats = kzalloc(priv->tx_hdr_len +
priv->cached_stats = kzalloc(sizeof(struct p54_statistics) + sizeof(*hdr) + sizeof(*stats), GFP_KERNEL);
priv->tx_hdr_len + sizeof(struct p54_control_hdr),
GFP_KERNEL);
if (!priv->cached_stats) if (!priv->cached_stats)
return -ENOMEM; return -ENOMEM;
}
hdr = (void *) priv->cached_stats + priv->tx_hdr_len;
hdr->magic1 = cpu_to_le16(0x8000);
hdr->len = cpu_to_le16(sizeof(*stats));
hdr->type = cpu_to_le16(P54_CONTROL_TYPE_STAT_READBACK);
hdr->retry1 = hdr->retry2 = 0;
mod_timer(&priv->stats_timer, jiffies + HZ);
return 0;
}
static int p54_start(struct ieee80211_hw *dev)
{
struct p54_common *priv = dev->priv;
int err;
err = priv->open(dev); err = priv->open(dev);
if (!err) if (!err)
...@@ -1174,7 +1187,7 @@ static int p54_start(struct ieee80211_hw *dev) ...@@ -1174,7 +1187,7 @@ static int p54_start(struct ieee80211_hw *dev)
P54_SET_QUEUE(priv->qos_params[3], 0x0007, 0x000f, 0x03ff, 0); P54_SET_QUEUE(priv->qos_params[3], 0x0007, 0x000f, 0x03ff, 0);
err = p54_set_edcf(dev); err = p54_set_edcf(dev);
if (!err) if (!err)
mod_timer(&priv->stats_timer, jiffies + HZ); err = p54_init_stats(dev);
return err; return err;
} }
...@@ -1185,6 +1198,8 @@ static void p54_stop(struct ieee80211_hw *dev) ...@@ -1185,6 +1198,8 @@ static void p54_stop(struct ieee80211_hw *dev)
struct sk_buff *skb; struct sk_buff *skb;
del_timer(&priv->stats_timer); del_timer(&priv->stats_timer);
kfree(priv->cached_stats);
priv->cached_stats = NULL;
while ((skb = skb_dequeue(&priv->tx_queue))) while ((skb = skb_dequeue(&priv->tx_queue)))
kfree_skb(skb); kfree_skb(skb);
priv->stop(dev); priv->stop(dev);
...@@ -1346,11 +1361,7 @@ static void p54_statistics_timer(unsigned long data) ...@@ -1346,11 +1361,7 @@ static void p54_statistics_timer(unsigned long data)
struct p54_statistics *stats; struct p54_statistics *stats;
BUG_ON(!priv->cached_stats); BUG_ON(!priv->cached_stats);
hdr = (void *) priv->cached_stats + priv->tx_hdr_len;
hdr = (void *)priv->cached_stats + priv->tx_hdr_len;
hdr->magic1 = cpu_to_le16(0x8000);
hdr->len = cpu_to_le16(sizeof(*stats));
hdr->type = cpu_to_le16(P54_CONTROL_TYPE_STAT_READBACK);
p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + sizeof(*stats)); p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + sizeof(*stats));
priv->tx(dev, hdr, sizeof(*hdr) + sizeof(*stats), 0); priv->tx(dev, hdr, sizeof(*hdr) + sizeof(*stats), 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment