diva_didd.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 divadidd_proc_open(struct inode *inode, struct file *file)
  67. {
  68. return single_open(file, divadidd_proc_show, NULL);
  69. }
  70. static const struct file_operations divadidd_proc_fops = {
  71. .owner = THIS_MODULE,
  72. .open = divadidd_proc_open,
  73. .read = seq_read,
  74. .llseek = seq_lseek,
  75. .release = single_release,
  76. };
  77. static int __init create_proc(void)
  78. {
  79. proc_net_eicon = proc_mkdir("eicon", init_net.proc_net);
  80. if (proc_net_eicon) {
  81. proc_didd = proc_create(DRIVERLNAME, S_IRUGO, proc_net_eicon,
  82. &divadidd_proc_fops);
  83. return (1);
  84. }
  85. return (0);
  86. }
  87. static void remove_proc(void)
  88. {
  89. remove_proc_entry(DRIVERLNAME, proc_net_eicon);
  90. remove_proc_entry("eicon", init_net.proc_net);
  91. }
  92. static int __init divadidd_init(void)
  93. {
  94. char tmprev[32];
  95. int ret = 0;
  96. printk(KERN_INFO "%s\n", DRIVERNAME);
  97. printk(KERN_INFO "%s: Rel:%s Rev:", DRIVERLNAME, DRIVERRELEASE_DIDD);
  98. strcpy(tmprev, main_revision);
  99. printk("%s Build:%s(%s)\n", getrev(tmprev),
  100. diva_didd_common_code_build, DIVA_BUILD);
  101. if (!create_proc()) {
  102. printk(KERN_ERR "%s: could not create proc entry\n",
  103. DRIVERLNAME);
  104. ret = -EIO;
  105. goto out;
  106. }
  107. if (!diddfunc_init()) {
  108. printk(KERN_ERR "%s: failed to connect to DIDD.\n",
  109. DRIVERLNAME);
  110. #ifdef MODULE
  111. remove_proc();
  112. #endif
  113. ret = -EIO;
  114. goto out;
  115. }
  116. out:
  117. return (ret);
  118. }
  119. static void __exit divadidd_exit(void)
  120. {
  121. diddfunc_finit();
  122. remove_proc();
  123. printk(KERN_INFO "%s: module unloaded.\n", DRIVERLNAME);
  124. }
  125. module_init(divadidd_init);
  126. module_exit(divadidd_exit);