diff options
author | Christoph Hellwig <hch@lst.de> | 2018-04-13 14:38:35 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2018-05-16 01:24:30 -0400 |
commit | 3617d9496cd92dcca4d0893191d95554590d8d9f (patch) | |
tree | 3054a4c965a42aa4375b08f92b111e1943cd41c5 /net/can/proc.c | |
parent | c3506372277779fccbffee2475400fcd689d5738 (diff) |
proc: introduce proc_create_net_single
Variant of proc_create_data that directly take a seq_file show
callback and deals with network namespaces in ->open and ->release.
All callers of proc_create + single_open_net converted over, and
single_{open,release}_net are removed entirely.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'net/can/proc.c')
-rw-r--r-- | net/can/proc.c | 127 |
1 files changed, 23 insertions, 104 deletions
diff --git a/net/can/proc.c b/net/can/proc.c index fde2fd55b826..70fea17bb04c 100644 --- a/net/can/proc.c +++ b/net/can/proc.c | |||
@@ -270,18 +270,6 @@ static int can_stats_proc_show(struct seq_file *m, void *v) | |||
270 | return 0; | 270 | return 0; |
271 | } | 271 | } |
272 | 272 | ||
273 | static int can_stats_proc_open(struct inode *inode, struct file *file) | ||
274 | { | ||
275 | return single_open_net(inode, file, can_stats_proc_show); | ||
276 | } | ||
277 | |||
278 | static const struct file_operations can_stats_proc_fops = { | ||
279 | .open = can_stats_proc_open, | ||
280 | .read = seq_read, | ||
281 | .llseek = seq_lseek, | ||
282 | .release = single_release_net, | ||
283 | }; | ||
284 | |||
285 | static int can_reset_stats_proc_show(struct seq_file *m, void *v) | 273 | static int can_reset_stats_proc_show(struct seq_file *m, void *v) |
286 | { | 274 | { |
287 | struct net *net = m->private; | 275 | struct net *net = m->private; |
@@ -303,36 +291,12 @@ static int can_reset_stats_proc_show(struct seq_file *m, void *v) | |||
303 | return 0; | 291 | return 0; |
304 | } | 292 | } |
305 | 293 | ||
306 | static int can_reset_stats_proc_open(struct inode *inode, struct file *file) | ||
307 | { | ||
308 | return single_open_net(inode, file, can_reset_stats_proc_show); | ||
309 | } | ||
310 | |||
311 | static const struct file_operations can_reset_stats_proc_fops = { | ||
312 | .open = can_reset_stats_proc_open, | ||
313 | .read = seq_read, | ||
314 | .llseek = seq_lseek, | ||
315 | .release = single_release, | ||
316 | }; | ||
317 | |||
318 | static int can_version_proc_show(struct seq_file *m, void *v) | 294 | static int can_version_proc_show(struct seq_file *m, void *v) |
319 | { | 295 | { |
320 | seq_printf(m, "%s\n", CAN_VERSION_STRING); | 296 | seq_printf(m, "%s\n", CAN_VERSION_STRING); |
321 | return 0; | 297 | return 0; |
322 | } | 298 | } |
323 | 299 | ||
324 | static int can_version_proc_open(struct inode *inode, struct file *file) | ||
325 | { | ||
326 | return single_open_net(inode, file, can_version_proc_show); | ||
327 | } | ||
328 | |||
329 | static const struct file_operations can_version_proc_fops = { | ||
330 | .open = can_version_proc_open, | ||
331 | .read = seq_read, | ||
332 | .llseek = seq_lseek, | ||
333 | .release = single_release, | ||
334 | }; | ||
335 | |||
336 | static inline void can_rcvlist_proc_show_one(struct seq_file *m, int idx, | 300 | static inline void can_rcvlist_proc_show_one(struct seq_file *m, int idx, |
337 | struct net_device *dev, | 301 | struct net_device *dev, |
338 | struct can_dev_rcv_lists *d) | 302 | struct can_dev_rcv_lists *d) |
@@ -373,18 +337,6 @@ static int can_rcvlist_proc_show(struct seq_file *m, void *v) | |||
373 | return 0; | 337 | return 0; |
374 | } | 338 | } |
375 | 339 | ||
376 | static int can_rcvlist_proc_open(struct inode *inode, struct file *file) | ||
377 | { | ||
378 | return single_open_net(inode, file, can_rcvlist_proc_show); | ||
379 | } | ||
380 | |||
381 | static const struct file_operations can_rcvlist_proc_fops = { | ||
382 | .open = can_rcvlist_proc_open, | ||
383 | .read = seq_read, | ||
384 | .llseek = seq_lseek, | ||
385 | .release = single_release, | ||
386 | }; | ||
387 | |||
388 | static inline void can_rcvlist_proc_show_array(struct seq_file *m, | 340 | static inline void can_rcvlist_proc_show_array(struct seq_file *m, |
389 | struct net_device *dev, | 341 | struct net_device *dev, |
390 | struct hlist_head *rcv_array, | 342 | struct hlist_head *rcv_array, |
@@ -440,19 +392,6 @@ static int can_rcvlist_sff_proc_show(struct seq_file *m, void *v) | |||
440 | return 0; | 392 | return 0; |
441 | } | 393 | } |
442 | 394 | ||
443 | static int can_rcvlist_sff_proc_open(struct inode *inode, struct file *file) | ||
444 | { | ||
445 | return single_open_net(inode, file, can_rcvlist_sff_proc_show); | ||
446 | } | ||
447 | |||
448 | static const struct file_operations can_rcvlist_sff_proc_fops = { | ||
449 | .open = can_rcvlist_sff_proc_open, | ||
450 | .read = seq_read, | ||
451 | .llseek = seq_lseek, | ||
452 | .release = single_release_net, | ||
453 | }; | ||
454 | |||
455 | |||
456 | static int can_rcvlist_eff_proc_show(struct seq_file *m, void *v) | 395 | static int can_rcvlist_eff_proc_show(struct seq_file *m, void *v) |
457 | { | 396 | { |
458 | struct net_device *dev; | 397 | struct net_device *dev; |
@@ -483,18 +422,6 @@ static int can_rcvlist_eff_proc_show(struct seq_file *m, void *v) | |||
483 | return 0; | 422 | return 0; |
484 | } | 423 | } |
485 | 424 | ||
486 | static int can_rcvlist_eff_proc_open(struct inode *inode, struct file *file) | ||
487 | { | ||
488 | return single_open_net(inode, file, can_rcvlist_eff_proc_show); | ||
489 | } | ||
490 | |||
491 | static const struct file_operations can_rcvlist_eff_proc_fops = { | ||
492 | .open = can_rcvlist_eff_proc_open, | ||
493 | .read = seq_read, | ||
494 | .llseek = seq_lseek, | ||
495 | .release = single_release_net, | ||
496 | }; | ||
497 | |||
498 | /* | 425 | /* |
499 | * can_init_proc - create main CAN proc directory and procfs entries | 426 | * can_init_proc - create main CAN proc directory and procfs entries |
500 | */ | 427 | */ |
@@ -510,37 +437,29 @@ void can_init_proc(struct net *net) | |||
510 | } | 437 | } |
511 | 438 | ||
512 | /* own procfs entries from the AF_CAN core */ | 439 | /* own procfs entries from the AF_CAN core */ |
513 | net->can.pde_version = proc_create(CAN_PROC_VERSION, 0644, | 440 | net->can.pde_version = proc_create_net_single(CAN_PROC_VERSION, 0644, |
514 | net->can.proc_dir, | 441 | net->can.proc_dir, can_version_proc_show, NULL); |
515 | &can_version_proc_fops); | 442 | net->can.pde_stats = proc_create_net_single(CAN_PROC_STATS, 0644, |
516 | net->can.pde_stats = proc_create(CAN_PROC_STATS, 0644, | 443 | net->can.proc_dir, can_stats_proc_show, NULL); |
517 | net->can.proc_dir, | 444 | net->can.pde_reset_stats = proc_create_net_single(CAN_PROC_RESET_STATS, |
518 | &can_stats_proc_fops); | 445 | 0644, net->can.proc_dir, can_reset_stats_proc_show, |
519 | net->can.pde_reset_stats = proc_create(CAN_PROC_RESET_STATS, 0644, | 446 | NULL); |
520 | net->can.proc_dir, | 447 | net->can.pde_rcvlist_err = proc_create_net_single(CAN_PROC_RCVLIST_ERR, |
521 | &can_reset_stats_proc_fops); | 448 | 0644, net->can.proc_dir, can_rcvlist_proc_show, |
522 | net->can.pde_rcvlist_err = proc_create_data(CAN_PROC_RCVLIST_ERR, 0644, | 449 | (void *)RX_ERR); |
523 | net->can.proc_dir, | 450 | net->can.pde_rcvlist_all = proc_create_net_single(CAN_PROC_RCVLIST_ALL, |
524 | &can_rcvlist_proc_fops, | 451 | 0644, net->can.proc_dir, can_rcvlist_proc_show, |
525 | (void *)RX_ERR); | 452 | (void *)RX_ALL); |
526 | net->can.pde_rcvlist_all = proc_create_data(CAN_PROC_RCVLIST_ALL, 0644, | 453 | net->can.pde_rcvlist_fil = proc_create_net_single(CAN_PROC_RCVLIST_FIL, |
527 | net->can.proc_dir, | 454 | 0644, net->can.proc_dir, can_rcvlist_proc_show, |
528 | &can_rcvlist_proc_fops, | 455 | (void *)RX_FIL); |
529 | (void *)RX_ALL); | 456 | net->can.pde_rcvlist_inv = proc_create_net_single(CAN_PROC_RCVLIST_INV, |
530 | net->can.pde_rcvlist_fil = proc_create_data(CAN_PROC_RCVLIST_FIL, 0644, | 457 | 0644, net->can.proc_dir, can_rcvlist_proc_show, |
531 | net->can.proc_dir, | 458 | (void *)RX_INV); |
532 | &can_rcvlist_proc_fops, | 459 | net->can.pde_rcvlist_eff = proc_create_net_single(CAN_PROC_RCVLIST_EFF, |
533 | (void *)RX_FIL); | 460 | 0644, net->can.proc_dir, can_rcvlist_eff_proc_show, NULL); |
534 | net->can.pde_rcvlist_inv = proc_create_data(CAN_PROC_RCVLIST_INV, 0644, | 461 | net->can.pde_rcvlist_sff = proc_create_net_single(CAN_PROC_RCVLIST_SFF, |
535 | net->can.proc_dir, | 462 | 0644, net->can.proc_dir, can_rcvlist_sff_proc_show, NULL); |
536 | &can_rcvlist_proc_fops, | ||
537 | (void *)RX_INV); | ||
538 | net->can.pde_rcvlist_eff = proc_create(CAN_PROC_RCVLIST_EFF, 0644, | ||
539 | net->can.proc_dir, | ||
540 | &can_rcvlist_eff_proc_fops); | ||
541 | net->can.pde_rcvlist_sff = proc_create(CAN_PROC_RCVLIST_SFF, 0644, | ||
542 | net->can.proc_dir, | ||
543 | &can_rcvlist_sff_proc_fops); | ||
544 | } | 463 | } |
545 | 464 | ||
546 | /* | 465 | /* |