]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/mac80211/debugfs_sta.c
mac80211: refactor debugfs function generation code
[net-next-2.6.git] / net / mac80211 / debugfs_sta.c
index 6a8fdc372c43e2ff236da5423a58ab5f74dd8e8a..f0fce37f4069b06c7e92db28cf4e2e1dfee4c54d 100644 (file)
 
 /* sta attributtes */
 
-#define STA_READ(name, buflen, field, format_string)                   \
+#define STA_READ(name, field, format_string)                           \
 static ssize_t sta_ ##name## _read(struct file *file,                  \
                                   char __user *userbuf,                \
                                   size_t count, loff_t *ppos)          \
 {                                                                      \
-       int res;                                                        \
        struct sta_info *sta = file->private_data;                      \
-       char buf[buflen];                                               \
-       res = scnprintf(buf, buflen, format_string, sta->field);        \
-       return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
+       return mac80211_format_buffer(userbuf, count, ppos,             \
+                                     format_string, sta->field);       \
 }
-#define STA_READ_D(name, field) STA_READ(name, 20, field, "%d\n")
-#define STA_READ_U(name, field) STA_READ(name, 20, field, "%u\n")
-#define STA_READ_S(name, field) STA_READ(name, 20, field, "%s\n")
+#define STA_READ_D(name, field) STA_READ(name, field, "%d\n")
+#define STA_READ_U(name, field) STA_READ(name, field, "%u\n")
+#define STA_READ_S(name, field) STA_READ(name, field, "%s\n")
 
 #define STA_OPS(name)                                                  \
 static const struct file_operations sta_ ##name## _ops = {             \
@@ -79,22 +77,18 @@ static ssize_t sta_num_ps_buf_frames_read(struct file *file,
                                          char __user *userbuf,
                                          size_t count, loff_t *ppos)
 {
-       char buf[20];
        struct sta_info *sta = file->private_data;
-       int res = scnprintf(buf, sizeof(buf), "%u\n",
-                           skb_queue_len(&sta->ps_tx_buf));
-       return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+       return mac80211_format_buffer(userbuf, count, ppos, "%u\n",
+                                     skb_queue_len(&sta->ps_tx_buf));
 }
 STA_OPS(num_ps_buf_frames);
 
 static ssize_t sta_inactive_ms_read(struct file *file, char __user *userbuf,
                                    size_t count, loff_t *ppos)
 {
-       char buf[20];
        struct sta_info *sta = file->private_data;
-       int res = scnprintf(buf, sizeof(buf), "%d\n",
-                           jiffies_to_msecs(jiffies - sta->last_rx));
-       return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+       return mac80211_format_buffer(userbuf, count, ppos, "%d\n",
+                                     jiffies_to_msecs(jiffies - sta->last_rx));
 }
 STA_OPS(inactive_ms);
 
@@ -198,7 +192,8 @@ static ssize_t sta_agg_status_write(struct file *file, const char __user *userbu
                else
                        ret = ieee80211_stop_tx_ba_session(&sta->sta, tid);
        } else {
-               __ieee80211_stop_rx_ba_session(sta, tid, WLAN_BACK_RECIPIENT, 3);
+               __ieee80211_stop_rx_ba_session(sta, tid, WLAN_BACK_RECIPIENT,
+                                              3, true);
                ret = 0;
        }
 
@@ -302,7 +297,7 @@ STA_OPS(ht_capa);
 
 void ieee80211_sta_debugfs_add(struct sta_info *sta)
 {
-       struct dentry *stations_dir = sta->local->debugfs.stations;
+       struct dentry *stations_dir = sta->sdata->debugfs.subdir_stations;
        u8 mac[3*ETH_ALEN];
 
        sta->debugfs.add_has_run = true;