capimain.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /* $Id: capimain.c,v 1.24 2003/09/09 06:51:05 schindler Exp $
  2. *
  3. * ISDN interface module for Eicon active cards DIVA.
  4. * CAPI Interface
  5. *
  6. * Copyright 2000-2003 by Armin Schindler (mac@melware.de)
  7. * Copyright 2000-2003 Cytronics & Melware (info@melware.de)
  8. *
  9. * This software may be used and distributed according to the terms
  10. * of the GNU General Public License, incorporated herein by reference.
  11. */
  12. #include <linux/module.h>
  13. #include <linux/slab.h>
  14. #include <linux/init.h>
  15. #include <asm/uaccess.h>
  16. #include <linux/seq_file.h>
  17. #include <linux/skbuff.h>
  18. #include "os_capi.h"
  19. #include "platform.h"
  20. #include "di_defs.h"
  21. #include "capi20.h"
  22. #include "divacapi.h"
  23. #include "cp_vers.h"
  24. #include "capifunc.h"
  25. static char *main_revision = "$Revision: 1.24 $";
  26. static char *DRIVERNAME =
  27. "Eicon DIVA - CAPI Interface driver (http://www.melware.net)";
  28. static char *DRIVERLNAME = "divacapi";
  29. MODULE_DESCRIPTION("CAPI driver for Eicon DIVA cards");
  30. MODULE_AUTHOR("Cytronics & Melware, Eicon Networks");
  31. MODULE_SUPPORTED_DEVICE("CAPI and DIVA card drivers");
  32. MODULE_LICENSE("GPL");
  33. /*
  34. * get revision number from revision string
  35. */
  36. static char *getrev(const char *revision)
  37. {
  38. char *rev;
  39. char *p;
  40. if ((p = strchr(revision, ':'))) {
  41. rev = p + 2;
  42. p = strchr(rev, '$');
  43. *--p = 0;
  44. } else
  45. rev = "1.0";
  46. return rev;
  47. }
  48. /*
  49. * alloc a message buffer
  50. */
  51. diva_os_message_buffer_s *diva_os_alloc_message_buffer(unsigned long size,
  52. void **data_buf)
  53. {
  54. diva_os_message_buffer_s *dmb = alloc_skb(size, GFP_ATOMIC);
  55. if (dmb) {
  56. *data_buf = skb_put(dmb, size);
  57. }
  58. return (dmb);
  59. }
  60. /*
  61. * free a message buffer
  62. */
  63. void diva_os_free_message_buffer(diva_os_message_buffer_s * dmb)
  64. {
  65. kfree_skb(dmb);
  66. }
  67. /*
  68. * proc function for controller info
  69. */
  70. static int diva_ctl_proc_show(struct seq_file *m, void *v)
  71. {
  72. struct capi_ctr *ctrl = m->private;
  73. diva_card *card = (diva_card *) ctrl->driverdata;
  74. seq_printf(m, "%s\n", ctrl->name);
  75. seq_printf(m, "Serial No. : %s\n", ctrl->serial);
  76. seq_printf(m, "Id : %d\n", card->Id);
  77. seq_printf(m, "Channels : %d\n", card->d.channels);
  78. return 0;
  79. }
  80. static int diva_ctl_proc_open(struct inode *inode, struct file *file)
  81. {
  82. return single_open(file, diva_ctl_proc_show, NULL);
  83. }
  84. static const struct file_operations diva_ctl_proc_fops = {
  85. .owner = THIS_MODULE,
  86. .open = diva_ctl_proc_open,
  87. .read = seq_read,
  88. .llseek = seq_lseek,
  89. .release = single_release,
  90. };
  91. /*
  92. * set additional os settings in capi_ctr struct
  93. */
  94. void diva_os_set_controller_struct(struct capi_ctr *ctrl)
  95. {
  96. ctrl->driver_name = DRIVERLNAME;
  97. ctrl->load_firmware = NULL;
  98. ctrl->reset_ctr = NULL;
  99. ctrl->proc_fops = &diva_ctl_proc_fops;
  100. ctrl->owner = THIS_MODULE;
  101. }
  102. /*
  103. * module init
  104. */
  105. static int DIVA_INIT_FUNCTION divacapi_init(void)
  106. {
  107. char tmprev[32];
  108. int ret = 0;
  109. sprintf(DRIVERRELEASE_CAPI, "%d.%d%s", DRRELMAJOR, DRRELMINOR,
  110. DRRELEXTRA);
  111. printk(KERN_INFO "%s\n", DRIVERNAME);
  112. printk(KERN_INFO "%s: Rel:%s Rev:", DRIVERLNAME, DRIVERRELEASE_CAPI);
  113. strcpy(tmprev, main_revision);
  114. printk("%s Build: %s(%s)\n", getrev(tmprev),
  115. diva_capi_common_code_build, DIVA_BUILD);
  116. if (!(init_capifunc())) {
  117. printk(KERN_ERR "%s: failed init capi_driver.\n",
  118. DRIVERLNAME);
  119. ret = -EIO;
  120. }
  121. return ret;
  122. }
  123. /*
  124. * module exit
  125. */
  126. static void DIVA_EXIT_FUNCTION divacapi_exit(void)
  127. {
  128. finit_capifunc();
  129. printk(KERN_INFO "%s: module unloaded.\n", DRIVERLNAME);
  130. }
  131. module_init(divacapi_init);
  132. module_exit(divacapi_exit);