diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2009-08-28 05:57:21 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-08-29 03:19:38 -0400 |
commit | ea00b8e2223170a842bee06e0f27754ccdf2a217 (patch) | |
tree | d167e267a05de6a1f422d805b0290047af313981 /net | |
parent | 4923576b8ac5bfd36ab2beb176aeb747aaab7e41 (diff) |
can: switch to seq_file
create_proc_read_entry() is going to be removed soon.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/can/bcm.c | 85 | ||||
-rw-r--r-- | net/can/proc.c | 281 |
2 files changed, 167 insertions, 199 deletions
diff --git a/net/can/bcm.c b/net/can/bcm.c index 72720c710351..597da4f8f888 100644 --- a/net/can/bcm.c +++ b/net/can/bcm.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/hrtimer.h> | 46 | #include <linux/hrtimer.h> |
47 | #include <linux/list.h> | 47 | #include <linux/list.h> |
48 | #include <linux/proc_fs.h> | 48 | #include <linux/proc_fs.h> |
49 | #include <linux/seq_file.h> | ||
49 | #include <linux/uio.h> | 50 | #include <linux/uio.h> |
50 | #include <linux/net.h> | 51 | #include <linux/net.h> |
51 | #include <linux/netdevice.h> | 52 | #include <linux/netdevice.h> |
@@ -146,23 +147,18 @@ static char *bcm_proc_getifname(int ifindex) | |||
146 | return "???"; | 147 | return "???"; |
147 | } | 148 | } |
148 | 149 | ||
149 | static int bcm_read_proc(char *page, char **start, off_t off, | 150 | static int bcm_proc_show(struct seq_file *m, void *v) |
150 | int count, int *eof, void *data) | ||
151 | { | 151 | { |
152 | int len = 0; | 152 | struct sock *sk = (struct sock *)m->private; |
153 | struct sock *sk = (struct sock *)data; | ||
154 | struct bcm_sock *bo = bcm_sk(sk); | 153 | struct bcm_sock *bo = bcm_sk(sk); |
155 | struct bcm_op *op; | 154 | struct bcm_op *op; |
156 | 155 | ||
157 | len += snprintf(page + len, PAGE_SIZE - len, ">>> socket %p", | 156 | seq_printf(m, ">>> socket %p", sk->sk_socket); |
158 | sk->sk_socket); | 157 | seq_printf(m, " / sk %p", sk); |
159 | len += snprintf(page + len, PAGE_SIZE - len, " / sk %p", sk); | 158 | seq_printf(m, " / bo %p", bo); |
160 | len += snprintf(page + len, PAGE_SIZE - len, " / bo %p", bo); | 159 | seq_printf(m, " / dropped %lu", bo->dropped_usr_msgs); |
161 | len += snprintf(page + len, PAGE_SIZE - len, " / dropped %lu", | 160 | seq_printf(m, " / bound %s", bcm_proc_getifname(bo->ifindex)); |
162 | bo->dropped_usr_msgs); | 161 | seq_printf(m, " <<<\n"); |
163 | len += snprintf(page + len, PAGE_SIZE - len, " / bound %s", | ||
164 | bcm_proc_getifname(bo->ifindex)); | ||
165 | len += snprintf(page + len, PAGE_SIZE - len, " <<<\n"); | ||
166 | 162 | ||
167 | list_for_each_entry(op, &bo->rx_ops, list) { | 163 | list_for_each_entry(op, &bo->rx_ops, list) { |
168 | 164 | ||
@@ -172,71 +168,62 @@ static int bcm_read_proc(char *page, char **start, off_t off, | |||
172 | if (!op->frames_abs) | 168 | if (!op->frames_abs) |
173 | continue; | 169 | continue; |
174 | 170 | ||
175 | len += snprintf(page + len, PAGE_SIZE - len, | 171 | seq_printf(m, "rx_op: %03X %-5s ", |
176 | "rx_op: %03X %-5s ", | ||
177 | op->can_id, bcm_proc_getifname(op->ifindex)); | 172 | op->can_id, bcm_proc_getifname(op->ifindex)); |
178 | len += snprintf(page + len, PAGE_SIZE - len, "[%d]%c ", | 173 | seq_printf(m, "[%d]%c ", op->nframes, |
179 | op->nframes, | ||
180 | (op->flags & RX_CHECK_DLC)?'d':' '); | 174 | (op->flags & RX_CHECK_DLC)?'d':' '); |
181 | if (op->kt_ival1.tv64) | 175 | if (op->kt_ival1.tv64) |
182 | len += snprintf(page + len, PAGE_SIZE - len, | 176 | seq_printf(m, "timeo=%lld ", |
183 | "timeo=%lld ", | ||
184 | (long long) | 177 | (long long) |
185 | ktime_to_us(op->kt_ival1)); | 178 | ktime_to_us(op->kt_ival1)); |
186 | 179 | ||
187 | if (op->kt_ival2.tv64) | 180 | if (op->kt_ival2.tv64) |
188 | len += snprintf(page + len, PAGE_SIZE - len, | 181 | seq_printf(m, "thr=%lld ", |
189 | "thr=%lld ", | ||
190 | (long long) | 182 | (long long) |
191 | ktime_to_us(op->kt_ival2)); | 183 | ktime_to_us(op->kt_ival2)); |
192 | 184 | ||
193 | len += snprintf(page + len, PAGE_SIZE - len, | 185 | seq_printf(m, "# recv %ld (%ld) => reduction: ", |
194 | "# recv %ld (%ld) => reduction: ", | ||
195 | op->frames_filtered, op->frames_abs); | 186 | op->frames_filtered, op->frames_abs); |
196 | 187 | ||
197 | reduction = 100 - (op->frames_filtered * 100) / op->frames_abs; | 188 | reduction = 100 - (op->frames_filtered * 100) / op->frames_abs; |
198 | 189 | ||
199 | len += snprintf(page + len, PAGE_SIZE - len, "%s%ld%%\n", | 190 | seq_printf(m, "%s%ld%%\n", |
200 | (reduction == 100)?"near ":"", reduction); | 191 | (reduction == 100)?"near ":"", reduction); |
201 | |||
202 | if (len > PAGE_SIZE - 200) { | ||
203 | /* mark output cut off */ | ||
204 | len += snprintf(page + len, PAGE_SIZE - len, "(..)\n"); | ||
205 | break; | ||
206 | } | ||
207 | } | 192 | } |
208 | 193 | ||
209 | list_for_each_entry(op, &bo->tx_ops, list) { | 194 | list_for_each_entry(op, &bo->tx_ops, list) { |
210 | 195 | ||
211 | len += snprintf(page + len, PAGE_SIZE - len, | 196 | seq_printf(m, "tx_op: %03X %s [%d] ", |
212 | "tx_op: %03X %s [%d] ", | ||
213 | op->can_id, bcm_proc_getifname(op->ifindex), | 197 | op->can_id, bcm_proc_getifname(op->ifindex), |
214 | op->nframes); | 198 | op->nframes); |
215 | 199 | ||
216 | if (op->kt_ival1.tv64) | 200 | if (op->kt_ival1.tv64) |
217 | len += snprintf(page + len, PAGE_SIZE - len, "t1=%lld ", | 201 | seq_printf(m, "t1=%lld ", |
218 | (long long) ktime_to_us(op->kt_ival1)); | 202 | (long long) ktime_to_us(op->kt_ival1)); |
219 | 203 | ||
220 | if (op->kt_ival2.tv64) | 204 | if (op->kt_ival2.tv64) |
221 | len += snprintf(page + len, PAGE_SIZE - len, "t2=%lld ", | 205 | seq_printf(m, "t2=%lld ", |
222 | (long long) ktime_to_us(op->kt_ival2)); | 206 | (long long) ktime_to_us(op->kt_ival2)); |
223 | 207 | ||
224 | len += snprintf(page + len, PAGE_SIZE - len, "# sent %ld\n", | 208 | seq_printf(m, "# sent %ld\n", op->frames_abs); |
225 | op->frames_abs); | ||
226 | |||
227 | if (len > PAGE_SIZE - 100) { | ||
228 | /* mark output cut off */ | ||
229 | len += snprintf(page + len, PAGE_SIZE - len, "(..)\n"); | ||
230 | break; | ||
231 | } | ||
232 | } | 209 | } |
210 | seq_putc(m, '\n'); | ||
211 | return 0; | ||
212 | } | ||
233 | 213 | ||
234 | len += snprintf(page + len, PAGE_SIZE - len, "\n"); | 214 | static int bcm_proc_open(struct inode *inode, struct file *file) |
235 | 215 | { | |
236 | *eof = 1; | 216 | return single_open(file, bcm_proc_show, PDE(inode)->data); |
237 | return len; | ||
238 | } | 217 | } |
239 | 218 | ||
219 | static const struct file_operations bcm_proc_fops = { | ||
220 | .owner = THIS_MODULE, | ||
221 | .open = bcm_proc_open, | ||
222 | .read = seq_read, | ||
223 | .llseek = seq_lseek, | ||
224 | .release = single_release, | ||
225 | }; | ||
226 | |||
240 | /* | 227 | /* |
241 | * bcm_can_tx - send the (next) CAN frame to the appropriate CAN interface | 228 | * bcm_can_tx - send the (next) CAN frame to the appropriate CAN interface |
242 | * of the given bcm tx op | 229 | * of the given bcm tx op |
@@ -1515,9 +1502,9 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len, | |||
1515 | if (proc_dir) { | 1502 | if (proc_dir) { |
1516 | /* unique socket address as filename */ | 1503 | /* unique socket address as filename */ |
1517 | sprintf(bo->procname, "%p", sock); | 1504 | sprintf(bo->procname, "%p", sock); |
1518 | bo->bcm_proc_read = create_proc_read_entry(bo->procname, 0644, | 1505 | bo->bcm_proc_read = proc_create_data(bo->procname, 0644, |
1519 | proc_dir, | 1506 | proc_dir, |
1520 | bcm_read_proc, sk); | 1507 | &bcm_proc_fops, sk); |
1521 | } | 1508 | } |
1522 | 1509 | ||
1523 | return 0; | 1510 | return 0; |
diff --git a/net/can/proc.c b/net/can/proc.c index 1463653dbe34..9b9ad29be567 100644 --- a/net/can/proc.c +++ b/net/can/proc.c | |||
@@ -196,8 +196,8 @@ void can_stat_update(unsigned long data) | |||
196 | * | 196 | * |
197 | */ | 197 | */ |
198 | 198 | ||
199 | static int can_print_rcvlist(char *page, int len, struct hlist_head *rx_list, | 199 | static void can_print_rcvlist(struct seq_file *m, struct hlist_head *rx_list, |
200 | struct net_device *dev) | 200 | struct net_device *dev) |
201 | { | 201 | { |
202 | struct receiver *r; | 202 | struct receiver *r; |
203 | struct hlist_node *n; | 203 | struct hlist_node *n; |
@@ -208,199 +208,188 @@ static int can_print_rcvlist(char *page, int len, struct hlist_head *rx_list, | |||
208 | " %-5s %08X %08x %08x %08x %8ld %s\n" : | 208 | " %-5s %08X %08x %08x %08x %8ld %s\n" : |
209 | " %-5s %03X %08x %08lx %08lx %8ld %s\n"; | 209 | " %-5s %03X %08x %08lx %08lx %8ld %s\n"; |
210 | 210 | ||
211 | len += snprintf(page + len, PAGE_SIZE - len, fmt, | 211 | seq_printf(m, fmt, DNAME(dev), r->can_id, r->mask, |
212 | DNAME(dev), r->can_id, r->mask, | ||
213 | (unsigned long)r->func, (unsigned long)r->data, | 212 | (unsigned long)r->func, (unsigned long)r->data, |
214 | r->matches, r->ident); | 213 | r->matches, r->ident); |
215 | |||
216 | /* does a typical line fit into the current buffer? */ | ||
217 | |||
218 | /* 100 Bytes before end of buffer */ | ||
219 | if (len > PAGE_SIZE - 100) { | ||
220 | /* mark output cut off */ | ||
221 | len += snprintf(page + len, PAGE_SIZE - len, | ||
222 | " (..)\n"); | ||
223 | break; | ||
224 | } | ||
225 | } | 214 | } |
226 | rcu_read_unlock(); | 215 | rcu_read_unlock(); |
227 | |||
228 | return len; | ||
229 | } | 216 | } |
230 | 217 | ||
231 | static int can_print_recv_banner(char *page, int len) | 218 | static void can_print_recv_banner(struct seq_file *m) |
232 | { | 219 | { |
233 | /* | 220 | /* |
234 | * can1. 00000000 00000000 00000000 | 221 | * can1. 00000000 00000000 00000000 |
235 | * ....... 0 tp20 | 222 | * ....... 0 tp20 |
236 | */ | 223 | */ |
237 | len += snprintf(page + len, PAGE_SIZE - len, | 224 | seq_puts(m, " device can_id can_mask function" |
238 | " device can_id can_mask function" | ||
239 | " userdata matches ident\n"); | 225 | " userdata matches ident\n"); |
240 | |||
241 | return len; | ||
242 | } | 226 | } |
243 | 227 | ||
244 | static int can_proc_read_stats(char *page, char **start, off_t off, | 228 | static int can_stats_proc_show(struct seq_file *m, void *v) |
245 | int count, int *eof, void *data) | ||
246 | { | 229 | { |
247 | int len = 0; | 230 | seq_putc(m, '\n'); |
231 | seq_printf(m, " %8ld transmitted frames (TXF)\n", can_stats.tx_frames); | ||
232 | seq_printf(m, " %8ld received frames (RXF)\n", can_stats.rx_frames); | ||
233 | seq_printf(m, " %8ld matched frames (RXMF)\n", can_stats.matches); | ||
248 | 234 | ||
249 | len += snprintf(page + len, PAGE_SIZE - len, "\n"); | 235 | seq_putc(m, '\n'); |
250 | len += snprintf(page + len, PAGE_SIZE - len, | ||
251 | " %8ld transmitted frames (TXF)\n", | ||
252 | can_stats.tx_frames); | ||
253 | len += snprintf(page + len, PAGE_SIZE - len, | ||
254 | " %8ld received frames (RXF)\n", can_stats.rx_frames); | ||
255 | len += snprintf(page + len, PAGE_SIZE - len, | ||
256 | " %8ld matched frames (RXMF)\n", can_stats.matches); | ||
257 | |||
258 | len += snprintf(page + len, PAGE_SIZE - len, "\n"); | ||
259 | 236 | ||
260 | if (can_stattimer.function == can_stat_update) { | 237 | if (can_stattimer.function == can_stat_update) { |
261 | len += snprintf(page + len, PAGE_SIZE - len, | 238 | seq_printf(m, " %8ld %% total match ratio (RXMR)\n", |
262 | " %8ld %% total match ratio (RXMR)\n", | ||
263 | can_stats.total_rx_match_ratio); | 239 | can_stats.total_rx_match_ratio); |
264 | 240 | ||
265 | len += snprintf(page + len, PAGE_SIZE - len, | 241 | seq_printf(m, " %8ld frames/s total tx rate (TXR)\n", |
266 | " %8ld frames/s total tx rate (TXR)\n", | ||
267 | can_stats.total_tx_rate); | 242 | can_stats.total_tx_rate); |
268 | len += snprintf(page + len, PAGE_SIZE - len, | 243 | seq_printf(m, " %8ld frames/s total rx rate (RXR)\n", |
269 | " %8ld frames/s total rx rate (RXR)\n", | ||
270 | can_stats.total_rx_rate); | 244 | can_stats.total_rx_rate); |
271 | 245 | ||
272 | len += snprintf(page + len, PAGE_SIZE - len, "\n"); | 246 | seq_putc(m, '\n'); |
273 | 247 | ||
274 | len += snprintf(page + len, PAGE_SIZE - len, | 248 | seq_printf(m, " %8ld %% current match ratio (CRXMR)\n", |
275 | " %8ld %% current match ratio (CRXMR)\n", | ||
276 | can_stats.current_rx_match_ratio); | 249 | can_stats.current_rx_match_ratio); |
277 | 250 | ||
278 | len += snprintf(page + len, PAGE_SIZE - len, | 251 | seq_printf(m, " %8ld frames/s current tx rate (CTXR)\n", |
279 | " %8ld frames/s current tx rate (CTXR)\n", | ||
280 | can_stats.current_tx_rate); | 252 | can_stats.current_tx_rate); |
281 | len += snprintf(page + len, PAGE_SIZE - len, | 253 | seq_printf(m, " %8ld frames/s current rx rate (CRXR)\n", |
282 | " %8ld frames/s current rx rate (CRXR)\n", | ||
283 | can_stats.current_rx_rate); | 254 | can_stats.current_rx_rate); |
284 | 255 | ||
285 | len += snprintf(page + len, PAGE_SIZE - len, "\n"); | 256 | seq_putc(m, '\n'); |
286 | 257 | ||
287 | len += snprintf(page + len, PAGE_SIZE - len, | 258 | seq_printf(m, " %8ld %% max match ratio (MRXMR)\n", |
288 | " %8ld %% max match ratio (MRXMR)\n", | ||
289 | can_stats.max_rx_match_ratio); | 259 | can_stats.max_rx_match_ratio); |
290 | 260 | ||
291 | len += snprintf(page + len, PAGE_SIZE - len, | 261 | seq_printf(m, " %8ld frames/s max tx rate (MTXR)\n", |
292 | " %8ld frames/s max tx rate (MTXR)\n", | ||
293 | can_stats.max_tx_rate); | 262 | can_stats.max_tx_rate); |
294 | len += snprintf(page + len, PAGE_SIZE - len, | 263 | seq_printf(m, " %8ld frames/s max rx rate (MRXR)\n", |
295 | " %8ld frames/s max rx rate (MRXR)\n", | ||
296 | can_stats.max_rx_rate); | 264 | can_stats.max_rx_rate); |
297 | 265 | ||
298 | len += snprintf(page + len, PAGE_SIZE - len, "\n"); | 266 | seq_putc(m, '\n'); |
299 | } | 267 | } |
300 | 268 | ||
301 | len += snprintf(page + len, PAGE_SIZE - len, | 269 | seq_printf(m, " %8ld current receive list entries (CRCV)\n", |
302 | " %8ld current receive list entries (CRCV)\n", | ||
303 | can_pstats.rcv_entries); | 270 | can_pstats.rcv_entries); |
304 | len += snprintf(page + len, PAGE_SIZE - len, | 271 | seq_printf(m, " %8ld maximum receive list entries (MRCV)\n", |
305 | " %8ld maximum receive list entries (MRCV)\n", | ||
306 | can_pstats.rcv_entries_max); | 272 | can_pstats.rcv_entries_max); |
307 | 273 | ||
308 | if (can_pstats.stats_reset) | 274 | if (can_pstats.stats_reset) |
309 | len += snprintf(page + len, PAGE_SIZE - len, | 275 | seq_printf(m, "\n %8ld statistic resets (STR)\n", |
310 | "\n %8ld statistic resets (STR)\n", | ||
311 | can_pstats.stats_reset); | 276 | can_pstats.stats_reset); |
312 | 277 | ||
313 | if (can_pstats.user_reset) | 278 | if (can_pstats.user_reset) |
314 | len += snprintf(page + len, PAGE_SIZE - len, | 279 | seq_printf(m, " %8ld user statistic resets (USTR)\n", |
315 | " %8ld user statistic resets (USTR)\n", | ||
316 | can_pstats.user_reset); | 280 | can_pstats.user_reset); |
317 | 281 | ||
318 | len += snprintf(page + len, PAGE_SIZE - len, "\n"); | 282 | seq_putc(m, '\n'); |
319 | 283 | return 0; | |
320 | *eof = 1; | ||
321 | return len; | ||
322 | } | 284 | } |
323 | 285 | ||
324 | static int can_proc_read_reset_stats(char *page, char **start, off_t off, | 286 | static int can_stats_proc_open(struct inode *inode, struct file *file) |
325 | int count, int *eof, void *data) | ||
326 | { | 287 | { |
327 | int len = 0; | 288 | return single_open(file, can_stats_proc_show, NULL); |
289 | } | ||
290 | |||
291 | static const struct file_operations can_stats_proc_fops = { | ||
292 | .owner = THIS_MODULE, | ||
293 | .open = can_stats_proc_open, | ||
294 | .read = seq_read, | ||
295 | .llseek = seq_lseek, | ||
296 | .release = single_release, | ||
297 | }; | ||
328 | 298 | ||
299 | static int can_reset_stats_proc_show(struct seq_file *m, void *v) | ||
300 | { | ||
329 | user_reset = 1; | 301 | user_reset = 1; |
330 | 302 | ||
331 | if (can_stattimer.function == can_stat_update) { | 303 | if (can_stattimer.function == can_stat_update) { |
332 | len += snprintf(page + len, PAGE_SIZE - len, | 304 | seq_printf(m, "Scheduled statistic reset #%ld.\n", |
333 | "Scheduled statistic reset #%ld.\n", | ||
334 | can_pstats.stats_reset + 1); | 305 | can_pstats.stats_reset + 1); |
335 | 306 | ||
336 | } else { | 307 | } else { |
337 | if (can_stats.jiffies_init != jiffies) | 308 | if (can_stats.jiffies_init != jiffies) |
338 | can_init_stats(); | 309 | can_init_stats(); |
339 | 310 | ||
340 | len += snprintf(page + len, PAGE_SIZE - len, | 311 | seq_printf(m, "Performed statistic reset #%ld.\n", |
341 | "Performed statistic reset #%ld.\n", | ||
342 | can_pstats.stats_reset); | 312 | can_pstats.stats_reset); |
343 | } | 313 | } |
314 | return 0; | ||
315 | } | ||
344 | 316 | ||
345 | *eof = 1; | 317 | static int can_reset_stats_proc_open(struct inode *inode, struct file *file) |
346 | return len; | 318 | { |
319 | return single_open(file, can_reset_stats_proc_show, NULL); | ||
347 | } | 320 | } |
348 | 321 | ||
349 | static int can_proc_read_version(char *page, char **start, off_t off, | 322 | static const struct file_operations can_reset_stats_proc_fops = { |
350 | int count, int *eof, void *data) | 323 | .owner = THIS_MODULE, |
324 | .open = can_reset_stats_proc_open, | ||
325 | .read = seq_read, | ||
326 | .llseek = seq_lseek, | ||
327 | .release = single_release, | ||
328 | }; | ||
329 | |||
330 | static int can_version_proc_show(struct seq_file *m, void *v) | ||
351 | { | 331 | { |
352 | int len = 0; | 332 | seq_printf(m, "%s\n", CAN_VERSION_STRING); |
333 | return 0; | ||
334 | } | ||
353 | 335 | ||
354 | len += snprintf(page + len, PAGE_SIZE - len, "%s\n", | 336 | static int can_version_proc_open(struct inode *inode, struct file *file) |
355 | CAN_VERSION_STRING); | 337 | { |
356 | *eof = 1; | 338 | return single_open(file, can_version_proc_show, NULL); |
357 | return len; | ||
358 | } | 339 | } |
359 | 340 | ||
360 | static int can_proc_read_rcvlist(char *page, char **start, off_t off, | 341 | static const struct file_operations can_version_proc_fops = { |
361 | int count, int *eof, void *data) | 342 | .owner = THIS_MODULE, |
343 | .open = can_version_proc_open, | ||
344 | .read = seq_read, | ||
345 | .llseek = seq_lseek, | ||
346 | .release = single_release, | ||
347 | }; | ||
348 | |||
349 | static int can_rcvlist_proc_show(struct seq_file *m, void *v) | ||
362 | { | 350 | { |
363 | /* double cast to prevent GCC warning */ | 351 | /* double cast to prevent GCC warning */ |
364 | int idx = (int)(long)data; | 352 | int idx = (int)(long)m->private; |
365 | int len = 0; | ||
366 | struct dev_rcv_lists *d; | 353 | struct dev_rcv_lists *d; |
367 | struct hlist_node *n; | 354 | struct hlist_node *n; |
368 | 355 | ||
369 | len += snprintf(page + len, PAGE_SIZE - len, | 356 | seq_printf(m, "\nreceive list '%s':\n", rx_list_name[idx]); |
370 | "\nreceive list '%s':\n", rx_list_name[idx]); | ||
371 | 357 | ||
372 | rcu_read_lock(); | 358 | rcu_read_lock(); |
373 | hlist_for_each_entry_rcu(d, n, &can_rx_dev_list, list) { | 359 | hlist_for_each_entry_rcu(d, n, &can_rx_dev_list, list) { |
374 | 360 | ||
375 | if (!hlist_empty(&d->rx[idx])) { | 361 | if (!hlist_empty(&d->rx[idx])) { |
376 | len = can_print_recv_banner(page, len); | 362 | can_print_recv_banner(m); |
377 | len = can_print_rcvlist(page, len, &d->rx[idx], d->dev); | 363 | can_print_rcvlist(m, &d->rx[idx], d->dev); |
378 | } else | 364 | } else |
379 | len += snprintf(page + len, PAGE_SIZE - len, | 365 | seq_printf(m, " (%s: no entry)\n", DNAME(d->dev)); |
380 | " (%s: no entry)\n", DNAME(d->dev)); | ||
381 | |||
382 | /* exit on end of buffer? */ | ||
383 | if (len > PAGE_SIZE - 100) | ||
384 | break; | ||
385 | } | 366 | } |
386 | rcu_read_unlock(); | 367 | rcu_read_unlock(); |
387 | 368 | ||
388 | len += snprintf(page + len, PAGE_SIZE - len, "\n"); | 369 | seq_putc(m, '\n'); |
370 | return 0; | ||
371 | } | ||
389 | 372 | ||
390 | *eof = 1; | 373 | static int can_rcvlist_proc_open(struct inode *inode, struct file *file) |
391 | return len; | 374 | { |
375 | return single_open(file, can_rcvlist_proc_show, PDE(inode)->data); | ||
392 | } | 376 | } |
393 | 377 | ||
394 | static int can_proc_read_rcvlist_sff(char *page, char **start, off_t off, | 378 | static const struct file_operations can_rcvlist_proc_fops = { |
395 | int count, int *eof, void *data) | 379 | .owner = THIS_MODULE, |
380 | .open = can_rcvlist_proc_open, | ||
381 | .read = seq_read, | ||
382 | .llseek = seq_lseek, | ||
383 | .release = single_release, | ||
384 | }; | ||
385 | |||
386 | static int can_rcvlist_sff_proc_show(struct seq_file *m, void *v) | ||
396 | { | 387 | { |
397 | int len = 0; | ||
398 | struct dev_rcv_lists *d; | 388 | struct dev_rcv_lists *d; |
399 | struct hlist_node *n; | 389 | struct hlist_node *n; |
400 | 390 | ||
401 | /* RX_SFF */ | 391 | /* RX_SFF */ |
402 | len += snprintf(page + len, PAGE_SIZE - len, | 392 | seq_puts(m, "\nreceive list 'rx_sff':\n"); |
403 | "\nreceive list 'rx_sff':\n"); | ||
404 | 393 | ||
405 | rcu_read_lock(); | 394 | rcu_read_lock(); |
406 | hlist_for_each_entry_rcu(d, n, &can_rx_dev_list, list) { | 395 | hlist_for_each_entry_rcu(d, n, &can_rx_dev_list, list) { |
@@ -413,46 +402,38 @@ static int can_proc_read_rcvlist_sff(char *page, char **start, off_t off, | |||
413 | } | 402 | } |
414 | 403 | ||
415 | if (!all_empty) { | 404 | if (!all_empty) { |
416 | len = can_print_recv_banner(page, len); | 405 | can_print_recv_banner(m); |
417 | for (i = 0; i < 0x800; i++) { | 406 | for (i = 0; i < 0x800; i++) { |
418 | if (!hlist_empty(&d->rx_sff[i]) && | 407 | if (!hlist_empty(&d->rx_sff[i])) |
419 | len < PAGE_SIZE - 100) | 408 | can_print_rcvlist(m, &d->rx_sff[i], |
420 | len = can_print_rcvlist(page, len, | 409 | d->dev); |
421 | &d->rx_sff[i], | ||
422 | d->dev); | ||
423 | } | 410 | } |
424 | } else | 411 | } else |
425 | len += snprintf(page + len, PAGE_SIZE - len, | 412 | seq_printf(m, " (%s: no entry)\n", DNAME(d->dev)); |
426 | " (%s: no entry)\n", DNAME(d->dev)); | ||
427 | |||
428 | /* exit on end of buffer? */ | ||
429 | if (len > PAGE_SIZE - 100) | ||
430 | break; | ||
431 | } | 413 | } |
432 | rcu_read_unlock(); | 414 | rcu_read_unlock(); |
433 | 415 | ||
434 | len += snprintf(page + len, PAGE_SIZE - len, "\n"); | 416 | seq_putc(m, '\n'); |
417 | return 0; | ||
418 | } | ||
435 | 419 | ||
436 | *eof = 1; | 420 | static int can_rcvlist_sff_proc_open(struct inode *inode, struct file *file) |
437 | return len; | 421 | { |
422 | return single_open(file, can_rcvlist_sff_proc_show, NULL); | ||
438 | } | 423 | } |
439 | 424 | ||
425 | static const struct file_operations can_rcvlist_sff_proc_fops = { | ||
426 | .owner = THIS_MODULE, | ||
427 | .open = can_rcvlist_sff_proc_open, | ||
428 | .read = seq_read, | ||
429 | .llseek = seq_lseek, | ||
430 | .release = single_release, | ||
431 | }; | ||
432 | |||
440 | /* | 433 | /* |
441 | * proc utility functions | 434 | * proc utility functions |
442 | */ | 435 | */ |
443 | 436 | ||
444 | static struct proc_dir_entry *can_create_proc_readentry(const char *name, | ||
445 | mode_t mode, | ||
446 | read_proc_t *read_proc, | ||
447 | void *data) | ||
448 | { | ||
449 | if (can_dir) | ||
450 | return create_proc_read_entry(name, mode, can_dir, read_proc, | ||
451 | data); | ||
452 | else | ||
453 | return NULL; | ||
454 | } | ||
455 | |||
456 | static void can_remove_proc_readentry(const char *name) | 437 | static void can_remove_proc_readentry(const char *name) |
457 | { | 438 | { |
458 | if (can_dir) | 439 | if (can_dir) |
@@ -474,24 +455,24 @@ void can_init_proc(void) | |||
474 | } | 455 | } |
475 | 456 | ||
476 | /* own procfs entries from the AF_CAN core */ | 457 | /* own procfs entries from the AF_CAN core */ |
477 | pde_version = can_create_proc_readentry(CAN_PROC_VERSION, 0644, | 458 | pde_version = proc_create(CAN_PROC_VERSION, 0644, can_dir, |
478 | can_proc_read_version, NULL); | 459 | &can_version_proc_fops); |
479 | pde_stats = can_create_proc_readentry(CAN_PROC_STATS, 0644, | 460 | pde_stats = proc_create(CAN_PROC_STATS, 0644, can_dir, |
480 | can_proc_read_stats, NULL); | 461 | &can_stats_proc_fops); |
481 | pde_reset_stats = can_create_proc_readentry(CAN_PROC_RESET_STATS, 0644, | 462 | pde_reset_stats = proc_create(CAN_PROC_RESET_STATS, 0644, can_dir, |
482 | can_proc_read_reset_stats, NULL); | 463 | &can_reset_stats_proc_fops); |
483 | pde_rcvlist_err = can_create_proc_readentry(CAN_PROC_RCVLIST_ERR, 0644, | 464 | pde_rcvlist_err = proc_create_data(CAN_PROC_RCVLIST_ERR, 0644, can_dir, |
484 | can_proc_read_rcvlist, (void *)RX_ERR); | 465 | &can_rcvlist_proc_fops, (void *)RX_ERR); |
485 | pde_rcvlist_all = can_create_proc_readentry(CAN_PROC_RCVLIST_ALL, 0644, | 466 | pde_rcvlist_all = proc_create_data(CAN_PROC_RCVLIST_ALL, 0644, can_dir, |
486 | can_proc_read_rcvlist, (void *)RX_ALL); | 467 | &can_rcvlist_proc_fops, (void *)RX_ALL); |
487 | pde_rcvlist_fil = can_create_proc_readentry(CAN_PROC_RCVLIST_FIL, 0644, | 468 | pde_rcvlist_fil = proc_create_data(CAN_PROC_RCVLIST_FIL, 0644, can_dir, |
488 | can_proc_read_rcvlist, (void *)RX_FIL); | 469 | &can_rcvlist_proc_fops, (void *)RX_FIL); |
489 | pde_rcvlist_inv = can_create_proc_readentry(CAN_PROC_RCVLIST_INV, 0644, | 470 | pde_rcvlist_inv = proc_create_data(CAN_PROC_RCVLIST_INV, 0644, can_dir, |
490 | can_proc_read_rcvlist, (void *)RX_INV); | 471 | &can_rcvlist_proc_fops, (void *)RX_INV); |
491 | pde_rcvlist_eff = can_create_proc_readentry(CAN_PROC_RCVLIST_EFF, 0644, | 472 | pde_rcvlist_eff = proc_create_data(CAN_PROC_RCVLIST_EFF, 0644, can_dir, |
492 | can_proc_read_rcvlist, (void *)RX_EFF); | 473 | &can_rcvlist_proc_fops, (void *)RX_EFF); |
493 | pde_rcvlist_sff = can_create_proc_readentry(CAN_PROC_RCVLIST_SFF, 0644, | 474 | pde_rcvlist_sff = proc_create(CAN_PROC_RCVLIST_SFF, 0644, can_dir, |
494 | can_proc_read_rcvlist_sff, NULL); | 475 | &can_rcvlist_sff_proc_fops); |
495 | } | 476 | } |
496 | 477 | ||
497 | /* | 478 | /* |