blob: b9ac598e2116345a7b05365c74adf95bbe5abd35 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*********************************************************************
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +09002 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * Filename: irproc.c
4 * Version: 1.0
5 * Description: Various entries in the /proc file system
6 * Status: Experimental.
7 * Author: Thomas Davis, <ratbert@radiks.net>
8 * Created at: Sat Feb 21 21:33:24 1998
9 * Modified at: Sun Nov 14 08:54:54 1999
10 * Modified by: Dag Brattli <dagb@cs.uit.no>
11 *
12 * Copyright (c) 1998-1999, Dag Brattli <dagb@cs.uit.no>
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090013 * Copyright (c) 1998, Thomas Davis, <ratbert@radiks.net>,
Linus Torvalds1da177e2005-04-16 15:20:36 -070014 * All Rights Reserved.
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090015 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
Linus Torvalds1da177e2005-04-16 15:20:36 -070019 * the License, or (at your option) any later version.
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090020 *
21 * I, Thomas Davis, provide no warranty for any of this software.
22 * This material is provided "AS-IS" and at no charge.
23 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 ********************************************************************/
25
26#include <linux/miscdevice.h>
27#include <linux/proc_fs.h>
28#include <linux/seq_file.h>
29#include <linux/module.h>
30#include <linux/init.h>
Eric W. Biederman457c4cb2007-09-12 12:01:34 +020031#include <net/net_namespace.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33#include <net/irda/irda.h>
34#include <net/irda/irlap.h>
35#include <net/irda/irlmp.h>
36
Stephen Hemminger5ca1b992009-09-01 19:25:05 +000037extern const struct file_operations discovery_seq_fops;
38extern const struct file_operations irlap_seq_fops;
39extern const struct file_operations irlmp_seq_fops;
40extern const struct file_operations irttp_seq_fops;
41extern const struct file_operations irias_seq_fops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43struct irda_entry {
44 const char *name;
Stephen Hemminger5ca1b992009-09-01 19:25:05 +000045 const struct file_operations *fops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070046};
47
48struct proc_dir_entry *proc_irda;
49EXPORT_SYMBOL(proc_irda);
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090050
Stephen Hemminger5ca1b992009-09-01 19:25:05 +000051static const struct irda_entry irda_dirs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 {"discovery", &discovery_seq_fops},
53 {"irttp", &irttp_seq_fops},
54 {"irlmp", &irlmp_seq_fops},
55 {"irlap", &irlap_seq_fops},
56 {"irias", &irias_seq_fops},
57};
58
59/*
60 * Function irda_proc_register (void)
61 *
62 * Register irda entry in /proc file system
63 *
64 */
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090065void __init irda_proc_register(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070066{
67 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Eric W. Biederman457c4cb2007-09-12 12:01:34 +020069 proc_irda = proc_mkdir("irda", init_net.proc_net);
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 if (proc_irda == NULL)
71 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
Wang Chen5e478792008-02-29 10:34:45 -080073 for (i = 0; i < ARRAY_SIZE(irda_dirs); i++)
David S. Miller63859692011-04-17 16:59:50 -070074 (void) proc_create(irda_dirs[i].name, 0, proc_irda,
75 irda_dirs[i].fops);
Linus Torvalds1da177e2005-04-16 15:20:36 -070076}
77
78/*
79 * Function irda_proc_unregister (void)
80 *
81 * Unregister irda entry in /proc file system
82 *
83 */
Samuel Ortiz75a69ac2007-07-18 02:16:30 -070084void irda_proc_unregister(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070085{
86 int i;
87
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090088 if (proc_irda) {
89 for (i=0; i<ARRAY_SIZE(irda_dirs); i++)
90 remove_proc_entry(irda_dirs[i].name, proc_irda);
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
Eric W. Biederman457c4cb2007-09-12 12:01:34 +020092 remove_proc_entry("irda", init_net.proc_net);
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090093 proc_irda = NULL;
94 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070095}
96
97