diva_didd.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* $Id: diva_didd.c,v 1.13.6.4 2005/02/11 19:40:25 armin Exp $
  2. *
  3. * DIDD Interface module for Eicon active cards.
  4. *
  5. * Functions are in dadapter.c
  6. *
  7. * Copyright 2002-2003 by Armin Schindler (mac@melware.de)
  8. * Copyright 2002-2003 Cytronics & Melware (info@melware.de)
  9. *
  10. * This software may be used and distributed according to the terms
  11. * of the GNU General Public License, incorporated herein by reference.
  12. */
  13. #include <linux/module.h>
  14. #include <linux/init.h>
  15. #include <linux/kernel.h>
  16. #include <linux/proc_fs.h>
  17. #include <linux/seq_file.h>
  18. #include <net/net_namespace.h>
  19. #include "platform.h"
  20. #include "di_defs.h"
  21. #include "dadapter.h"
  22. #include "divasync.h"
  23. #include "did_vers.h"
  24. static char *main_revision = "$Revision: 1.13.6.4 $";
  25. static char *DRIVERNAME =
  26. "Eicon DIVA - DIDD table (http://www.melware.net)";
  27. static char *DRIVERLNAME = "divadidd";
  28. char *DRIVERRELEASE_DIDD = "2.0";
  29. MODULE_DESCRIPTION("DIDD table driver for diva drivers");
  30. MODULE_AUTHOR("Cytronics & Melware, Eicon Networks");
  31. MODULE_SUPPORTED_DEVICE("Eicon diva drivers");
  32. MODULE_LICENSE("GPL");
  33. #define DBG_MINIMUM (DL_LOG + DL_FTL + DL_ERR)
  34. #define DBG_DEFAULT (DBG_MINIMUM + DL_XLOG + DL_REG)
  35. extern int diddfunc_init(void);
  36. extern void diddfunc_finit(void);
  37. extern void DIVA_DIDD_Read(void *, int);
  38. static struct proc_dir_entry *proc_didd;
  39. struct proc_dir_entry *proc_net_eicon = NULL;
  40. EXPORT_SYMBOL(DIVA_DIDD_Read);
  41. EXPORT_SYMBOL(proc_net_eicon);
  42. static char *getrev(const char *revision)
  43. {
  44. char *rev;
  45. char *p;
  46. if ((p = strchr(revision, ':'))) {
  47. rev = p + 2;
  48. p = strchr(rev, '$');
  49. *--p = 0;
  50. } else
  51. rev = "1.0";
  52. return rev;
  53. }
  54. static int divadidd_proc_show(struct seq_file *m, void *v)
  55. {
  56. char tmprev[32];
  57. strcpy(tmprev, main_revision);
  58. seq_printf(m, "%s\n", DRIVERNAME);
  59. seq_printf(m, "name : %s\n", DRIVERLNAME);
  60. seq_printf(m, "release : %s\n", DRIVERRELEASE_DIDD);
  61. seq_printf(m, "build : %s(%s)\n",
  62. diva_didd_common_code_build, DIVA_BUILD);
  63. seq_printf(m, "revision : %s\n", getrev(tmprev));
  64. return 0;
  65. }
  66. static int __init create_proc(void)
  67. {
  68. proc_net_eicon = proc_mkdir("eicon", init_net.proc_net);
  69. if (proc_net_eicon) {
  70. proc_didd = proc_create_single(DRIVERLNAME, S_IRUGO,
  71. proc_net_eicon, divadidd_proc_show);
  72. return (1);
  73. }
  74. return (0);
  75. }
  76. static void remove_proc(void)
  77. {
  78. remove_proc_entry(DRIVERLNAME, proc_net_eicon);
  79. remove_proc_entry("eicon", init_net.proc_net);
  80. }
  81. static int __init divadidd_init(void)
  82. {
  83. char tmprev[32];
  84. int ret = 0;
  85. printk(KERN_INFO "%s\n", DRIVERNAME);
  86. printk(KERN_INFO "%s: Rel:%s Rev:", DRIVERLNAME, DRIVERRELEASE_DIDD);
  87. strcpy(tmprev, main_revision);
  88. printk("%s Build:%s(%s)\n", getrev(tmprev),
  89. diva_didd_common_code_build, DIVA_BUILD);
  90. if (!create_proc()) {
  91. printk(KERN_ERR "%s: could not create proc entry\n",
  92. DRIVERLNAME);
  93. ret = -EIO;
  94. goto out;
  95. }
  96. if (!diddfunc_init()) {
  97. printk(KERN_ERR "%s: failed to connect to DIDD.\n",
  98. DRIVERLNAME);
  99. #ifdef MODULE
  100. remove_proc();
  101. #endif
  102. ret = -EIO;
  103. goto out;
  104. }
  105. out:
  106. return (ret);
  107. }
  108. static void __exit divadidd_exit(void)
  109. {
  110. diddfunc_finit();
  111. remove_proc();
  112. printk(KERN_INFO "%s: module unloaded.\n", DRIVERLNAME);
  113. }
  114. module_init(divadidd_init);
  115. module_exit(divadidd_exit);