From: Christian Lamparter <chunkeey@web.de>
To: linux-wireless@vger.kernel.org
Cc: Larry Finger <Larry.Finger@lwfinger.net>,
Kalle Valo <kalle.valo@nokia.com>,
Johannes Berg <johannes@sipsolutions.net>,
John W Linville <linville@tuxdriver.com>
Subject: [RFC][PATCH 2/5] p54: refactor statistic timer code
Date: Sun, 5 Oct 2008 02:38:40 +0200 [thread overview]
Message-ID: <200810050238.41014.chunkeey@web.de> (raw)
---
diff -Nurp a/drivers/net/wireless/p54/p54common.c b/drivers/net/wireless/p54/p54common.c
--- a/drivers/net/wireless/p54/p54common.c 2008-10-05 01:46:00.000000000 +0200
+++ b/drivers/net/wireless/p54/p54common.c 2008-10-05 01:46:18.000000000 +0200
@@ -1103,19 +1103,32 @@ static int p54_set_vdcf(struct ieee80211
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;
- int err;
+ struct p54_control_hdr *hdr;
+ struct p54_statistics *stats;
- if (!priv->cached_stats) {
- priv->cached_stats = kzalloc(sizeof(struct p54_statistics) +
- priv->tx_hdr_len + sizeof(struct p54_control_hdr),
- GFP_KERNEL);
+ priv->cached_stats = kzalloc(priv->tx_hdr_len +
+ sizeof(*hdr) + sizeof(*stats), GFP_KERNEL);
- if (!priv->cached_stats)
+ if (!priv->cached_stats)
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);
if (!err)
@@ -1127,7 +1140,7 @@ static int p54_start(struct ieee80211_hw
P54_SET_QUEUE(priv->qos_params[3], 0x0007, 0x000f, 0x03ff, 0);
err = p54_set_vdcf(dev);
if (!err)
- mod_timer(&priv->stats_timer, jiffies + HZ);
+ err = p54_init_stats(dev);
return err;
}
@@ -1138,6 +1151,8 @@ static void p54_stop(struct ieee80211_hw
struct sk_buff *skb;
del_timer(&priv->stats_timer);
+ kfree(priv->cached_stats);
+ priv->cached_stats = NULL;
while ((skb = skb_dequeue(&priv->tx_queue)))
kfree_skb(skb);
priv->stop(dev);
@@ -1299,11 +1314,7 @@ static void p54_statistics_timer(unsigne
struct p54_statistics *stats;
BUG_ON(!priv->cached_stats);
-
- 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 = (void *) priv->cached_stats + priv->tx_hdr_len;
p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + sizeof(*stats));
priv->tx(dev, hdr, sizeof(*hdr) + sizeof(*stats), 0);
reply other threads:[~2008-10-05 0:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200810050238.41014.chunkeey@web.de \
--to=chunkeey@web.de \
--cc=Larry.Finger@lwfinger.net \
--cc=johannes@sipsolutions.net \
--cc=kalle.valo@nokia.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).