fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / isdn / sc / init.c
index efefede..150759a 100644 (file)
@@ -20,9 +20,9 @@ board *sc_adapter[MAX_CARDS];
 int cinst;
 
 static char devname[] = "scX";
-const char version[] = "2.0b1";
+static const char version[] = "2.0b1";
 
-const char *boardname[] = { "DataCommute/BRI", "DataCommute/PRI", "TeleCommute/BRI" };
+static const char *boardname[] = { "DataCommute/BRI", "DataCommute/PRI", "TeleCommute/BRI" };
 
 /* insmod set parameters */
 static unsigned int io[] = {0,0,0,0};
@@ -35,26 +35,13 @@ module_param_array(irq, int, NULL, 0);
 module_param_array(ram, int, NULL, 0);
 module_param(do_reset, bool, 0);
 
-static int sup_irq[] = { 11, 10, 9, 5, 12, 14, 7, 3, 4, 6 };
-#define MAX_IRQS       10
-
-extern irqreturn_t interrupt_handler(int, void *, struct pt_regs *);
+extern irqreturn_t interrupt_handler(int, void *);
 extern int sndpkt(int, int, int, struct sk_buff *);
 extern int command(isdn_ctrl *);
 extern int indicate_status(int, int, ulong, char*);
 extern int reset(int);
 
-int identify_board(unsigned long, unsigned int);
-
-int irq_supported(int irq_x)
-{
-       int i;
-       for(i=0 ; i < MAX_IRQS ; i++) {
-               if(sup_irq[i] == irq_x)
-                       return 1;
-       }
-       return 0;
-}
+static int identify_board(unsigned long, unsigned int);
 
 static int __init sc_init(void)
 {
@@ -100,7 +87,7 @@ static int __init sc_init(void)
                         */
                        for (i = 0 ; i < MAX_IO_REGS - 1 ; i++) {
                                if(!request_region(io[b] + i * 0x400, 1, "sc test")) {
-                                       pr_debug("check_region for 0x%x failed\n", io[b] + i * 0x400);
+                                       pr_debug("request_region for 0x%x failed\n", io[b] + i * 0x400);
                                        io[b] = 0;
                                        break;
                                } else
@@ -111,13 +98,14 @@ static int __init sc_init(void)
                         * Confirm the I/O Address with a test
                         */
                        if(io[b] == 0) {
-                               pr_debug("I/O Address 0x%x is in use.\n");
+                               pr_debug("I/O Address invalid.\n");
                                continue;
                        }
 
                        outb(0x18, io[b] + 0x400 * EXP_PAGE0);
                        if(inb(io[b] + 0x400 * EXP_PAGE0) != 0x18) {
-                               pr_debug("I/O Base 0x%x fails test\n");
+                               pr_debug("I/O Base 0x%x fails test\n",
+                                        io[b] + 0x400 * EXP_PAGE0);
                                continue;
                        }
                }
@@ -171,8 +159,8 @@ static int __init sc_init(void)
                        outb(0xFF, io[b] + RESET_OFFSET);
                        msleep_interruptible(10000);
                }
