aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/hostap/hostap_proc.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2013-04-10 16:13:23 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-04-29 15:41:56 -0400
commit6bbefe86796c07fb8a6d28114f1e3f770586ba05 (patch)
tree9420dda4c0366785b1eb8efc0d2c8df2ee1e1910 /drivers/net/wireless/hostap/hostap_proc.c
parent4c4df9b91bf6ffd4bb01abe4cfba1f8f145878a0 (diff)
hostap: Don't use create_proc_read_entry()
Don't use create_proc_read_entry() as that is deprecated, but rather use proc_create_data() and seq_file instead. Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> cc: Jouni Malinen <j@w1.fi> cc: John W. Linville <linville@tuxdriver.com> cc: Johannes Berg <johannes@sipsolutions.net> cc: linux-wireless@vger.kernel.org cc: netdev@vger.kernel.org cc: devel@driverdev.osuosl.org Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/net/wireless/hostap/hostap_proc.c')
-rw-r--r--drivers/net/wireless/hostap/hostap_proc.c589
1 files changed, 327 insertions, 262 deletions
diff --git a/drivers/net/wireless/hostap/hostap_proc.c b/drivers/net/wireless/hostap/hostap_proc.c
index dc447c1b5abe..89292cffa764 100644
--- a/drivers/net/wireless/hostap/hostap_proc.c
+++ b/drivers/net/wireless/hostap/hostap_proc.c
@@ -12,259 +12,297 @@
12 12
13 13
14#ifndef PRISM2_NO_PROCFS_DEBUG 14#ifndef PRISM2_NO_PROCFS_DEBUG
15static int prism2_debug_proc_read(char *page, char **start, off_t off, 15static int prism2_debug_proc_show(struct seq_file *m, void *v)
16 int count, int *eof, void *data)
17{ 16{
18 char *p = page; 17 local_info_t *local = m->private;
19 local_info_t *local = (local_info_t *) data;
20 int i; 18 int i;
21 19
22 if (off != 0) { 20 seq_printf(m, "next_txfid=%d next_alloc=%d\n",
23 *eof = 1; 21 local->next_txfid, local->next_alloc);
24 return 0;
25 }
26
27 p += sprintf(p, "next_txfid=%d next_alloc=%d\n",
28 local->next_txfid, local->next_alloc);
29 for (i = 0; i < PRISM2_TXFID_COUNT; i++) 22 for (i = 0; i < PRISM2_TXFID_COUNT; i++)
30 p += sprintf(p, "FID: tx=%04X intransmit=%04X\n", 23 seq_printf(m, "FID: tx=%04X intransmit=%04X\n",
31 local->txfid[i], local->intransmitfid[i]); 24 local->txfid[i], local->intransmitfid[i]);
32 p += sprintf(p, "FW TX rate control: %d\n", local->fw_tx_rate_control); 25 seq_printf(m, "FW TX rate control: %d\n", local->fw_tx_rate_control);
33 p += sprintf(p, "beacon_int=%d\n", local->beacon_int); 26 seq_printf(m, "beacon_int=%d\n", local->beacon_int);
34 p += sprintf(p, "dtim_period=%d\n", local->dtim_period); 27 seq_printf(m, "dtim_period=%d\n", local->dtim_period);
35 p += sprintf(p, "wds_max_connections=%d\n", 28 seq_printf(m, "wds_max_connections=%d\n", local->wds_max_connections);
36 local->wds_max_connections); 29 seq_printf(m, "dev_enabled=%d\n", local->dev_enabled);
37 p += sprintf(p, "dev_enabled=%d\n", local->dev_enabled); 30 seq_printf(m, "sw_tick_stuck=%d\n", local->sw_tick_stuck);
38 p += sprintf(p, "sw_tick_stuck=%d\n", local->sw_tick_stuck);
39 for (i = 0; i < WEP_KEYS; i++) { 31 for (i = 0; i < WEP_KEYS; i++) {
40 if (local->crypt_info.crypt[i] && 32 if (local->crypt_info.crypt[i] &&
41 local->crypt_info.crypt[i]->ops) { 33 local->crypt_info.crypt[i]->ops) {
42 p += sprintf(p, "crypt[%d]=%s\n", i, 34 seq_printf(m, "crypt[%d]=%s\n", i,
43 local->crypt_info.crypt[i]->ops->name); 35 local->crypt_info.crypt[i]->ops->name);
44 } 36 }
45 } 37 }
46 p += sprintf(p, "pri_only=%d\n", local->pri_only); 38 seq_printf(m, "pri_only=%d\n", local->pri_only);
47 p += sprintf(p, "pci=%d\n", local->func->hw_type == HOSTAP_HW_PCI); 39 seq_printf(m, "pci=%d\n", local->func->hw_type == HOSTAP_HW_PCI);
48 p += sprintf(p, "sram_type=%d\n", local->sram_type); 40 seq_printf(m, "sram_type=%d\n", local->sram_type);
49 p += sprintf(p, "no_pri=%d\n", local->no_pri); 41 seq_printf(m, "no_pri=%d\n", local->no_pri);
42
43 return 0;
44}
50 45
51 return (p - page); 46static int prism2_debug_proc_open(struct inode *inode, struct file *file)
47{
48 return single_open(file, prism2_debug_proc_show, PDE_DATA(inode));
52} 49}
50
51static const struct file_operations prism2_debug_proc_fops = {
52 .open = prism2_debug_proc_open,
53 .read = seq_read,
54 .llseek = seq_lseek,
55 .release = seq_release,
56};
53#endif /* PRISM2_NO_PROCFS_DEBUG */ 57#endif /* PRISM2_NO_PROCFS_DEBUG */
54 58
55 59
56static int prism2_stats_proc_read(char *page, char **start, off_t off, 60static int prism2_stats_proc_show(struct seq_file *m, void *v)
57 int count, int *eof, void *data)
58{ 61{
59 char *p = page; 62 local_info_t *local = m->private;
60 local_info_t *local = (local_info_t *) data;
61 struct comm_tallies_sums *sums = &local->comm_tallies; 63 struct comm_tallies_sums *sums = &local->comm_tallies;
62 64
63 if (off != 0) { 65 seq_printf(m, "TxUnicastFrames=%u\n", sums->tx_unicast_frames);
64 *eof = 1; 66 seq_printf(m, "TxMulticastframes=%u\n", sums->tx_multicast_frames);
65 return 0; 67 seq_printf(m, "TxFragments=%u\n", sums->tx_fragments);
66 } 68 seq_printf(m, "TxUnicastOctets=%u\n", sums->tx_unicast_octets);
67 69 seq_printf(m, "TxMulticastOctets=%u\n", sums->tx_multicast_octets);
68 p += sprintf(p, "TxUnicastFrames=%u\n", sums->tx_unicast_frames); 70 seq_printf(m, "TxDeferredTransmissions=%u\n",
69 p += sprintf(p, "TxMulticastframes=%u\n", sums->tx_multicast_frames); 71 sums->tx_deferred_transmissions);
70 p += sprintf(p, "TxFragments=%u\n", sums->tx_fragments); 72 seq_printf(m, "TxSingleRetryFrames=%u\n", sums->tx_single_retry_frames);
71 p += sprintf(p, "TxUnicastOctets=%u\n", sums->tx_unicast_octets); 73 seq_printf(m, "TxMultipleRetryFrames=%u\n",
72 p += sprintf(p, "TxMulticastOctets=%u\n", sums->tx_multicast_octets); 74 sums->tx_multiple_retry_frames);
73 p += sprintf(p, "TxDeferredTransmissions=%u\n", 75 seq_printf(m, "TxRetryLimitExceeded=%u\n",
74 sums->tx_deferred_transmissions); 76 sums->tx_retry_limit_exceeded);
75 p += sprintf(p, "TxSingleRetryFrames=%u\n", 77 seq_printf(m, "TxDiscards=%u\n", sums->tx_discards);
76 sums->tx_single_retry_frames); 78 seq_printf(m, "RxUnicastFrames=%u\n", sums->rx_unicast_frames);
77 p += sprintf(p, "TxMultipleRetryFrames=%u\n", 79 seq_printf(m, "RxMulticastFrames=%u\n", sums->rx_multicast_frames);
78 sums->tx_multiple_retry_frames); 80 seq_printf(m, "RxFragments=%u\n", sums->rx_fragments);
79 p += sprintf(p, "TxRetryLimitExceeded=%u\n", 81 seq_printf(m, "RxUnicastOctets=%u\n", sums->rx_unicast_octets);
80 sums->tx_retry_limit_exceeded); 82 seq_printf(m, "RxMulticastOctets=%u\n", sums->rx_multicast_octets);
81 p += sprintf(p, "TxDiscards=%u\n", sums->tx_discards); 83 seq_printf(m, "RxFCSErrors=%u\n", sums->rx_fcs_errors);
82 p += sprintf(p, "RxUnicastFrames=%u\n", sums->rx_unicast_frames); 84 seq_printf(m, "RxDiscardsNoBuffer=%u\n", sums->rx_discards_no_buffer);
83 p += sprintf(p, "RxMulticastFrames=%u\n", sums->rx_multicast_frames); 85 seq_printf(m, "TxDiscardsWrongSA=%u\n", sums->tx_discards_wrong_sa);
84 p += sprintf(p, "RxFragments=%u\n", sums->rx_fragments); 86 seq_printf(m, "RxDiscardsWEPUndecryptable=%u\n",
85 p += sprintf(p, "RxUnicastOctets=%u\n", sums->rx_unicast_octets); 87 sums->rx_discards_wep_undecryptable);
86 p += sprintf(p, "RxMulticastOctets=%u\n", sums->rx_multicast_octets); 88 seq_printf(m, "RxMessageInMsgFragments=%u\n",
87 p += sprintf(p, "RxFCSErrors=%u\n", sums->rx_fcs_errors); 89 sums->rx_message_in_msg_fragments);
88 p += sprintf(p, "RxDiscardsNoBuffer=%u\n", 90 seq_printf(m, "RxMessageInBadMsgFragments=%u\n",
89 sums->rx_discards_no_buffer); 91 sums->rx_message_in_bad_msg_fragments);
90 p += sprintf(p, "TxDiscardsWrongSA=%u\n", sums->tx_discards_wrong_sa);
91 p += sprintf(p, "RxDiscardsWEPUndecryptable=%u\n",
92 sums->rx_discards_wep_undecryptable);
93 p += sprintf(p, "RxMessageInMsgFragments=%u\n",
94 sums->rx_message_in_msg_fragments);
95 p += sprintf(p, "RxMessageInBadMsgFragments=%u\n",
96 sums->rx_message_in_bad_msg_fragments);
97 /* FIX: this may grow too long for one page(?) */ 92 /* FIX: this may grow too long for one page(?) */
98 93
99 return (p - page); 94 return 0;
95}
96
97static int prism2_stats_proc_open(struct inode *inode, struct file *file)
98{
99 return single_open(file, prism2_stats_proc_show, PDE_DATA(inode));
100} 100}
101 101
102static const struct file_operations prism2_stats_proc_fops = {
103 .open = prism2_stats_proc_open,
104 .read = seq_read,
105 .llseek = seq_lseek,
106 .release = seq_release,
107};
108
102 109
103static int prism2_wds_proc_read(char *page, char **start, off_t off, 110static int prism2_wds_proc_show(struct seq_file *m, void *v)
104 int count, int *eof, void *data)
105{ 111{
106 char *p = page; 112 struct list_head *ptr = v;
107 local_info_t *local = (local_info_t *) data;
108 struct list_head *ptr;
109 struct hostap_interface *iface; 113 struct hostap_interface *iface;
110 114
111 if (off > PROC_LIMIT) { 115 iface = list_entry(ptr, struct hostap_interface, list);
112 *eof = 1; 116 if (iface->type == HOSTAP_INTERFACE_WDS)
113 return 0; 117 seq_printf(m, "%s\t%pM\n",
114 } 118 iface->dev->name, iface->u.wds.remote_addr);
119 return 0;
120}
115 121
122static void *prism2_wds_proc_start(struct seq_file *m, loff_t *_pos)
123{
124 local_info_t *local = m->private;
116 read_lock_bh(&local->iface_lock); 125 read_lock_bh(&local->iface_lock);
117 list_for_each(ptr, &local->hostap_interfaces) { 126 return seq_list_start(&local->hostap_interfaces, *_pos);
118 iface = list_entry(ptr, struct hostap_interface, list); 127}
119 if (iface->type != HOSTAP_INTERFACE_WDS)
120 continue;
121 p += sprintf(p, "%s\t%pM\n",
122 iface->dev->name,
123 iface->u.wds.remote_addr);
124 if ((p - page) > PROC_LIMIT) {
125 printk(KERN_DEBUG "%s: wds proc did not fit\n",
126 local->dev->name);
127 break;
128 }
129 }
130 read_unlock_bh(&local->iface_lock);
131 128
132 if ((p - page) <= off) { 129static void *prism2_wds_proc_next(struct seq_file *m, void *v, loff_t *_pos)
133 *eof = 1; 130{
134 return 0; 131 local_info_t *local = m->private;
135 } 132 return seq_list_next(v, &local->hostap_interfaces, _pos);
133}
134
135static void prism2_wds_proc_stop(struct seq_file *m, void *v)
136{
137 local_info_t *local = m->private;
138 read_unlock_bh(&local->iface_lock);
139}
136 140
137 *start = page + off; 141static const struct seq_operations prism2_wds_proc_seqops = {
142 .start = prism2_wds_proc_start,
143 .next = prism2_wds_proc_next,
144 .stop = prism2_wds_proc_stop,
145 .show = prism2_wds_proc_show,
146};
138 147
139 return (p - page - off); 148static int prism2_wds_proc_open(struct inode *inode, struct file *file)
149{
150 int ret = seq_open(file, &prism2_wds_proc_seqops);
151 if (ret == 0) {
152 struct seq_file *m = file->private_data;
153 m->private = PDE_DATA(inode);
154 }
155 return ret;
140} 156}
141 157
158static const struct file_operations prism2_wds_proc_fops = {
159 .open = prism2_wds_proc_open,
160 .read = seq_read,
161 .llseek = seq_lseek,
162 .release = seq_release,
163};
142 164
143static int prism2_bss_list_proc_read(char *page, char **start, off_t off, 165
144 int count, int *eof, void *data) 166static int prism2_bss_list_proc_show(struct seq_file *m, void *v)
145{ 167{
146 char *p = page; 168 local_info_t *local = m->private;
147 local_info_t *local = (local_info_t *) data; 169 struct list_head *ptr = v;
148 struct list_head *ptr;
149 struct hostap_bss_info *bss; 170 struct hostap_bss_info *bss;
150 int i; 171 int i;
151 172
152 if (off > PROC_LIMIT) { 173 if (ptr == &local->bss_list) {
153 *eof = 1; 174 seq_printf(m, "#BSSID\tlast_update\tcount\tcapab_info\tSSID(txt)\t"
175 "SSID(hex)\tWPA IE\n");
154 return 0; 176 return 0;
155 } 177 }
156 178
157 p += sprintf(p, "#BSSID\tlast_update\tcount\tcapab_info\tSSID(txt)\t" 179 bss = list_entry(ptr, struct hostap_bss_info, list);
158 "SSID(hex)\tWPA IE\n"); 180 seq_printf(m, "%pM\t%lu\t%u\t0x%x\t",
181 bss->bssid, bss->last_update,
182 bss->count, bss->capab_info);
183
184 for (i = 0; i < bss->ssid_len; i++)
185 seq_putc(m,bss->ssid[i] >= 32 && bss->ssid[i] < 127 ?
186 bss->ssid[i] : '_');
187
188 seq_putc(m, '\t');
189 for (i = 0; i < bss->ssid_len; i++)
190 seq_printf(m, "%02x", bss->ssid[i]);
191 seq_putc(m, '\t');
192 for (i = 0; i < bss->wpa_ie_len; i++)
193 seq_printf(m, "%02x", bss->wpa_ie[i]);
194 seq_putc(m, '\n');
195 return 0;
196}
197
198static void *prism2_bss_list_proc_start(struct seq_file *m, loff_t *_pos)
199{
200 local_info_t *local = m->private;
159 spin_lock_bh(&local->lock); 201 spin_lock_bh(&local->lock);
160 list_for_each(ptr, &local->bss_list) { 202 return seq_list_start_head(&local->bss_list, *_pos);
161 bss = list_entry(ptr, struct hostap_bss_info, list); 203}
162 p += sprintf(p, "%pM\t%lu\t%u\t0x%x\t",
163 bss->bssid, bss->last_update,
164 bss->count, bss->capab_info);
165 for (i = 0; i < bss->ssid_len; i++) {
166 p += sprintf(p, "%c",
167 bss->ssid[i] >= 32 && bss->ssid[i] < 127 ?
168 bss->ssid[i] : '_');
169 }
170 p += sprintf(p, "\t");
171 for (i = 0; i < bss->ssid_len; i++) {
172 p += sprintf(p, "%02x", bss->ssid[i]);
173 }
174 p += sprintf(p, "\t");
175 for (i = 0; i < bss->wpa_ie_len; i++) {
176 p += sprintf(p, "%02x", bss->wpa_ie[i]);
177 }
178 p += sprintf(p, "\n");
179 if ((p - page) > PROC_LIMIT) {
180 printk(KERN_DEBUG "%s: BSS proc did not fit\n",
181 local->dev->name);
182 break;
183 }
184 }
185 spin_unlock_bh(&local->lock);
186 204
187 if ((p - page) <= off) { 205static void *prism2_bss_list_proc_next(struct seq_file *m, void *v, loff_t *_pos)
188 *eof = 1; 206{
189 return 0; 207 local_info_t *local = m->private;
190 } 208 return seq_list_next(v, &local->bss_list, _pos);
209}
210
211static void prism2_bss_list_proc_stop(struct seq_file *m, void *v)
212{
213 local_info_t *local = m->private;
214 spin_unlock_bh(&local->lock);
215}
191 216
192 *start = page + off; 217static const struct seq_operations prism2_bss_list_proc_seqops = {
218 .start = prism2_bss_list_proc_start,
219 .next = prism2_bss_list_proc_next,
220 .stop = prism2_bss_list_proc_stop,
221 .show = prism2_bss_list_proc_show,
222};
193 223
194 return (p - page - off); 224static int prism2_bss_list_proc_open(struct inode *inode, struct file *file)
225{
226 int ret = seq_open(file, &prism2_bss_list_proc_seqops);
227 if (ret == 0) {
228 struct seq_file *m = file->private_data;
229 m->private = PDE_DATA(inode);
230 }
231 return ret;
195} 232}
196 233
234static const struct file_operations prism2_bss_list_proc_fops = {
235 .open = prism2_bss_list_proc_open,
236 .read = seq_read,
237 .llseek = seq_lseek,
238 .release = seq_release,
239};
197 240
198static int prism2_crypt_proc_read(char *page, char **start, off_t off, 241
199 int count, int *eof, void *data) 242static int prism2_crypt_proc_show(struct seq_file *m, void *v)
200{ 243{
201 char *p = page; 244 local_info_t *local = m->private;
202 local_info_t *local = (local_info_t *) data;
203 int i; 245 int i;
204 246
205 if (off > PROC_LIMIT) { 247 seq_printf(m, "tx_keyidx=%d\n", local->crypt_info.tx_keyidx);
206 *eof = 1;
207 return 0;
208 }
209
210 p += sprintf(p, "tx_keyidx=%d\n", local->crypt_info.tx_keyidx);
211 for (i = 0; i < WEP_KEYS; i++) { 248 for (i = 0; i < WEP_KEYS; i++) {
212 if (local->crypt_info.crypt[i] && 249 if (local->crypt_info.crypt[i] &&
213 local->crypt_info.crypt[i]->ops && 250 local->crypt_info.crypt[i]->ops &&
214 local->crypt_info.crypt[i]->ops->print_stats) { 251 local->crypt_info.crypt[i]->ops->print_stats) {
215 p = local->crypt_info.crypt[i]->ops->print_stats( 252 local->crypt_info.crypt[i]->ops->print_stats(
216 p, local->crypt_info.crypt[i]->priv); 253 m, local->crypt_info.crypt[i]->priv);
217 } 254 }
218 } 255 }
256 return 0;
257}
219 258
220 if ((p - page) <= off) { 259static int prism2_crypt_proc_open(struct inode *inode, struct file *file)
221 *eof = 1; 260{
222 return 0; 261 return single_open(file, prism2_crypt_proc_show, PDE_DATA(inode));
223 }
224
225 *start = page + off;
226
227 return (p - page - off);
228} 262}
229 263
264static const struct file_operations prism2_crypt_proc_fops = {
265 .open = prism2_crypt_proc_open,
266 .read = seq_read,
267 .llseek = seq_lseek,
268 .release = seq_release,
269};
270
230 271
231static int prism2_pda_proc_read(char *page, char **start, off_t off, 272static ssize_t prism2_pda_proc_read(struct file *file, char __user *buf,
232 int count, int *eof, void *data) 273 size_t count, loff_t *_pos)
233{ 274{
234 local_info_t *local = (local_info_t *) data; 275 local_info_t *local = PDE_DATA(file_inode(file));
276 size_t off;
235 277
236 if (local->pda == NULL || off >= PRISM2_PDA_SIZE) { 278 if (local->pda == NULL || *_pos >= PRISM2_PDA_SIZE)
237 *eof = 1;
238 return 0; 279 return 0;
239 }
240 280
241 if (off + count > PRISM2_PDA_SIZE) 281 off = *_pos;
282 if (count > PRISM2_PDA_SIZE - off)
242 count = PRISM2_PDA_SIZE - off; 283 count = PRISM2_PDA_SIZE - off;
243 284 if (copy_to_user(buf, local->pda + off, count) != 0)
244 memcpy(page, local->pda + off, count); 285 return -EFAULT;
286 *_pos += count;
245 return count; 287 return count;
246} 288}
247 289
290static const struct file_operations prism2_pda_proc_fops = {
291 .read = prism2_pda_proc_read,
292 .llseek = generic_file_llseek,
293};
248 294
249static int prism2_aux_dump_proc_read(char *page, char **start, off_t off,
250 int count, int *eof, void *data)
251{
252 local_info_t *local = (local_info_t *) data;
253
254 if (local->func->read_aux == NULL) {
255 *eof = 1;
256 return 0;
257 }
258
259 if (local->func->read_aux(local->dev, off, count, page)) {
260 *eof = 1;
261 return 0;
262 }
263 *start = page;
264 295
265 return count; 296static ssize_t prism2_aux_dump_proc_no_read(struct file *file, char __user *buf,
297 size_t bufsize, loff_t *_pos)
298{
299 return 0;
266} 300}
267 301
302static const struct file_operations prism2_aux_dump_proc_fops = {
303 .read = prism2_aux_dump_proc_no_read,
304};
305
268 306
269#ifdef PRISM2_IO_DEBUG 307#ifdef PRISM2_IO_DEBUG
270static int prism2_io_debug_proc_read(char *page, char **start, off_t off, 308static int prism2_io_debug_proc_read(char *page, char **start, off_t off,
@@ -306,82 +344,108 @@ static int prism2_io_debug_proc_read(char *page, char **start, off_t off,
306 344
307 345
308#ifndef PRISM2_NO_STATION_MODES 346#ifndef PRISM2_NO_STATION_MODES
309static int prism2_scan_results_proc_read(char *page, char **start, off_t off, 347static int prism2_scan_results_proc_show(struct seq_file *m, void *v)
310 int count, int *eof, void *data)
311{ 348{
312 char *p = page; 349 local_info_t *local = m->private;
313 local_info_t *local = (local_info_t *) data; 350 unsigned long entry;
314 int entry, i, len, total = 0; 351 int i, len;
315 struct hfa384x_hostscan_result *scanres; 352 struct hfa384x_hostscan_result *scanres;
316 u8 *pos; 353 u8 *p;
317 354
318 p += sprintf(p, "CHID ANL SL BcnInt Capab Rate BSSID ATIM SupRates " 355 if (v == SEQ_START_TOKEN) {
319 "SSID\n"); 356 seq_printf(m,
357 "CHID ANL SL BcnInt Capab Rate BSSID ATIM SupRates SSID\n");
358 return 0;
359 }
360
361 entry = (unsigned long)v - 2;
362 scanres = &local->last_scan_results[entry];
363
364 seq_printf(m, "%d %d %d %d 0x%02x %d %pM %d ",
365 le16_to_cpu(scanres->chid),
366 (s16) le16_to_cpu(scanres->anl),
367 (s16) le16_to_cpu(scanres->sl),
368 le16_to_cpu(scanres->beacon_interval),
369 le16_to_cpu(scanres->capability),
370 le16_to_cpu(scanres->rate),
371 scanres->bssid,
372 le16_to_cpu(scanres->atim));
373
374 p = scanres->sup_rates;
375 for (i = 0; i < sizeof(scanres->sup_rates); i++) {
376 if (p[i] == 0)
377 break;
378 seq_printf(m, "<%02x>", p[i]);
379 }
380 seq_putc(m, ' ');
381
382 p = scanres->ssid;
383 len = le16_to_cpu(scanres->ssid_len);
384 if (len > 32)
385 len = 32;
386 for (i = 0; i < len; i++) {
387 unsigned char c = p[i];
388 if (c >= 32 && c < 127)
389 seq_putc(m, c);
390 else
391 seq_printf(m, "<%02x>", c);
392 }
393 seq_putc(m, '\n');
394 return 0;
395}
320 396
397static void *prism2_scan_results_proc_start(struct seq_file *m, loff_t *_pos)
398{
399 local_info_t *local = m->private;
321 spin_lock_bh(&local->lock); 400 spin_lock_bh(&local->lock);
322 for (entry = 0; entry < local->last_scan_results_count; entry++) {
323 scanres = &local->last_scan_results[entry];
324 401
325 if (total + (p - page) <= off) { 402 /* We have a header (pos 0) + N results to show (pos 1...N) */
326 total += p - page; 403 if (*_pos > local->last_scan_results_count)
327 p = page; 404 return NULL;
328 } 405 return (void *)(unsigned long)(*_pos + 1); /* 0 would be EOF */
329 if (total + (p - page) > off + count) 406}
330 break;
331 if ((p - page) > (PAGE_SIZE - 200))
332 break;
333 407
334 p += sprintf(p, "%d %d %d %d 0x%02x %d %pM %d ", 408static void *prism2_scan_results_proc_next(struct seq_file *m, void *v, loff_t *_pos)
335 le16_to_cpu(scanres->chid), 409{
336 (s16) le16_to_cpu(scanres->anl), 410 local_info_t *local = m->private;
337 (s16) le16_to_cpu(scanres->sl), 411
338 le16_to_cpu(scanres->beacon_interval), 412 ++*_pos;
339 le16_to_cpu(scanres->capability), 413 if (*_pos > local->last_scan_results_count)
340 le16_to_cpu(scanres->rate), 414 return NULL;
341 scanres->bssid, 415 return (void *)(unsigned long)(*_pos + 1); /* 0 would be EOF */
342 le16_to_cpu(scanres->atim)); 416}
343 417
344 pos = scanres->sup_rates; 418static void prism2_scan_results_proc_stop(struct seq_file *m, void *v)
345 for (i = 0; i < sizeof(scanres->sup_rates); i++) { 419{
346 if (pos[i] == 0) 420 local_info_t *local = m->private;
347 break;
348 p += sprintf(p, "<%02x>", pos[i]);
349 }
350 p += sprintf(p, " ");
351
352 pos = scanres->ssid;
353 len = le16_to_cpu(scanres->ssid_len);
354 if (len > 32)
355 len = 32;
356 for (i = 0; i < len; i++) {
357 unsigned char c = pos[i];
358 if (c >= 32 && c < 127)
359 p += sprintf(p, "%c", c);
360 else
361 p += sprintf(p, "<%02x>", c);
362 }
363 p += sprintf(p, "\n");
364 }
365 spin_unlock_bh(&local->lock); 421 spin_unlock_bh(&local->lock);
422}
366 423
367 total += (p - page); 424static const struct seq_operations prism2_scan_results_proc_seqops = {
368 if (total >= off + count) 425 .start = prism2_scan_results_proc_start,
369 *eof = 1; 426 .next = prism2_scan_results_proc_next,
427 .stop = prism2_scan_results_proc_stop,
428 .show = prism2_scan_results_proc_show,
429};
370 430
371 if (total < off) { 431static int prism2_scan_results_proc_open(struct inode *inode, struct file *file)
372 *eof = 1; 432{
373 return 0; 433 int ret = seq_open(file, &prism2_scan_results_proc_seqops);
434 if (ret == 0) {
435 struct seq_file *m = file->private_data;
436 m->private = PDE_DATA(inode);
374 } 437 }
438 return ret;
439}
440
441static const struct file_operations prism2_scan_results_proc_fops = {
442 .open = prism2_scan_results_proc_open,
443 .read = seq_read,
444 .llseek = seq_lseek,
445 .release = seq_release,
446};
375 447
376 len = total - off;
377 if (len > (p - page))
378 len = p - page;
379 *start = p - len;
380 if (len > count)
381 len = count;
382 448
383 return len;
384}
385#endif /* PRISM2_NO_STATION_MODES */ 449#endif /* PRISM2_NO_STATION_MODES */
386 450
387 451
@@ -403,28 +467,29 @@ void hostap_init_proc(local_info_t *local)
403 } 467 }
404 468
405#ifndef PRISM2_NO_PROCFS_DEBUG 469#ifndef PRISM2_NO_PROCFS_DEBUG
406 create_proc_read_entry("debug", 0, local->proc, 470 proc_create_data("debug", 0, local->proc,
407 prism2_debug_proc_read, local); 471 &prism2_debug_proc_fops, local);
408#endif /* PRISM2_NO_PROCFS_DEBUG */ 472#endif /* PRISM2_NO_PROCFS_DEBUG */
409 create_proc_read_entry("stats", 0, local->proc, 473 proc_create_data("stats", 0, local->proc,
410 prism2_stats_proc_read, local); 474 &prism2_stats_proc_fops, local);
411 create_proc_read_entry("wds", 0, local->proc, 475 proc_create_data("wds", 0, local->proc,
412 prism2_wds_proc_read, local); 476 &prism2_wds_proc_fops, local);
413 create_proc_read_entry("pda", 0, local->proc, 477 proc_create_data("pda", 0, local->proc,
414 prism2_pda_proc_read, local); 478 &prism2_pda_proc_fops, local);
415 create_proc_read_entry("aux_dump", 0, local->proc, 479 proc_create_data("aux_dump", 0, local->proc,
416 prism2_aux_dump_proc_read, local); 480 local->func->read_aux_fops ?: &prism2_aux_dump_proc_fops,
417 create_proc_read_entry("bss_list", 0, local->proc, 481 local);
418 prism2_bss_list_proc_read, local); 482 proc_create_data("bss_list", 0, local->proc,
419 create_proc_read_entry("crypt", 0, local->proc, 483 &prism2_bss_list_proc_fops, local);
420 prism2_crypt_proc_read, local); 484 proc_create_data("crypt", 0, local->proc,
485 &prism2_crypt_proc_fops, local);
421#ifdef PRISM2_IO_DEBUG 486#ifdef PRISM2_IO_DEBUG
422 create_proc_read_entry("io_debug", 0, local->proc, 487 proc_create_data("io_debug", 0, local->proc,
423 prism2_io_debug_proc_read, local); 488 &prism2_io_debug_proc_fops, local);
424#endif /* PRISM2_IO_DEBUG */ 489#endif /* PRISM2_IO_DEBUG */
425#ifndef PRISM2_NO_STATION_MODES 490#ifndef PRISM2_NO_STATION_MODES
426 create_proc_read_entry("scan_results", 0, local->proc, 491 proc_create_data("scan_results", 0, local->proc,
427 prism2_scan_results_proc_read, local); 492 &prism2_scan_results_proc_fops, local);
428#endif /* PRISM2_NO_STATION_MODES */ 493#endif /* PRISM2_NO_STATION_MODES */
429} 494}
430 495