diff options
author | Eliad Peller <eliad@wizery.com> | 2010-10-27 08:58:30 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-11-15 13:25:23 -0500 |
commit | 03107a4b5923aa7767329e857caf227749087e47 (patch) | |
tree | cb6cebf5c0052d85ed00f4abb76aca88a87dd933 /drivers | |
parent | 71125abdf0c297adc00dc5632f0318b2397286f5 (diff) |
wl1271: refactor debugfs function generation code
refactor wl1271_debugfs by using a format© function, instead of
duplicating the code for each generated function.
this change reduces about 3Kb from wl1271.ko
Signed-off-by: Eliad Peller <eliad@wizery.com>
Reviewed-by: Luciano Coelho <luciano.coelho@nokia.com>
Signed-off-by: Luciano Coelho <luciano.coelho@nokia.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_debugfs.c | 215 |
1 files changed, 111 insertions, 104 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_debugfs.c b/drivers/net/wireless/wl12xx/wl1271_debugfs.c index 66c2b90ddfd4..3468b849852e 100644 --- a/drivers/net/wireless/wl12xx/wl1271_debugfs.c +++ b/drivers/net/wireless/wl12xx/wl1271_debugfs.c | |||
@@ -35,17 +35,28 @@ | |||
35 | #define WL1271_DEBUGFS_STATS_LIFETIME 1000 | 35 | #define WL1271_DEBUGFS_STATS_LIFETIME 1000 |
36 | 36 | ||
37 | /* debugfs macros idea from mac80211 */ | 37 | /* debugfs macros idea from mac80211 */ |
38 | #define DEBUGFS_FORMAT_BUFFER_SIZE 100 | ||
39 | static int wl1271_format_buffer(char __user *userbuf, size_t count, | ||
40 | loff_t *ppos, char *fmt, ...) | ||
41 | { | ||
42 | va_list args; | ||
43 | char buf[DEBUGFS_FORMAT_BUFFER_SIZE]; | ||
44 | int res; | ||
38 | 45 | ||
39 | #define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \ | 46 | va_start(args, fmt); |
47 | res = vscnprintf(buf, sizeof(buf), fmt, args); | ||
48 | va_end(args); | ||
49 | |||
50 | return simple_read_from_buffer(userbuf, count, ppos, buf, res); | ||
51 | } | ||
52 | |||
53 | #define DEBUGFS_READONLY_FILE(name, fmt, value...) \ | ||
40 | static ssize_t name## _read(struct file *file, char __user *userbuf, \ | 54 | static ssize_t name## _read(struct file *file, char __user *userbuf, \ |
41 | size_t count, loff_t *ppos) \ | 55 | size_t count, loff_t *ppos) \ |
42 | { \ | 56 | { \ |
43 | struct wl1271 *wl = file->private_data; \ | 57 | struct wl1271 *wl = file->private_data; \ |
44 | char buf[buflen]; \ | 58 | return wl1271_format_buffer(userbuf, count, ppos, \ |
45 | int res; \ | 59 | fmt "\n", ##value); \ |
46 | \ | ||
47 | res = scnprintf(buf, buflen, fmt "\n", ##value); \ | ||
48 | return simple_read_from_buffer(userbuf, count, ppos, buf, res); \ | ||
49 | } \ | 60 | } \ |
50 | \ | 61 | \ |
51 | static const struct file_operations name## _ops = { \ | 62 | static const struct file_operations name## _ops = { \ |
@@ -69,20 +80,17 @@ static const struct file_operations name## _ops = { \ | |||
69 | wl->debugfs.name = NULL; \ | 80 | wl->debugfs.name = NULL; \ |
70 | } while (0) | 81 | } while (0) |
71 | 82 | ||
72 | #define DEBUGFS_FWSTATS_FILE(sub, name, buflen, fmt) \ | 83 | #define DEBUGFS_FWSTATS_FILE(sub, name, fmt) \ |
73 | static ssize_t sub## _ ##name## _read(struct file *file, \ | 84 | static ssize_t sub## _ ##name## _read(struct file *file, \ |
74 | char __user *userbuf, \ | 85 | char __user *userbuf, \ |
75 | size_t count, loff_t *ppos) \ | 86 | size_t count, loff_t *ppos) \ |
76 | { \ | 87 | { \ |
77 | struct wl1271 *wl = file->private_data; \ | 88 | struct wl1271 *wl = file->private_data; \ |
78 | char buf[buflen]; \ | ||
79 | int res; \ | ||
80 | \ | 89 | \ |
81 | wl1271_debugfs_update_stats(wl); \ | 90 | wl1271_debugfs_update_stats(wl); \ |
82 | \ | 91 | \ |
83 | res = scnprintf(buf, buflen, fmt "\n", \ | 92 | return wl1271_format_buffer(userbuf, count, ppos, fmt "\n", \ |
84 | wl->stats.fw_stats->sub.name); \ | 93 | wl->stats.fw_stats->sub.name); \ |
85 | return simple_read_from_buffer(userbuf, count, ppos, buf, res); \ | ||
86 | } \ | 94 | } \ |
87 | \ | 95 | \ |
88 | static const struct file_operations sub## _ ##name## _ops = { \ | 96 | static const struct file_operations sub## _ ##name## _ops = { \ |
@@ -126,100 +134,99 @@ static int wl1271_open_file_generic(struct inode *inode, struct file *file) | |||
126 | return 0; | 134 | return 0; |
127 | } | 135 | } |
128 | 136 | ||
129 | DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, 20, "%u"); | 137 | DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, "%u"); |
130 | 138 | ||
131 | DEBUGFS_FWSTATS_FILE(rx, out_of_mem, 20, "%u"); | 139 | DEBUGFS_FWSTATS_FILE(rx, out_of_mem, "%u"); |
132 | DEBUGFS_FWSTATS_FILE(rx, hdr_overflow, 20, "%u"); | 140 | DEBUGFS_FWSTATS_FILE(rx, hdr_overflow, "%u"); |
133 | DEBUGFS_FWSTATS_FILE(rx, hw_stuck, 20, "%u"); | 141 | DEBUGFS_FWSTATS_FILE(rx, hw_stuck, "%u"); |
134 | DEBUGFS_FWSTATS_FILE(rx, dropped, 20, "%u"); | 142 | DEBUGFS_FWSTATS_FILE(rx, dropped, "%u"); |
135 | DEBUGFS_FWSTATS_FILE(rx, fcs_err, 20, "%u"); | 143 | DEBUGFS_FWSTATS_FILE(rx, fcs_err, "%u"); |
136 | DEBUGFS_FWSTATS_FILE(rx, xfr_hint_trig, 20, "%u"); | 144 | DEBUGFS_FWSTATS_FILE(rx, xfr_hint_trig, "%u"); |
137 | DEBUGFS_FWSTATS_FILE(rx, path_reset, 20, "%u"); | 145 | DEBUGFS_FWSTATS_FILE(rx, path_reset, "%u"); |
138 | DEBUGFS_FWSTATS_FILE(rx, reset_counter, 20, "%u"); | 146 | DEBUGFS_FWSTATS_FILE(rx, reset_counter, "%u"); |
139 | 147 | ||
140 | DEBUGFS_FWSTATS_FILE(dma, rx_requested, 20, "%u"); | 148 | DEBUGFS_FWSTATS_FILE(dma, rx_requested, "%u"); |
141 | DEBUGFS_FWSTATS_FILE(dma, rx_errors, 20, "%u"); | 149 | DEBUGFS_FWSTATS_FILE(dma, rx_errors, "%u"); |
142 | DEBUGFS_FWSTATS_FILE(dma, tx_requested, 20, "%u"); | 150 | DEBUGFS_FWSTATS_FILE(dma, tx_requested, "%u"); |
143 | DEBUGFS_FWSTATS_FILE(dma, tx_errors, 20, "%u"); | 151 | DEBUGFS_FWSTATS_FILE(dma, tx_errors, "%u"); |
144 | 152 | ||
145 | DEBUGFS_FWSTATS_FILE(isr, cmd_cmplt, 20, "%u"); | 153 | DEBUGFS_FWSTATS_FILE(isr, cmd_cmplt, "%u"); |
146 | DEBUGFS_FWSTATS_FILE(isr, fiqs, 20, "%u"); | 154 | DEBUGFS_FWSTATS_FILE(isr, fiqs, "%u"); |
147 | DEBUGFS_FWSTATS_FILE(isr, rx_headers, 20, "%u"); | 155 | DEBUGFS_FWSTATS_FILE(isr, rx_headers, "%u"); |
148 | DEBUGFS_FWSTATS_FILE(isr, rx_mem_overflow, 20, "%u"); | 156 | DEBUGFS_FWSTATS_FILE(isr, rx_mem_overflow, "%u"); |
149 | DEBUGFS_FWSTATS_FILE(isr, rx_rdys, 20, "%u"); | 157 | DEBUGFS_FWSTATS_FILE(isr, rx_rdys, "%u"); |
150 | DEBUGFS_FWSTATS_FILE(isr, irqs, 20, "%u"); | 158 | DEBUGFS_FWSTATS_FILE(isr, irqs, "%u"); |
151 | DEBUGFS_FWSTATS_FILE(isr, tx_procs, 20, "%u"); | 159 | DEBUGFS_FWSTATS_FILE(isr, tx_procs, "%u"); |
152 | DEBUGFS_FWSTATS_FILE(isr, decrypt_done, 20, "%u"); | 160 | DEBUGFS_FWSTATS_FILE(isr, decrypt_done, "%u"); |
153 | DEBUGFS_FWSTATS_FILE(isr, dma0_done, 20, "%u"); | 161 | DEBUGFS_FWSTATS_FILE(isr, dma0_done, "%u"); |
154 | DEBUGFS_FWSTATS_FILE(isr, dma1_done, 20, "%u"); | 162 | DEBUGFS_FWSTATS_FILE(isr, dma1_done, "%u"); |
155 | DEBUGFS_FWSTATS_FILE(isr, tx_exch_complete, 20, "%u"); | 163 | DEBUGFS_FWSTATS_FILE(isr, tx_exch_complete, "%u"); |
156 | DEBUGFS_FWSTATS_FILE(isr, commands, 20, "%u"); | 164 | DEBUGFS_FWSTATS_FILE(isr, commands, "%u"); |
157 | DEBUGFS_FWSTATS_FILE(isr, rx_procs, 20, "%u"); | 165 | DEBUGFS_FWSTATS_FILE(isr, rx_procs, "%u"); |
158 | DEBUGFS_FWSTATS_FILE(isr, hw_pm_mode_changes, 20, "%u"); | 166 | DEBUGFS_FWSTATS_FILE(isr, hw_pm_mode_changes, "%u"); |
159 | DEBUGFS_FWSTATS_FILE(isr, host_acknowledges, 20, "%u"); | 167 | DEBUGFS_FWSTATS_FILE(isr, host_acknowledges, "%u"); |
160 | DEBUGFS_FWSTATS_FILE(isr, pci_pm, 20, "%u"); | 168 | DEBUGFS_FWSTATS_FILE(isr, pci_pm, "%u"); |
161 | DEBUGFS_FWSTATS_FILE(isr, wakeups, 20, "%u"); | 169 | DEBUGFS_FWSTATS_FILE(isr, wakeups, "%u"); |
162 | DEBUGFS_FWSTATS_FILE(isr, low_rssi, 20, "%u"); | 170 | DEBUGFS_FWSTATS_FILE(isr, low_rssi, "%u"); |
163 | 171 | ||
164 | DEBUGFS_FWSTATS_FILE(wep, addr_key_count, 20, "%u"); | 172 | DEBUGFS_FWSTATS_FILE(wep, addr_key_count, "%u"); |
165 | DEBUGFS_FWSTATS_FILE(wep, default_key_count, 20, "%u"); | 173 | DEBUGFS_FWSTATS_FILE(wep, default_key_count, "%u"); |
166 | /* skipping wep.reserved */ | 174 | /* skipping wep.reserved */ |
167 | DEBUGFS_FWSTATS_FILE(wep, key_not_found, 20, "%u"); | 175 | DEBUGFS_FWSTATS_FILE(wep, key_not_found, "%u"); |
168 | DEBUGFS_FWSTATS_FILE(wep, decrypt_fail, 20, "%u"); | 176 | DEBUGFS_FWSTATS_FILE(wep, decrypt_fail, "%u"); |
169 | DEBUGFS_FWSTATS_FILE(wep, packets, 20, "%u"); | 177 | DEBUGFS_FWSTATS_FILE(wep, packets, "%u"); |
170 | DEBUGFS_FWSTATS_FILE(wep, interrupt, 20, "%u"); | 178 | DEBUGFS_FWSTATS_FILE(wep, interrupt, "%u"); |
171 | 179 | ||
172 | DEBUGFS_FWSTATS_FILE(pwr, ps_enter, 20, "%u"); | 180 | DEBUGFS_FWSTATS_FILE(pwr, ps_enter, "%u"); |
173 | DEBUGFS_FWSTATS_FILE(pwr, elp_enter, 20, "%u"); | 181 | DEBUGFS_FWSTATS_FILE(pwr, elp_enter, "%u"); |
174 | DEBUGFS_FWSTATS_FILE(pwr, missing_bcns, 20, "%u"); | 182 | DEBUGFS_FWSTATS_FILE(pwr, missing_bcns, "%u"); |
175 | DEBUGFS_FWSTATS_FILE(pwr, wake_on_host, 20, "%u"); | 183 | DEBUGFS_FWSTATS_FILE(pwr, wake_on_host, "%u"); |
176 | DEBUGFS_FWSTATS_FILE(pwr, wake_on_timer_exp, 20, "%u"); | 184 | DEBUGFS_FWSTATS_FILE(pwr, wake_on_timer_exp, "%u"); |
177 | DEBUGFS_FWSTATS_FILE(pwr, tx_with_ps, 20, "%u"); | 185 | DEBUGFS_FWSTATS_FILE(pwr, tx_with_ps, "%u"); |
178 | DEBUGFS_FWSTATS_FILE(pwr, tx_without_ps, 20, "%u"); | 186 | DEBUGFS_FWSTATS_FILE(pwr, tx_without_ps, "%u"); |
179 | DEBUGFS_FWSTATS_FILE(pwr, rcvd_beacons, 20, "%u"); | 187 | DEBUGFS_FWSTATS_FILE(pwr, rcvd_beacons, "%u"); |
180 | DEBUGFS_FWSTATS_FILE(pwr, power_save_off, 20, "%u"); | 188 | DEBUGFS_FWSTATS_FILE(pwr, power_save_off, "%u"); |
181 | DEBUGFS_FWSTATS_FILE(pwr, enable_ps, 20, "%u"); | 189 | DEBUGFS_FWSTATS_FILE(pwr, enable_ps, "%u"); |
182 | DEBUGFS_FWSTATS_FILE(pwr, disable_ps, 20, "%u"); | 190 | DEBUGFS_FWSTATS_FILE(pwr, disable_ps, "%u"); |
183 | DEBUGFS_FWSTATS_FILE(pwr, fix_tsf_ps, 20, "%u"); | 191 | DEBUGFS_FWSTATS_FILE(pwr, fix_tsf_ps, "%u"); |
184 | /* skipping cont_miss_bcns_spread for now */ | 192 | /* skipping cont_miss_bcns_spread for now */ |
185 | DEBUGFS_FWSTATS_FILE(pwr, rcvd_awake_beacons, 20, "%u"); | 193 | DEBUGFS_FWSTATS_FILE(pwr, rcvd_awake_beacons, "%u"); |
186 | 194 | ||
187 | DEBUGFS_FWSTATS_FILE(mic, rx_pkts, 20, "%u"); | 195 | DEBUGFS_FWSTATS_FILE(mic, rx_pkts, "%u"); |
188 | DEBUGFS_FWSTATS_FILE(mic, calc_failure, 20, "%u"); | 196 | DEBUGFS_FWSTATS_FILE(mic, calc_failure, "%u"); |
189 | 197 | ||
190 | DEBUGFS_FWSTATS_FILE(aes, encrypt_fail, 20, "%u"); | 198 | DEBUGFS_FWSTATS_FILE(aes, encrypt_fail, "%u"); |
191 | DEBUGFS_FWSTATS_FILE(aes, decrypt_fail, 20, "%u"); | 199 | DEBUGFS_FWSTATS_FILE(aes, decrypt_fail, "%u"); |
192 | DEBUGFS_FWSTATS_FILE(aes, encrypt_packets, 20, "%u"); | 200 | DEBUGFS_FWSTATS_FILE(aes, encrypt_packets, "%u"); |
193 | DEBUGFS_FWSTATS_FILE(aes, decrypt_packets, 20, "%u"); | 201 | DEBUGFS_FWSTATS_FILE(aes, decrypt_packets, "%u"); |
194 | DEBUGFS_FWSTATS_FILE(aes, encrypt_interrupt, 20, "%u"); | 202 | DEBUGFS_FWSTATS_FILE(aes, encrypt_interrupt, "%u"); |
195 | DEBUGFS_FWSTATS_FILE(aes, decrypt_interrupt, 20, "%u"); | 203 | DEBUGFS_FWSTATS_FILE(aes, decrypt_interrupt, "%u"); |
196 | 204 | ||
197 | DEBUGFS_FWSTATS_FILE(event, heart_beat, 20, "%u"); | 205 | DEBUGFS_FWSTATS_FILE(event, heart_beat, "%u"); |
198 | DEBUGFS_FWSTATS_FILE(event, calibration, 20, "%u"); | 206 | DEBUGFS_FWSTATS_FILE(event, calibration, "%u"); |
199 | DEBUGFS_FWSTATS_FILE(event, rx_mismatch, 20, "%u"); | 207 | DEBUGFS_FWSTATS_FILE(event, rx_mismatch, "%u"); |
200 | DEBUGFS_FWSTATS_FILE(event, rx_mem_empty, 20, "%u"); | 208 | DEBUGFS_FWSTATS_FILE(event, rx_mem_empty, "%u"); |
201 | DEBUGFS_FWSTATS_FILE(event, rx_pool, 20, "%u"); | 209 | DEBUGFS_FWSTATS_FILE(event, rx_pool, "%u"); |
202 | DEBUGFS_FWSTATS_FILE(event, oom_late, 20, "%u"); | 210 | DEBUGFS_FWSTATS_FILE(event, oom_late, "%u"); |
203 | DEBUGFS_FWSTATS_FILE(event, phy_transmit_error, 20, "%u"); | 211 | DEBUGFS_FWSTATS_FILE(event, phy_transmit_error, "%u"); |
204 | DEBUGFS_FWSTATS_FILE(event, tx_stuck, 20, "%u"); | 212 | DEBUGFS_FWSTATS_FILE(event, tx_stuck, "%u"); |
205 | 213 | ||
206 | DEBUGFS_FWSTATS_FILE(ps, pspoll_timeouts, 20, "%u"); | 214 | DEBUGFS_FWSTATS_FILE(ps, pspoll_timeouts, "%u"); |
207 | DEBUGFS_FWSTATS_FILE(ps, upsd_timeouts, 20, "%u"); | 215 | DEBUGFS_FWSTATS_FILE(ps, upsd_timeouts, "%u"); |
208 | DEBUGFS_FWSTATS_FILE(ps, upsd_max_sptime, 20, "%u"); | 216 | DEBUGFS_FWSTATS_FILE(ps, upsd_max_sptime, "%u"); |
209 | DEBUGFS_FWSTATS_FILE(ps, upsd_max_apturn, 20, "%u"); | 217 | DEBUGFS_FWSTATS_FILE(ps, upsd_max_apturn, "%u"); |
210 | DEBUGFS_FWSTATS_FILE(ps, pspoll_max_apturn, 20, "%u"); | 218 | DEBUGFS_FWSTATS_FILE(ps, pspoll_max_apturn, "%u"); |
211 | DEBUGFS_FWSTATS_FILE(ps, pspoll_utilization, 20, "%u"); | 219 | DEBUGFS_FWSTATS_FILE(ps, pspoll_utilization, "%u"); |
212 | DEBUGFS_FWSTATS_FILE(ps, upsd_utilization, 20, "%u"); | 220 | DEBUGFS_FWSTATS_FILE(ps, upsd_utilization, "%u"); |
213 | 221 | ||
214 | DEBUGFS_FWSTATS_FILE(rxpipe, rx_prep_beacon_drop, 20, "%u"); | 222 | DEBUGFS_FWSTATS_FILE(rxpipe, rx_prep_beacon_drop, "%u"); |
215 | DEBUGFS_FWSTATS_FILE(rxpipe, descr_host_int_trig_rx_data, 20, "%u"); | 223 | DEBUGFS_FWSTATS_FILE(rxpipe, descr_host_int_trig_rx_data, "%u"); |
216 | DEBUGFS_FWSTATS_FILE(rxpipe, beacon_buffer_thres_host_int_trig_rx_data, | 224 | DEBUGFS_FWSTATS_FILE(rxpipe, beacon_buffer_thres_host_int_trig_rx_data, "%u"); |
217 | 20, "%u"); | 225 | DEBUGFS_FWSTATS_FILE(rxpipe, missed_beacon_host_int_trig_rx_data, "%u"); |
218 | DEBUGFS_FWSTATS_FILE(rxpipe, missed_beacon_host_int_trig_rx_data, 20, "%u"); | 226 | DEBUGFS_FWSTATS_FILE(rxpipe, tx_xfr_host_int_trig_rx_data, "%u"); |
219 | DEBUGFS_FWSTATS_FILE(rxpipe, tx_xfr_host_int_trig_rx_data, 20, "%u"); | 227 | |
220 | 228 | DEBUGFS_READONLY_FILE(retry_count, "%u", wl->stats.retry_count); | |
221 | DEBUGFS_READONLY_FILE(retry_count, 20, "%u", wl->stats.retry_count); | 229 | DEBUGFS_READONLY_FILE(excessive_retries, "%u", |
222 | DEBUGFS_READONLY_FILE(excessive_retries, 20, "%u", | ||
223 | wl->stats.excessive_retries); | 230 | wl->stats.excessive_retries); |
224 | 231 | ||
225 | static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf, | 232 | static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf, |