-               pr_debug("RAM Base for board %d is 0x%x, %s probe\n", b, ram[b],
-                       ram[b] == 0 ? "will" : "won't");
+               pr_debug("RAM Base for board %d is 0x%lx, %s probe\n", b,
+                       ram[b], ram[b] == 0 ? "will" : "won't");
 
                if(ram[b]) {
                        /*
@@ -181,7 +169,7 @@ static int __init sc_init(void)
                         * board model
                         */
                        if(request_region(ram[b], SRAM_PAGESIZE, "sc test")) {
-                               pr_debug("request_region for RAM base 0x%x succeeded\n", ram[b]);
+                               pr_debug("request_region for RAM base 0x%lx succeeded\n", ram[b]);
                                model = identify_board(ram[b], io[b]);
                                release_region(ram[b], SRAM_PAGESIZE);
                        }
@@ -194,7 +182,7 @@ static int __init sc_init(void)
                        for (i = SRAM_MIN ; i < SRAM_MAX ; i += SRAM_PAGESIZE) {
                                pr_debug("Checking RAM address 0x%x...\n", i);
                                if(request_region(i, SRAM_PAGESIZE, "sc test")) {
-                                       pr_debug("  check_region succeeded\n");
+                                       pr_debug("  request_region succeeded\n");
                                        model = identify_board(i, io[b]);
                                        release_region(i, SRAM_PAGESIZE);
                                        if (model >= 0) {
@@ -217,7 +205,7 @@ static int __init sc_init(void)
                         * Nope, there was no place in RAM for the
                         * board, or it couldn't be identified
                         */
-                        pr_debug("Failed to find an adapter at 0x%x\n", ram[b]);
+                        pr_debug("Failed to find an adapter at 0x%lx\n", ram[b]);
                         continue;
                }
 
@@ -283,14 +271,13 @@ static int __init sc_init(void)
                 * Horray! We found a board, Make sure we can register
                 * it with ISDN4Linux
                 */
-               interface = kmalloc(sizeof(isdn_if), GFP_KERNEL);
+               interface = kzalloc(sizeof(isdn_if), GFP_KERNEL);
                if (interface == NULL) {
                        /*
                         * Oops, can't malloc isdn_if
                         */
                        continue;
                }
-               memset(interface, 0, sizeof(isdn_if));
 
                interface->owner = THIS_MODULE;
                interface->hl_hdrlen = 0;
@@ -306,7 +293,7 @@ static int __init sc_init(void)
                /*
                 * Allocate the board structure
                 */
-               sc_adapter[cinst] = kmalloc(sizeof(board), GFP_KERNEL);
+               sc_adapter[cinst] = kzalloc(sizeof(board), GFP_KERNEL);
                if (sc_adapter[cinst] == NULL) {
                        /*
                         * Oops, can't alloc memory for the board
@@ -314,7 +301,6 @@ static int __init sc_init(void)
                        kfree(interface);
                        continue;
                }
-               memset(sc_adapter[cinst], 0, sizeof(board));
                spin_lock_init(&sc_adapter[cinst]->lock);
 
                if(!register_isdn(interface)) {
@@ -338,7 +324,7 @@ static int __init sc_init(void)
                /*
                 * Allocate channels status structures
                 */
-               sc_adapter[cinst]->channel = kmalloc(sizeof(bchan) * channels, GFP_KERNEL);
+               sc_adapter[cinst]->channel = kzalloc(sizeof(bchan) * channels, GFP_KERNEL);
                if (sc_adapter[cinst]->channel == NULL) {
                        /*
                         * Oops, can't alloc memory for the channels
@@ -348,14 +334,13 @@ static int __init sc_init(void)
                        kfree(sc_adapter[cinst]);
                        continue;
                }
-               memset(sc_adapter[cinst]->channel, 0, sizeof(bchan) * channels);
 
                /*
                 * Lock down the hardware resources
                 */
                sc_adapter[cinst]->interrupt = irq[b];
                if (request_irq(sc_adapter[cinst]->interrupt, interrupt_handler,
-                               SA_INTERRUPT, interface->id, NULL))
+                               IRQF_DISABLED, interface->id, NULL))
                {
                        kfree(sc_adapter[cinst]->channel);
                        indicate_status(cinst, ISDN_STAT_UNLOAD, 0, NULL);      /* Fix me */
@@ -454,7 +439,7 @@ static void __exit sc_exit(void)
        pr_info("SpellCaster ISA ISDN Adapter Driver Unloaded.\n");
 }
 
-int identify_board(unsigned long rambase, unsigned int iobase) 
+static int identify_board(unsigned long rambase, unsigned int iobase)
 {
        unsigned int pgport;
        unsigned long sig;
@@ -464,7 +449,7 @@ int identify_board(unsigned long rambase, unsigned int iobase)
        HWConfig_pl hwci;
        int x;
 
-       pr_debug("Attempting to identify adapter @ 0x%x io 0x%x\n",
+       pr_debug("Attempting to identify adapter @ 0x%lx io 0x%x\n",
                rambase, iobase);
 
        /*
@@ -503,7 +488,7 @@ int identify_board(unsigned long rambase, unsigned int iobase)
        outb(PRI_BASEPG_VAL, pgport);
        msleep_interruptible(1000);
        sig = readl(rambase + SIG_OFFSET);
-       pr_debug("Looking for a signature, got 0x%x\n", sig);
+       pr_debug("Looking for a signature, got 0x%lx\n", sig);
        if(sig == SIGNATURE)
                return PRI_BOARD;
 
@@ -513,7 +498,7 @@ int identify_board(unsigned long rambase, unsigned int iobase)
        outb(BRI_BASEPG_VAL, pgport);
        msleep_interruptible(1000);
        sig = readl(rambase + SIG_OFFSET);
-       pr_debug("Looking for a signature, got 0x%x\n", sig);
+       pr_debug("Looking for a signature, got 0x%lx\n", sig);
        if(sig == SIGNATURE)
                return BRI_BOARD;
 
@@ -523,7 +508,7 @@ int identify_board(unsigned long rambase, unsigned int iobase)
         * Try to spot a card
         */
        sig = readl(rambase + SIG_OFFSET);
-       pr_debug("Looking for a signature, got 0x%x\n", sig);
+       pr_debug("Looking for a signature, got 0x%lx\n", sig);
        if(sig != SIGNATURE)
                return -1;
 
@@ -542,8 +527,7 @@ int identify_board(unsigned long rambase, unsigned int iobase)
         */
        x = 0;
        while((inb(iobase + FIFOSTAT_OFFSET) & RF_HAS_DATA) && x < 100) {
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(1);
+               schedule_timeout_interruptible(1);
                x++;
        }
        if(x == 100) {
@@ -554,7 +538,7 @@ int identify_board(unsigned long rambase, unsigned int iobase)
        memcpy_fromio(&rcvmsg, &(dpm->rsp_queue[dpm->rsp_tail]), MSG_LEN);
        pr_debug("Got HWConfig response, status = 0x%x\n", rcvmsg.rsp_status);
        memcpy(&hwci, &(rcvmsg.msg_data.HWCresponse), sizeof(HWConfig_pl));
-       pr_debug("Hardware Config: Interface: %s, RAM Size: %d, Serial: %s\n"
+       pr_debug("Hardware Config: Interface: %s, RAM Size: %ld, Serial: %s\n"
                 "                 Part: %s, Rev: %s\n",
                 hwci.st_u_sense ? "S/T" : "U", hwci.ram_size,
                 hwci.serial_no, hwci.part_no, hwci.rev_no);