module.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * PCBIT-D module support
  3. *
  4. * Copyright (C) 1996 Universidade de Lisboa
  5. *
  6. * Written by Pedro Roque Marques (roque@di.fc.ul.pt)
  7. *
  8. * This software may be used and distributed according to the terms of
  9. * the GNU General Public License, incorporated herein by reference.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/init.h>
  13. #include <linux/string.h>
  14. #include <linux/kernel.h>
  15. #include <linux/skbuff.h>
  16. #include <linux/isdnif.h>
  17. #include "pcbit.h"
  18. MODULE_DESCRIPTION("ISDN4Linux: Driver for PCBIT-T card");
  19. MODULE_AUTHOR("Pedro Roque Marques");
  20. MODULE_LICENSE("GPL");
  21. static int mem[MAX_PCBIT_CARDS];
  22. static int irq[MAX_PCBIT_CARDS];
  23. module_param_array(mem, int, NULL, 0);
  24. module_param_array(irq, int, NULL, 0);
  25. static int num_boards;
  26. struct pcbit_dev *dev_pcbit[MAX_PCBIT_CARDS];
  27. static int __init pcbit_init(void)
  28. {
  29. int board;
  30. num_boards = 0;
  31. printk(KERN_NOTICE
  32. "PCBIT-D device driver v 0.5-fjpc0 19991204 - "
  33. "Copyright (C) 1996 Universidade de Lisboa\n");
  34. if (mem[0] || irq[0])
  35. {
  36. for (board = 0; board < MAX_PCBIT_CARDS && mem[board] && irq[board]; board++)
  37. {
  38. if (!mem[board])
  39. mem[board] = 0xD0000;
  40. if (!irq[board])
  41. irq[board] = 5;
  42. if (pcbit_init_dev(board, mem[board], irq[board]) == 0)
  43. num_boards++;
  44. else
  45. {
  46. printk(KERN_WARNING
  47. "pcbit_init failed for dev %d",
  48. board + 1);
  49. return -EIO;
  50. }
  51. }
  52. }
  53. /* Hardcoded default settings detection */
  54. if (!num_boards)
  55. {
  56. printk(KERN_INFO
  57. "Trying to detect board using default settings\n");
  58. if (pcbit_init_dev(0, 0xD0000, 5) == 0)
  59. num_boards++;
  60. else
  61. return -EIO;
  62. }
  63. return 0;
  64. }
  65. static void __exit pcbit_exit(void)
  66. {
  67. #ifdef MODULE
  68. int board;
  69. for (board = 0; board < num_boards; board++)
  70. pcbit_terminate(board);
  71. printk(KERN_NOTICE
  72. "PCBIT-D module unloaded\n");
  73. #endif
  74. }
  75. #ifndef MODULE
  76. #define MAX_PARA (MAX_PCBIT_CARDS * 2)
  77. static int __init pcbit_setup(char *line)
  78. {
  79. int i, j, argc;
  80. char *str;
  81. int ints[MAX_PARA + 1];
  82. str = get_options(line, MAX_PARA, ints);
  83. argc = ints[0];
  84. i = 0;
  85. j = 1;
  86. while (argc && (i < MAX_PCBIT_CARDS)) {
  87. if (argc) {
  88. mem[i] = ints[j];
  89. j++; argc--;
  90. }
  91. if (argc) {
  92. irq[i] = ints[j];
  93. j++; argc--;
  94. }
  95. i++;
  96. }
  97. return (1);
  98. }
  99. __setup("pcbit=", pcbit_setup);
  100. #endif
  101. module_init(pcbit_init);
  102. module_exit(pcbit_exit);