root/drivers/isdn/pcbit/module.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. pcbit_init
  2. cleanup_module
  3. pcbit_setup

   1 /*
   2  * Copyright (C) 1996 Universidade de Lisboa
   3  * 
   4  * Written by Pedro Roque Marques (roque@di.fc.ul.pt)
   5  *
   6  * This software may be used and distributed according to the terms of 
   7  * the GNU Public License, incorporated herein by reference.
   8  */
   9 
  10 /*        
  11  *        PCBIT-D module support
  12  */
  13 
  14 #include <linux/module.h>
  15 
  16 #include <linux/sched.h>
  17 #include <linux/string.h>
  18 #include <linux/kernel.h>
  19 #include <linux/tqueue.h>
  20 #include <linux/skbuff.h>
  21 
  22 #include <linux/isdnif.h>
  23 #include "pcbit.h"
  24 
  25 int mem[MAX_PCBIT_CARDS] = {0, };
  26 int irq[MAX_PCBIT_CARDS] = {0, };
  27 
  28 int num_boards;
  29 struct pcbit_dev * dev_pcbit[MAX_PCBIT_CARDS] = {0, 0, 0, 0};
  30 
  31 int init_module(void);
  32 void cleanup_module(void);
  33 
  34 extern void pcbit_terminate(int board);
  35 extern int pcbit_init_dev(int board, int mem_base, int irq);
  36 
  37 #ifdef MODULE
  38 #define pcbit_init init_module
  39 #endif
  40 
  41 int pcbit_init(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  42 {
  43         int board;
  44 
  45         num_boards = 0;
  46 
  47         printk(KERN_INFO 
  48                "PCBIT-D device driver v 0.5 - "
  49                "Copyright (C) 1996 Universidade de Lisboa\n");
  50 
  51         if (mem[0] || irq[0]) 
  52         {
  53                 for (board=0; board < MAX_PCBIT_CARDS && mem[board] && irq[board]; board++)
  54                 {
  55                         if (!mem[board])
  56                                 mem[board] = 0xD0000;
  57                         if (!irq[board])
  58                                 irq[board] = 5;
  59                         
  60                         if (pcbit_init_dev(board, mem[board], irq[board]) == 0)
  61                                 num_boards++;
  62                 
  63                         else 
  64                         {
  65                                 printk(KERN_WARNING 
  66                                        "pcbit_init failed for dev %d", 
  67                                        board + 1);
  68                                 return -EIO;
  69                         }
  70                 }
  71         }
  72 
  73         /* Hardcoded default settings detection */
  74 
  75         if (!num_boards)
  76         {
  77                 printk(KERN_INFO 
  78                        "Trying to detect board using default settings\n");
  79                 if (pcbit_init_dev(0, 0xD0000, 5) == 0)
  80                         num_boards++;
  81                 else
  82                         return -EIO;
  83         }
  84 
  85         /* No symbols to export, hide all symbols */
  86         register_symtab(NULL);
  87 
  88         return 0;
  89 }
  90 
  91 #ifdef MODULE
  92 void cleanup_module(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  93 {
  94         int board;
  95 
  96         if (MOD_IN_USE) {
  97                 printk(KERN_WARNING "pcbit: device busy, remove cancelled\n");
  98                 return;
  99         }
 100 
 101         for (board = 0; board < num_boards; board++)
 102                 pcbit_terminate(board);
 103         printk(KERN_INFO 
 104                "PCBIT-D module unloaded\n");
 105 }
 106 
 107 #else
 108 void pcbit_setup(char *str, int *ints)
     /* [previous][next][first][last][top][bottom][index][help] */
 109 {
 110         int i, j, argc;
 111 
 112         argc = ints[0];
 113         i = 0;
 114         j = 1;
 115 
 116         while (argc && (i<MAX_PCBIT_CARDS)) {
 117 
 118                 if (argc) {
 119                         mem[i]  = ints[j];
 120                         j++; argc--;
 121                 }
 122                 
 123                 if (argc) {
 124                         irq[i]  = ints[j];
 125                         j++; argc--;
 126                 }
 127 
 128                 i++;
 129         }
 130 }
 131 #endif
 132 
 133 
 134 

/* [previous][next][first][last][top][bottom][index][help] */