capimain.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 <linux/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. /*
  81. * set additional os settings in capi_ctr struct
  82. */
  83. void diva_os_set_controller_struct(struct capi_ctr *ctrl)
  84. {
  85. ctrl->driver_name = DRIVERLNAME;
  86. ctrl->load_firmware = NULL;
  87. ctrl->reset_ctr = NULL;
  88. ctrl->proc_show = diva_ctl_proc_show;
  89. ctrl->owner = THIS_MODULE;
  90. }
  91. /*
  92. * module init
  93. */
  94. static int __init divacapi_init(void)
  95. {
  96. char tmprev[32];
  97. int ret = 0;
  98. sprintf(DRIVERRELEASE_CAPI, "%d.%d%s", DRRELMAJOR, DRRELMINOR,
  99. DRRELEXTRA);
  100. printk(KERN_INFO "%s\n", DRIVERNAME);
  101. printk(KERN_INFO "%s: Rel:%s Rev:", DRIVERLNAME, DRIVERRELEASE_CAPI);
  102. strcpy(tmprev, main_revision);
  103. printk("%s Build: %s(%s)\n", getrev(tmprev),
  104. diva_capi_common_code_build, DIVA_BUILD);
  105. if (!(init_capifunc())) {
  106. printk(KERN_ERR "%s: failed init capi_driver.\n",
  107. DRIVERLNAME);
  108. ret = -EIO;
  109. }
  110. return ret;
  111. }
  112. /*
  113. * module exit
  114. */
  115. static void __exit divacapi_exit(void)
  116. {
  117. finit_capifunc();
  118. printk(KERN_INFO "%s: module unloaded.\n", DRIVERLNAME);
  119. }
  120. module_init(divacapi_init);
  121. module_exit(divacapi_exit);