aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2018-04-11 12:16:54 -0400
committerChristoph Hellwig <hch@lst.de>2018-05-16 01:24:30 -0400
commitdba5e4288d36630b961af89e9dde6eef750fe79d (patch)
treec012f7e15e2a1b03aadf62b69d6ea546faf51851
parent07a3b8ed48557fb9796943dac6333f527a6f5048 (diff)
staging/rtl8192u: simplify procfs code
Unwind the registration loop into individual calls. Switch to use proc_create_single where applicable. Also don't bother handling proc_create* failures - the driver works perfectly fine without the proc files, and the cleanup will handle missing files gracefully. Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--drivers/staging/rtl8192u/r8192U_core.c67
1 files changed, 14 insertions, 53 deletions
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index d607c59761cf..7a0dbc0fa18e 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -646,64 +646,25 @@ static void rtl8192_proc_module_init(void)
646 rtl8192_proc = proc_mkdir(RTL819xU_MODULE_NAME, init_net.proc_net); 646 rtl8192_proc = proc_mkdir(RTL819xU_MODULE_NAME, init_net.proc_net);
647} 647}
648 648
649/*
650 * seq_file wrappers for procfile show routines.
651 */
652static int rtl8192_proc_open(struct inode *inode, struct file *file)
653{
654 struct net_device *dev = proc_get_parent_data(inode);
655 int (*show)(struct seq_file *, void *) = PDE_DATA(inode);
656
657 return single_open(file, show, dev);
658}
659
660static const struct file_operations rtl8192_proc_fops = {
661 .open = rtl8192_proc_open,
662 .read = seq_read,
663 .llseek = seq_lseek,
664 .release = single_release,
665};
666
667/*
668 * Table of proc files we need to create.
669 */
670struct rtl8192_proc_file {
671 char name[12];
672 int (*show)(struct seq_file *, void *);
673};
674
675static const struct rtl8192_proc_file rtl8192_proc_files[] = {
676 { "stats-rx", &proc_get_stats_rx },
677 { "stats-tx", &proc_get_stats_tx },
678 { "stats-ap", &proc_get_stats_ap },
679 { "registers", &proc_get_registers },
680 { "" }
681};
682
683static void rtl8192_proc_init_one(struct net_device *dev) 649static void rtl8192_proc_init_one(struct net_device *dev)
684{ 650{
685 const struct rtl8192_proc_file *f;
686 struct proc_dir_entry *dir; 651 struct proc_dir_entry *dir;
687 652
688 if (rtl8192_proc) { 653 if (!rtl8192_proc)
689 dir = proc_mkdir_data(dev->name, 0, rtl8192_proc, dev); 654 return;
690 if (!dir) {
691 RT_TRACE(COMP_ERR,
692 "Unable to initialize /proc/net/rtl8192/%s\n",
693 dev->name);
694 return;
695 }
696 655
697 for (f = rtl8192_proc_files; f->name[0]; f++) { 656 dir = proc_mkdir_data(dev->name, 0, rtl8192_proc, dev);
698 if (!proc_create_data(f->name, S_IFREG | S_IRUGO, dir, 657 if (!dir)
699 &rtl8192_proc_fops, f->show)) { 658 return;
700 RT_TRACE(COMP_ERR, 659
701 "Unable to initialize /proc/net/rtl8192/%s/%s\n", 660 proc_create_single("stats-rx", S_IFREG | S_IRUGO, dir,
702 dev->name, f->name); 661 proc_get_stats_rx);
703 return; 662 proc_create_single("stats-tx", S_IFREG | S_IRUGO, dir,
704 } 663 proc_get_stats_tx);
705 } 664 proc_create_single("stats-ap", S_IFREG | S_IRUGO, dir,
706 } 665 proc_get_stats_ap);
666 proc_create_single("registers", S_IFREG | S_IRUGO, dir,
667 proc_get_registers);
707} 668}
708 669
709static void rtl8192_proc_remove_one(struct net_device *dev) 670static void rtl8192_proc_remove_one(struct net_device *dev)