diff options
Diffstat (limited to 'drivers/isdn/sc/init.c')
| -rw-r--r-- | drivers/isdn/sc/init.c | 173 |
1 files changed, 84 insertions, 89 deletions
diff --git a/drivers/isdn/sc/init.c b/drivers/isdn/sc/init.c index 62b7acfad8a..d6f19b168e8 100644 --- a/drivers/isdn/sc/init.c +++ b/drivers/isdn/sc/init.c @@ -8,6 +8,8 @@ #include <linux/init.h> #include <linux/interrupt.h> #include <linux/delay.h> +#include <linux/sched.h> +#include <linux/slab.h> #include "includes.h" #include "hardware.h" #include "card.h" @@ -25,22 +27,16 @@ static const char version[] = "2.0b1"; static const char *boardname[] = { "DataCommute/BRI", "DataCommute/PRI", "TeleCommute/BRI" }; /* insmod set parameters */ -static unsigned int io[] = {0,0,0,0}; -static unsigned char irq[] = {0,0,0,0}; -static unsigned long ram[] = {0,0,0,0}; -static int do_reset = 0; +static unsigned int io[] = {0, 0, 0, 0}; +static unsigned char irq[] = {0, 0, 0, 0}; +static unsigned long ram[] = {0, 0, 0, 0}; +static bool do_reset = 0; module_param_array(io, int, NULL, 0); -module_param_array(irq, int, NULL, 0); -module_param_array(ram, int, NULL, 0); +module_param_array(irq, byte, NULL, 0); +module_param_array(ram, long, NULL, 0); module_param(do_reset, bool, 0); -extern irqreturn_t interrupt_handler(int, void *, struct pt_regs *); -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); - static int identify_board(unsigned long, unsigned int); static int __init sc_init(void) @@ -66,7 +62,7 @@ static int __init sc_init(void) #endif pr_info("Copyright (C) 1996 SpellCaster Telecommunications Inc.\n"); - while(b++ < MAX_CARDS - 1) { + while (b++ < MAX_CARDS - 1) { pr_debug("Probing for adapter #%d\n", b); /* * Initialize reusable variables @@ -76,17 +72,17 @@ static int __init sc_init(void) channels = 0; pgport = 0; - /* - * See if we should probe for IO base + /* + * See if we should probe for IO base */ pr_debug("I/O Base for board %d is 0x%x, %s probe\n", b, io[b], - io[b] == 0 ? "will" : "won't"); - if(io[b]) { + io[b] == 0 ? "will" : "won't"); + if (io[b]) { /* * No, I/O Base has been provided */ - for (i = 0 ; i < MAX_IO_REGS - 1 ; i++) { - if(!request_region(io[b] + i * 0x400, 1, "sc test")) { + for (i = 0; i < MAX_IO_REGS - 1; i++) { + if (!request_region(io[b] + i * 0x400, 1, "sc test")) { pr_debug("request_region for 0x%x failed\n", io[b] + i * 0x400); io[b] = 0; break; @@ -97,14 +93,15 @@ 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"); + if (io[b] == 0) { + 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"); + if (inb(io[b] + 0x400 * EXP_PAGE0) != 0x18) { + pr_debug("I/O Base 0x%x fails test\n", + io[b] + 0x400 * EXP_PAGE0); continue; } } @@ -112,12 +109,12 @@ static int __init sc_init(void) /* * Yes, probe for I/O Base */ - if(probe_exhasted) { + if (probe_exhasted) { pr_debug("All probe addresses exhasted, skipping\n"); continue; } pr_debug("Probing for I/O...\n"); - for (i = last_base ; i <= IOBASE_MAX ; i += IOBASE_OFFSET) { + for (i = last_base; i <= IOBASE_MAX; i += IOBASE_OFFSET) { int found_io = 1; if (i == IOBASE_MAX) { probe_exhasted = 1; /* No more addresses to probe */ @@ -125,19 +122,19 @@ static int __init sc_init(void) } last_base = i + IOBASE_OFFSET; pr_debug(" checking 0x%x...", i); - for ( j = 0 ; j < MAX_IO_REGS - 1 ; j++) { - if(!request_region(i + j * 0x400, 1, "sc test")) { + for (j = 0; j < MAX_IO_REGS - 1; j++) { + if (!request_region(i + j * 0x400, 1, "sc test")) { pr_debug("Failed\n"); found_io = 0; break; } else release_region(i + j * 0x400, 1); - } + } - if(found_io) { + if (found_io) { io[b] = i; outb(0x18, io[b] + 0x400 * EXP_PAGE0); - if(inb(io[b] + 0x400 * EXP_PAGE0) != 0x18) { + if (inb(io[b] + 0x400 * EXP_PAGE0) != 0x18) { pr_debug("Failed by test\n"); continue; } @@ -145,7 +142,7 @@ static int __init sc_init(void) break; } } - if(probe_exhasted) { + if (probe_exhasted) { continue; } } @@ -153,23 +150,23 @@ static int __init sc_init(void) /* * See if we should probe for shared RAM */ - if(do_reset) { + if (do_reset) { pr_debug("Doing a SAFE probe reset\n"); 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]) { + if (ram[b]) { /* * No, the RAM base has been provided * Just look for a signature and ID the * board model */ - if(request_region(ram[b], SRAM_PAGESIZE, "sc test")) { - pr_debug("request_region for RAM base 0x%x succeeded\n", ram[b]); - model = identify_board(ram[b], io[b]); + if (request_region(ram[b], SRAM_PAGESIZE, "sc test")) { + 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); } } @@ -178,15 +175,15 @@ static int __init sc_init(void) * Yes, probe for free RAM and look for * a signature and id the board model */ - for (i = SRAM_MIN ; i < SRAM_MAX ; i += SRAM_PAGESIZE) { + 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")) { + if (request_region(i, SRAM_PAGESIZE, "sc test")) { pr_debug(" request_region succeeded\n"); model = identify_board(i, io[b]); release_region(i, SRAM_PAGESIZE); if (model >= 0) { pr_debug(" Identified a %s\n", - boardname[model]); + boardname[model]); ram[b] = i; break; } @@ -199,19 +196,19 @@ static int __init sc_init(void) /* * See if we found free RAM and the board model */ - if(!ram[b] || model < 0) { + if (!ram[b] || model < 0) { /* * 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]); - continue; + pr_debug("Failed to find an adapter at 0x%lx\n", ram[b]); + continue; } /* * Set the board's magic number, memory size and page register */ - switch(model) { + switch (model) { case PRI_BOARD: channels = 23; magic = 0x20000; @@ -227,7 +224,7 @@ static int __init sc_init(void) features = BRI_FEATURES; break; } - switch(ram[b] >> 12 & 0x0F) { + switch (ram[b] >> 12 & 0x0F) { case 0x0: pr_debug("RAM Page register set to EXP_PAGE0\n"); pgport = EXP_PAGE0; @@ -253,12 +250,12 @@ static int __init sc_init(void) continue; } - pr_debug("current IRQ: %d b: %d\n",irq[b],b); + pr_debug("current IRQ: %d b: %d\n", irq[b], b); /* * Make sure we got an IRQ */ - if(!irq[b]) { + if (!irq[b]) { /* * No interrupt could be used */ @@ -270,14 +267,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; @@ -293,7 +289,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 @@ -301,10 +297,9 @@ 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)) { + if (!register_isdn(interface)) { /* * Oops, couldn't register for some reason */ @@ -325,7 +320,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 @@ -335,44 +330,44 @@ 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)) + 0, interface->id, + (void *)(unsigned long) cinst)) { kfree(sc_adapter[cinst]->channel); indicate_status(cinst, ISDN_STAT_UNLOAD, 0, NULL); /* Fix me */ kfree(interface); kfree(sc_adapter[cinst]); continue; - + } sc_adapter[cinst]->iobase = io[b]; - for(i = 0 ; i < MAX_IO_REGS - 1 ; i++) { + for (i = 0; i < MAX_IO_REGS - 1; i++) { sc_adapter[cinst]->ioport[i] = io[b] + i * 0x400; request_region(sc_adapter[cinst]->ioport[i], 1, - interface->id); + interface->id); pr_debug("Requesting I/O Port %#x\n", - sc_adapter[cinst]->ioport[i]); + sc_adapter[cinst]->ioport[i]); } sc_adapter[cinst]->ioport[IRQ_SELECT] = io[b] + 0x2; request_region(sc_adapter[cinst]->ioport[IRQ_SELECT], 1, - interface->id); + interface->id); pr_debug("Requesting I/O Port %#x\n", - sc_adapter[cinst]->ioport[IRQ_SELECT]); + sc_adapter[cinst]->ioport[IRQ_SELECT]); sc_adapter[cinst]->rambase = ram[b]; request_region(sc_adapter[cinst]->rambase, SRAM_PAGESIZE, - interface->id); + interface->id); - pr_info(" %s (%d) - %s %d channels IRQ %d, I/O Base 0x%x, RAM Base 0x%lx\n", + pr_info(" %s (%d) - %s %d channels IRQ %d, I/O Base 0x%x, RAM Base 0x%lx\n", sc_adapter[cinst]->devicename, sc_adapter[cinst]->driverId, boardname[model], channels, irq[b], io[b], ram[b]); - + /* * reset the adapter to put things in motion */ @@ -381,7 +376,7 @@ static int __init sc_init(void) cinst++; status = 0; } - if (status) + if (status) pr_info("Failed to find any adapters, driver unloaded\n"); return status; } @@ -390,13 +385,13 @@ static void __exit sc_exit(void) { int i, j; - for(i = 0 ; i < cinst ; i++) { + for (i = 0; i < cinst; i++) { pr_debug("Cleaning up after adapter %d\n", i); /* * kill the timers */ - del_timer(&(sc_adapter[i]->reset_timer)); - del_timer(&(sc_adapter[i]->stat_timer)); + del_timer_sync(&(sc_adapter[i]->reset_timer)); + del_timer_sync(&(sc_adapter[i]->stat_timer)); /* * Tell I4L we're toast @@ -412,7 +407,7 @@ static void __exit sc_exit(void) /* * Release the IRQ */ - FREE_IRQ(sc_adapter[i]->interrupt, NULL); + free_irq(sc_adapter[i]->interrupt, NULL); /* * Reset for a clean start @@ -422,14 +417,14 @@ static void __exit sc_exit(void) /* * Release the I/O Port regions */ - for(j = 0 ; j < MAX_IO_REGS - 1; j++) { + for (j = 0; j < MAX_IO_REGS - 1; j++) { release_region(sc_adapter[i]->ioport[j], 1); pr_debug("Releasing I/O Port %#x\n", - sc_adapter[i]->ioport[j]); + sc_adapter[i]->ioport[j]); } release_region(sc_adapter[i]->ioport[IRQ_SELECT], 1); pr_debug("Releasing I/O Port %#x\n", - sc_adapter[i]->ioport[IRQ_SELECT]); + sc_adapter[i]->ioport[IRQ_SELECT]); /* * Release any memory we alloced @@ -451,20 +446,20 @@ static 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", - rambase, iobase); + pr_debug("Attempting to identify adapter @ 0x%lx io 0x%x\n", + rambase, iobase); /* * Enable the base pointer */ outb(rambase >> 12, iobase + 0x2c00); - switch(rambase >> 12 & 0x0F) { + switch (rambase >> 12 & 0x0F) { case 0x0: pgport = iobase + PG0_OFFSET; pr_debug("Page Register offset is 0x%x\n", PG0_OFFSET); break; - + case 0x4: pgport = iobase + PG1_OFFSET; pr_debug("Page Register offset is 0x%x\n", PG1_OFFSET); @@ -490,8 +485,8 @@ static 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); - if(sig == SIGNATURE) + pr_debug("Looking for a signature, got 0x%lx\n", sig); + if (sig == SIGNATURE) return PRI_BOARD; /* @@ -500,8 +495,8 @@ static 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); - if(sig == SIGNATURE) + pr_debug("Looking for a signature, got 0x%lx\n", sig); + if (sig == SIGNATURE) return BRI_BOARD; return -1; @@ -510,8 +505,8 @@ static 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); - if(sig != SIGNATURE) + pr_debug("Looking for a signature, got 0x%lx\n", sig); + if (sig != SIGNATURE) return -1; dpm = (DualPortMemory *) rambase; @@ -528,11 +523,11 @@ static int identify_board(unsigned long rambase, unsigned int iobase) * Wait for the response */ x = 0; - while((inb(iobase + FIFOSTAT_OFFSET) & RF_HAS_DATA) && x < 100) { + while ((inb(iobase + FIFOSTAT_OFFSET) & RF_HAS_DATA) && x < 100) { schedule_timeout_interruptible(1); x++; } - if(x == 100) { + if (x == 100) { pr_debug("Timeout waiting for response\n"); return -1; } @@ -540,16 +535,16 @@ static 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); - if(!strncmp(PRI_PARTNO, hwci.part_no, 6)) + if (!strncmp(PRI_PARTNO, hwci.part_no, 6)) return PRI_BOARD; - if(!strncmp(BRI_PARTNO, hwci.part_no, 6)) + if (!strncmp(BRI_PARTNO, hwci.part_no, 6)) return BRI_BOARD; - + return -1; } |
