Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /********************************************************************* |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 2 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * 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 Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 13 | * Copyright (c) 1998, Thomas Davis, <ratbert@radiks.net>, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | * All Rights Reserved. |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 15 | * |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | * the License, or (at your option) any later version. |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 20 | * |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | ********************************************************************/ |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/proc_fs.h> |
| 27 | #include <linux/seq_file.h> |
| 28 | #include <linux/module.h> |
| 29 | #include <linux/init.h> |
Eric W. Biederman | 457c4cb | 2007-09-12 12:01:34 +0200 | [diff] [blame] | 30 | #include <net/net_namespace.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
| 32 | #include <net/irda/irda.h> |
| 33 | #include <net/irda/irlap.h> |
| 34 | #include <net/irda/irlmp.h> |
| 35 | |
Stephen Hemminger | 5ca1b99 | 2009-09-01 19:25:05 +0000 | [diff] [blame] | 36 | extern const struct file_operations discovery_seq_fops; |
| 37 | extern const struct file_operations irlap_seq_fops; |
| 38 | extern const struct file_operations irlmp_seq_fops; |
| 39 | extern const struct file_operations irttp_seq_fops; |
| 40 | extern const struct file_operations irias_seq_fops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
| 42 | struct irda_entry { |
| 43 | const char *name; |
Stephen Hemminger | 5ca1b99 | 2009-09-01 19:25:05 +0000 | [diff] [blame] | 44 | const struct file_operations *fops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | struct proc_dir_entry *proc_irda; |
| 48 | EXPORT_SYMBOL(proc_irda); |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 49 | |
Stephen Hemminger | 5ca1b99 | 2009-09-01 19:25:05 +0000 | [diff] [blame] | 50 | static const struct irda_entry irda_dirs[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | {"discovery", &discovery_seq_fops}, |
| 52 | {"irttp", &irttp_seq_fops}, |
| 53 | {"irlmp", &irlmp_seq_fops}, |
| 54 | {"irlap", &irlap_seq_fops}, |
| 55 | {"irias", &irias_seq_fops}, |
| 56 | }; |
| 57 | |
| 58 | /* |
| 59 | * Function irda_proc_register (void) |
| 60 | * |
| 61 | * Register irda entry in /proc file system |
| 62 | * |
| 63 | */ |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 64 | void __init irda_proc_register(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | { |
| 66 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | |
Eric W. Biederman | 457c4cb | 2007-09-12 12:01:34 +0200 | [diff] [blame] | 68 | proc_irda = proc_mkdir("irda", init_net.proc_net); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | if (proc_irda == NULL) |
| 70 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | |
Wang Chen | 5e47879 | 2008-02-29 10:34:45 -0800 | [diff] [blame] | 72 | for (i = 0; i < ARRAY_SIZE(irda_dirs); i++) |
David S. Miller | 6385969 | 2011-04-17 16:59:50 -0700 | [diff] [blame] | 73 | (void) proc_create(irda_dirs[i].name, 0, proc_irda, |
| 74 | irda_dirs[i].fops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | /* |
| 78 | * Function irda_proc_unregister (void) |
| 79 | * |
| 80 | * Unregister irda entry in /proc file system |
| 81 | * |
| 82 | */ |
Samuel Ortiz | 75a69ac | 2007-07-18 02:16:30 -0700 | [diff] [blame] | 83 | void irda_proc_unregister(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | { |
| 85 | int i; |
| 86 | |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 87 | if (proc_irda) { |
| 88 | for (i=0; i<ARRAY_SIZE(irda_dirs); i++) |
| 89 | remove_proc_entry(irda_dirs[i].name, proc_irda); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | |
Eric W. Biederman | 457c4cb | 2007-09-12 12:01:34 +0200 | [diff] [blame] | 91 | remove_proc_entry("irda", init_net.proc_net); |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 92 | proc_irda = NULL; |
| 93 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | |