irproc.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*********************************************************************
  2. *
  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>
  13. * Copyright (c) 1998, Thomas Davis, <ratbert@radiks.net>,
  14. * All Rights Reserved.
  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
  19. * the License, or (at your option) any later version.
  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. *
  24. ********************************************************************/
  25. #include <linux/miscdevice.h>
  26. #include <linux/proc_fs.h>
  27. #include <linux/seq_file.h>
  28. #include <linux/module.h>
  29. #include <linux/init.h>
  30. #include <net/irda/irda.h>
  31. #include <net/irda/irlap.h>
  32. #include <net/irda/irlmp.h>
  33. extern struct file_operations discovery_seq_fops;
  34. extern struct file_operations irlap_seq_fops;
  35. extern struct file_operations irlmp_seq_fops;
  36. extern struct file_operations irttp_seq_fops;
  37. extern struct file_operations irias_seq_fops;
  38. struct irda_entry {
  39. const char *name;
  40. struct file_operations *fops;
  41. };
  42. struct proc_dir_entry *proc_irda;
  43. EXPORT_SYMBOL(proc_irda);
  44. static struct irda_entry irda_dirs[] = {
  45. {"discovery", &discovery_seq_fops},
  46. {"irttp", &irttp_seq_fops},
  47. {"irlmp", &irlmp_seq_fops},
  48. {"irlap", &irlap_seq_fops},
  49. {"irias", &irias_seq_fops},
  50. };
  51. /*
  52. * Function irda_proc_register (void)
  53. *
  54. * Register irda entry in /proc file system
  55. *
  56. */
  57. void __init irda_proc_register(void)
  58. {
  59. int i;
  60. struct proc_dir_entry *d;
  61. proc_irda = proc_mkdir("irda", proc_net);
  62. if (proc_irda == NULL)
  63. return;
  64. proc_irda->owner = THIS_MODULE;
  65. for (i=0; i<ARRAY_SIZE(irda_dirs); i++) {
  66. d = create_proc_entry(irda_dirs[i].name, 0, proc_irda);
  67. if (d)
  68. d->proc_fops = irda_dirs[i].fops;
  69. }
  70. }
  71. /*
  72. * Function irda_proc_unregister (void)
  73. *
  74. * Unregister irda entry in /proc file system
  75. *
  76. */
  77. void __exit irda_proc_unregister(void)
  78. {
  79. int i;
  80. if (proc_irda) {
  81. for (i=0; i<ARRAY_SIZE(irda_dirs); i++)
  82. remove_proc_entry(irda_dirs[i].name, proc_irda);
  83. remove_proc_entry("irda", proc_net);
  84. proc_irda = NULL;
  85. }
  86. }