Global variable `adapter' is insufficiently unique - it clashes with another `adapter' somewhere else. --- drivers/isdn/sc/card.h | 0 drivers/isdn/sc/command.c | 81 +++++++++++++------------- drivers/isdn/sc/event.c | 10 +-- drivers/isdn/sc/hardware.h | 2 drivers/isdn/sc/init.c | 102 +++++++++++++++++---------------- drivers/isdn/sc/interrupt.c | 70 +++++++++++++--------- drivers/isdn/sc/ioctl.c | 135 +++++++++++++++++++++++++------------------- drivers/isdn/sc/message.c | 71 +++++++++++------------ drivers/isdn/sc/message.h | 0 drivers/isdn/sc/packet.c | 107 +++++++++++++++++++--------------- drivers/isdn/sc/shmem.c | 60 ++++++++++--------- drivers/isdn/sc/timer.c | 49 ++++++++------- 12 files changed, 373 insertions(+), 314 deletions(-) diff -puN drivers/isdn/sc/command.c~i4l-sc-adapter-fix drivers/isdn/sc/command.c --- 25/drivers/isdn/sc/command.c~i4l-sc-adapter-fix 2004-02-10 02:06:12.000000000 -0800 +++ 25-akpm/drivers/isdn/sc/command.c 2004-02-10 02:07:54.000000000 -0800 @@ -32,7 +32,7 @@ int setl3(int card, unsigned long arg); int acceptb(int card, unsigned long channel); extern int cinst; -extern board *adapter[]; +extern board *sc_adapter[]; extern int sc_ioctl(int, scs_ioctl *); extern int setup_buffers(int, int, unsigned int); @@ -84,7 +84,7 @@ int get_card_from_id(int driver) int i; for(i = 0 ; i < cinst ; i++) { - if(adapter[i]->driverId == driver) + if(sc_adapter[i]->driverId == driver) return i; } return -ENODEV; @@ -105,7 +105,7 @@ int command(isdn_ctrl *cmd) } pr_debug("%s: Received %s command from Link Layer\n", - adapter[card]->devicename, commands[cmd->command]); + sc_adapter[card]->devicename, commands[cmd->command]); /* * Dispatch the command @@ -120,7 +120,7 @@ int command(isdn_ctrl *cmd) if (copy_from_user(&ioc, (scs_ioctl *)cmdptr, sizeof(scs_ioctl))) { pr_debug("%s: Failed to verify user space 0x%x\n", - adapter[card]->devicename, cmdptr); + sc_adapter[card]->devicename, cmdptr); return -EFAULT; } return sc_ioctl(card, &ioc); @@ -163,8 +163,8 @@ int loopback(int card) return -ENODEV; } - pr_debug("%s: Sending loopback message\n", adapter[card]->devicename); - + pr_debug("%s: Sending loopback message\n", + sc_adapter[card]->devicename); /* * Send the loopback message to confirm that memory transfer is @@ -181,17 +181,17 @@ int loopback(int card) if (!status) { pr_debug("%s: Loopback message successfully sent\n", - adapter[card]->devicename); + sc_adapter[card]->devicename); if(strcmp(rspmsg.msg_data.byte_array, testmsg)) { pr_debug("%s: Loopback return != sent\n", - adapter[card]->devicename); + sc_adapter[card]->devicename); return -EIO; } return 0; } else { pr_debug("%s: Send loopback message failed\n", - adapter[card]->devicename); + sc_adapter[card]->devicename); return -EIO; } @@ -216,7 +216,7 @@ int startproc(int card) cmReqClass0, cmReqStartProc, 0,0,0); - pr_debug("%s: Sent startProc\n", adapter[card]->devicename); + pr_debug("%s: Sent startProc\n", sc_adapter[card]->devicename); return status; } @@ -253,7 +253,7 @@ int dial(int card, unsigned long channel (unsigned int *) Phone); pr_debug("%s: Dialing %s on channel %d\n", - adapter[card]->devicename, Phone, channel+1); + sc_adapter[card]->devicename, Phone, channel+1); return status; } @@ -275,7 +275,7 @@ int answer(int card, unsigned long chann indicate_status(card, ISDN_STAT_BCONN,channel,NULL); pr_debug("%s: Answered incoming call on channel %s\n", - adapter[card]->devicename, channel+1); + sc_adapter[card]->devicename, channel+1); return 0; } @@ -298,7 +298,7 @@ int hangup(int card, unsigned long chann 0, NULL); pr_debug("%s: Sent HANGUP message to channel %d\n", - adapter[card]->devicename, channel+1); + sc_adapter[card]->devicename, channel+1); return status; } @@ -316,15 +316,16 @@ int setl2(int card, unsigned long arg) } protocol = arg >> 8; channel = arg & 0xff; - adapter[card]->channel[channel].l2_proto = protocol; + sc_adapter[card]->channel[channel].l2_proto = protocol; pr_debug("%s: Level 2 protocol for channel %d set to %s from %d\n", - adapter[card]->devicename, channel+1,l2protos[adapter[card]->channel[channel].l2_proto],protocol); + sc_adapter[card]->devicename, channel+1, + l2protos[sc_adapter[card]->channel[channel].l2_proto],protocol); /* * check that the adapter is also set to the correct protocol */ pr_debug("%s: Sending GetFrameFormat for channel %d\n", - adapter[card]->devicename, channel+1); + sc_adapter[card]->devicename, channel+1); status = sendmessage(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetFrameFormat, @@ -348,9 +349,9 @@ int setl3(int card, unsigned long channe return -ENODEV; } - adapter[card]->channel[channel].l3_proto = protocol; + sc_adapter[card]->channel[channel].l3_proto = protocol; pr_debug("%s: Level 3 protocol for channel %d set to %s\n", - adapter[card]->devicename, channel+1, l3protos[protocol]); + sc_adapter[card]->devicename, channel+1, l3protos[protocol]); return 0; } @@ -368,7 +369,7 @@ int acceptb(int card, unsigned long chan } pr_debug("%s: B-Channel connection accepted on channel %d\n", - adapter[card]->devicename, channel+1); + sc_adapter[card]->devicename, channel+1); indicate_status(card, ISDN_STAT_BCONN, channel, NULL); return 0; } @@ -380,10 +381,10 @@ int clreaz(int card, unsigned long arg) return -ENODEV; } - strcpy(adapter[card]->channel[arg].eazlist, ""); - adapter[card]->channel[arg].eazclear = 1; + strcpy(sc_adapter[card]->channel[arg].eazlist, ""); + sc_adapter[card]->channel[arg].eazclear = 1; pr_debug("%s: EAZ List cleared for channel %d\n", - adapter[card]->devicename, arg+1); + sc_adapter[card]->devicename, arg+1); return 0; } @@ -394,11 +395,11 @@ int seteaz(int card, unsigned long arg, return -ENODEV; } - strcpy(adapter[card]->channel[arg].eazlist, num); - adapter[card]->channel[arg].eazclear = 0; + strcpy(sc_adapter[card]->channel[arg].eazlist, num); + sc_adapter[card]->channel[arg].eazclear = 0; pr_debug("%s: EAZ list for channel %d set to: %s\n", - adapter[card]->devicename, arg+1, - adapter[card]->channel[arg].eazlist); + sc_adapter[card]->devicename, arg+1, + sc_adapter[card]->channel[arg].eazlist); return 0; } @@ -413,28 +414,28 @@ int reset(int card) indicate_status(card, ISDN_STAT_STOP, 0, NULL); - if(adapter[card]->EngineUp) { - del_timer(&adapter[card]->stat_timer); + if(sc_adapter[card]->EngineUp) { + del_timer(&sc_adapter[card]->stat_timer); } - adapter[card]->EngineUp = 0; + sc_adapter[card]->EngineUp = 0; - spin_lock_irqsave(&adapter[card]->lock, flags); - init_timer(&adapter[card]->reset_timer); - adapter[card]->reset_timer.function = check_reset; - adapter[card]->reset_timer.data = card; - adapter[card]->reset_timer.expires = jiffies + CHECKRESET_TIME; - add_timer(&adapter[card]->reset_timer); - spin_unlock_irqrestore(&adapter[card]->lock, flags); + spin_lock_irqsave(&sc_adapter[card]->lock, flags); + init_timer(&sc_adapter[card]->reset_timer); + sc_adapter[card]->reset_timer.function = check_reset; + sc_adapter[card]->reset_timer.data = card; + sc_adapter[card]->reset_timer.expires = jiffies + CHECKRESET_TIME; + add_timer(&sc_adapter[card]->reset_timer); + spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); - outb(0x1,adapter[card]->ioport[SFT_RESET]); + outb(0x1,sc_adapter[card]->ioport[SFT_RESET]); - pr_debug("%s: Adapter Reset\n", adapter[card]->devicename); + pr_debug("%s: Adapter Reset\n", sc_adapter[card]->devicename); return 0; } void flushreadfifo (int card) { - while(inb(adapter[card]->ioport[FIFO_STATUS]) & RF_HAS_DATA) - inb(adapter[card]->ioport[FIFO_READ]); + while(inb(sc_adapter[card]->ioport[FIFO_STATUS]) & RF_HAS_DATA) + inb(sc_adapter[card]->ioport[FIFO_READ]); } diff -puN drivers/isdn/sc/card.h~i4l-sc-adapter-fix drivers/isdn/sc/card.h diff -puN drivers/isdn/sc/hardware.h~i4l-sc-adapter-fix drivers/isdn/sc/hardware.h --- 25/drivers/isdn/sc/hardware.h~i4l-sc-adapter-fix 2004-02-10 02:06:13.000000000 -0800 +++ 25-akpm/drivers/isdn/sc/hardware.h 2004-02-10 02:08:10.000000000 -0800 @@ -108,6 +108,6 @@ #define milliseconds(x) (x/(1000/HZ)) /* Determine if a channel number is valid for the adapter */ -#define IS_VALID_CHANNEL(y,x) ((x>0) && (x <= adapter[y]->channels)) +#define IS_VALID_CHANNEL(y,x) ((x>0) && (x <= sc_adapter[y]->channels)) #endif diff -puN drivers/isdn/sc/event.c~i4l-sc-adapter-fix drivers/isdn/sc/event.c --- 25/drivers/isdn/sc/event.c~i4l-sc-adapter-fix 2004-02-10 02:06:13.000000000 -0800 +++ 25-akpm/drivers/isdn/sc/event.c 2004-02-10 02:08:18.000000000 -0800 @@ -21,7 +21,7 @@ #include "card.h" extern int cinst; -extern board *adapter[]; +extern board *sc_adapter[]; #ifdef DEBUG static char *events[] = { "ISDN_STAT_STAVAIL", @@ -46,9 +46,9 @@ int indicate_status(int card, int event, isdn_ctrl cmd; pr_debug("%s: Indicating event %s on Channel %d\n", - adapter[card]->devicename, events[event-256], Channel); + sc_adapter[card]->devicename, events[event-256], Channel); if (Data != NULL){ - pr_debug("%s: Event data: %s\n", adapter[card]->devicename, + pr_debug("%s: Event data: %s\n", sc_adapter[card]->devicename, Data); switch (event) { case ISDN_STAT_BSENT: @@ -63,7 +63,7 @@ int indicate_status(int card, int event, } cmd.command = event; - cmd.driver = adapter[card]->driverId; + cmd.driver = sc_adapter[card]->driverId; cmd.arg = Channel; - return adapter[card]->card->statcallb(&cmd); + return sc_adapter[card]->card->statcallb(&cmd); } diff -puN drivers/isdn/sc/init.c~i4l-sc-adapter-fix drivers/isdn/sc/init.c --- 25/drivers/isdn/sc/init.c~i4l-sc-adapter-fix 2004-02-10 02:06:13.000000000 -0800 +++ 25-akpm/drivers/isdn/sc/init.c 2004-02-10 02:09:58.000000000 -0800 @@ -19,7 +19,7 @@ MODULE_PARM(irq, "1-" __MODULE_STRING(MA MODULE_PARM(ram, "1-" __MODULE_STRING(MAX_CARDS) "i"); MODULE_PARM(do_reset, "i"); -board *adapter[MAX_CARDS]; +board *sc_adapter[MAX_CARDS]; int cinst; static char devname[] = "scX"; @@ -305,78 +305,84 @@ static int __init sc_init(void) /* * Allocate the board structure */ - adapter[cinst] = kmalloc(sizeof(board), GFP_KERNEL); - if (adapter[cinst] == NULL) { + sc_adapter[cinst] = kmalloc(sizeof(board), GFP_KERNEL); + if (sc_adapter[cinst] == NULL) { /* * Oops, can't alloc memory for the board */ kfree(interface); continue; } - memset(adapter[cinst], 0, sizeof(board)); - spin_lock_init(&adapter[cinst]->lock); + memset(sc_adapter[cinst], 0, sizeof(board)); + spin_lock_init(&sc_adapter[cinst]->lock); if(!register_isdn(interface)) { /* * Oops, couldn't register for some reason */ kfree(interface); - kfree(adapter[cinst]); + kfree(sc_adapter[cinst]); continue; } - adapter[cinst]->card = interface; - adapter[cinst]->driverId = interface->channels; - strcpy(adapter[cinst]->devicename, interface->id); - adapter[cinst]->nChannels = channels; - adapter[cinst]->ramsize = memsize; - adapter[cinst]->shmem_magic = magic; - adapter[cinst]->shmem_pgport = pgport; - adapter[cinst]->StartOnReset = 1; + sc_adapter[cinst]->card = interface; + sc_adapter[cinst]->driverId = interface->channels; + strcpy(sc_adapter[cinst]->devicename, interface->id); + sc_adapter[cinst]->nChannels = channels; + sc_adapter[cinst]->ramsize = memsize; + sc_adapter[cinst]->shmem_magic = magic; + sc_adapter[cinst]->shmem_pgport = pgport; + sc_adapter[cinst]->StartOnReset = 1; /* * Allocate channels status structures */ - adapter[cinst]->channel = kmalloc(sizeof(bchan) * channels, GFP_KERNEL); - if (adapter[cinst]->channel == NULL) { + sc_adapter[cinst]->channel = kmalloc(sizeof(bchan) * channels, GFP_KERNEL); + if (sc_adapter[cinst]->channel == NULL) { /* * Oops, can't alloc memory for the channels */ indicate_status(cinst, ISDN_STAT_UNLOAD, 0, NULL); /* Fix me */ kfree(interface); - kfree(adapter[cinst]); + kfree(sc_adapter[cinst]); continue; } - memset(adapter[cinst]->channel, 0, sizeof(bchan) * channels); + memset(sc_adapter[cinst]->channel, 0, sizeof(bchan) * channels); /* * Lock down the hardware resources */ - adapter[cinst]->interrupt = irq[b]; - if (request_irq(adapter[cinst]->interrupt, interrupt_handler, SA_INTERRUPT, - interface->id, NULL)) + sc_adapter[cinst]->interrupt = irq[b]; + if (request_irq(sc_adapter[cinst]->interrupt, interrupt_handler, + SA_INTERRUPT, interface->id, NULL)) { - kfree(adapter[cinst]->channel); + kfree(sc_adapter[cinst]->channel); indicate_status(cinst, ISDN_STAT_UNLOAD, 0, NULL); /* Fix me */ kfree(interface); - kfree(adapter[cinst]); + kfree(sc_adapter[cinst]); continue; } - adapter[cinst]->iobase = io[b]; + sc_adapter[cinst]->iobase = io[b]; for(i = 0 ; i < MAX_IO_REGS - 1 ; i++) { - adapter[cinst]->ioport[i] = io[b] + i * 0x400; - request_region(adapter[cinst]->ioport[i], 1, interface->id); - pr_debug("Requesting I/O Port %#x\n", adapter[cinst]->ioport[i]); - } - adapter[cinst]->ioport[IRQ_SELECT] = io[b] + 0x2; - request_region(adapter[cinst]->ioport[IRQ_SELECT], 1, interface->id); - pr_debug("Requesting I/O Port %#x\n", adapter[cinst]->ioport[IRQ_SELECT]); - adapter[cinst]->rambase = ram[b]; - request_region(adapter[cinst]->rambase, SRAM_PAGESIZE, interface->id); + sc_adapter[cinst]->ioport[i] = io[b] + i * 0x400; + request_region(sc_adapter[cinst]->ioport[i], 1, + interface->id); + pr_debug("Requesting I/O Port %#x\n", + 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); + pr_debug("Requesting I/O Port %#x\n", + sc_adapter[cinst]->ioport[IRQ_SELECT]); + sc_adapter[cinst]->rambase = ram[b]; + request_region(sc_adapter[cinst]->rambase, SRAM_PAGESIZE, + interface->id); pr_info(" %s (%d) - %s %d channels IRQ %d, I/O Base 0x%x, RAM Base 0x%lx\n", - adapter[cinst]->devicename, adapter[cinst]->driverId, + sc_adapter[cinst]->devicename, + sc_adapter[cinst]->driverId, boardname[model], channels, irq[b], io[b], ram[b]); /* @@ -401,8 +407,8 @@ static void __exit sc_exit(void) /* * kill the timers */ - del_timer(&(adapter[i]->reset_timer)); - del_timer(&(adapter[i]->stat_timer)); + del_timer(&(sc_adapter[i]->reset_timer)); + del_timer(&(sc_adapter[i]->stat_timer)); /* * Tell I4L we're toast @@ -413,34 +419,36 @@ static void __exit sc_exit(void) /* * Release shared RAM */ - release_region(adapter[i]->rambase, SRAM_PAGESIZE); + release_region(sc_adapter[i]->rambase, SRAM_PAGESIZE); /* * Release the IRQ */ - FREE_IRQ(adapter[i]->interrupt, NULL); + FREE_IRQ(sc_adapter[i]->interrupt, NULL); /* * Reset for a clean start */ - outb(0xFF, adapter[i]->ioport[SFT_RESET]); + outb(0xFF, sc_adapter[i]->ioport[SFT_RESET]); /* * Release the I/O Port regions */ for(j = 0 ; j < MAX_IO_REGS - 1; j++) { - release_region(adapter[i]->ioport[j], 1); - pr_debug("Releasing I/O Port %#x\n", adapter[i]->ioport[j]); - } - release_region(adapter[i]->ioport[IRQ_SELECT], 1); - pr_debug("Releasing I/O Port %#x\n", adapter[i]->ioport[IRQ_SELECT]); + release_region(sc_adapter[i]->ioport[j], 1); + pr_debug("Releasing I/O Port %#x\n", + 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]); /* * Release any memory we alloced */ - kfree(adapter[i]->channel); - kfree(adapter[i]->card); - kfree(adapter[i]); + kfree(sc_adapter[i]->channel); + kfree(sc_adapter[i]->card); + kfree(sc_adapter[i]); } pr_info("SpellCaster ISA ISDN Adapter Driver Unloaded.\n"); } diff -puN drivers/isdn/sc/interrupt.c~i4l-sc-adapter-fix drivers/isdn/sc/interrupt.c --- 25/drivers/isdn/sc/interrupt.c~i4l-sc-adapter-fix 2004-02-10 02:06:13.000000000 -0800 +++ 25-akpm/drivers/isdn/sc/interrupt.c 2004-02-10 02:11:30.000000000 -0800 @@ -29,14 +29,14 @@ extern int sendmessage(int, unsigned int extern void rcvpkt(int, RspMessage *); extern int cinst; -extern board *adapter[]; +extern board *sc_adapter[]; int get_card_from_irq(int irq) { int i; for(i = 0 ; i < cinst ; i++) { - if(adapter[i]->interrupt == irq) + if(sc_adapter[i]->interrupt == irq) return i; } return -1; @@ -59,7 +59,8 @@ irqreturn_t interrupt_handler(int interr return IRQ_NONE; } - pr_debug("%s: Entered Interrupt handler\n", adapter[card]->devicename); + pr_debug("%s: Entered Interrupt handler\n", + sc_adapter[card]->devicename); /* * Pull all of the waiting messages off the response queue @@ -69,8 +70,9 @@ irqreturn_t interrupt_handler(int interr * Push the message to the adapter structure for * send_and_receive to snoop */ - if(adapter[card]->want_async_messages) - memcpy(&(adapter[card]->async_msg), &rcvmsg, sizeof(RspMessage)); + if(sc_adapter[card]->want_async_messages) + memcpy(&(sc_adapter[card]->async_msg), + &rcvmsg, sizeof(RspMessage)); channel = (unsigned int) rcvmsg.phy_link_no; @@ -79,7 +81,8 @@ irqreturn_t interrupt_handler(int interr */ if(IS_CM_MESSAGE(rcvmsg, 0, 0, Invalid)) { pr_debug("%s: Invalid request Message, rsp_status = %d\n", - adapter[card]->devicename, rcvmsg.rsp_status); + sc_adapter[card]->devicename, + rcvmsg.rsp_status); break; } @@ -89,7 +92,7 @@ irqreturn_t interrupt_handler(int interr if (IS_CE_MESSAGE(rcvmsg, Lnk, 1, Read)) { pr_debug("%s: Received packet 0x%x bytes long at 0x%x\n", - adapter[card]->devicename, + sc_adapter[card]->devicename, rcvmsg.msg_data.response.msg_len, rcvmsg.msg_data.response.buff_offset); rcvpkt(card, &rcvmsg); @@ -101,9 +104,10 @@ irqreturn_t interrupt_handler(int interr * Handle a write acknoledgement */ if(IS_CE_MESSAGE(rcvmsg, Lnk, 1, Write)) { - pr_debug("%s: Packet Send ACK on channel %d\n", adapter[card]->devicename, + pr_debug("%s: Packet Send ACK on channel %d\n", + sc_adapter[card]->devicename, rcvmsg.phy_link_no); - adapter[card]->channel[rcvmsg.phy_link_no-1].free_sendbufs++; + sc_adapter[card]->channel[rcvmsg.phy_link_no-1].free_sendbufs++; continue; } @@ -115,7 +119,7 @@ irqreturn_t interrupt_handler(int interr unsigned int callid; setup_parm setup; pr_debug("%s: Connect message: line %d: status %d: cause 0x%x\n", - adapter[card]->devicename, + sc_adapter[card]->devicename, rcvmsg.phy_link_no, rcvmsg.rsp_status, rcvmsg.msg_data.byte_array[2]); @@ -123,16 +127,19 @@ irqreturn_t interrupt_handler(int interr memcpy(&callid,rcvmsg.msg_data.byte_array,sizeof(int)); if(callid>=0x8000 && callid<=0xFFFF) { - pr_debug("%s: Got Dial-Out Rsp\n", adapter[card]->devicename); + pr_debug("%s: Got Dial-Out Rsp\n", + sc_adapter[card]->devicename); indicate_status(card, ISDN_STAT_DCONN, (unsigned long)rcvmsg.phy_link_no-1,NULL); } else if(callid>=0x0000 && callid<=0x7FFF) { - pr_debug("%s: Got Incoming Call\n", adapter[card]->devicename); + pr_debug("%s: Got Incoming Call\n", + sc_adapter[card]->devicename); strcpy(setup.phone,&(rcvmsg.msg_data.byte_array[4])); - strcpy(setup.eazmsn,adapter[card]->channel[rcvmsg.phy_link_no-1].dn); + strcpy(setup.eazmsn, + sc_adapter[card]->channel[rcvmsg.phy_link_no-1].dn); setup.si1 = 7; setup.si2 = 0; setup.plan = 0; @@ -150,7 +157,7 @@ irqreturn_t interrupt_handler(int interr if (IS_CE_MESSAGE(rcvmsg, Phy, 1, Disconnect)) { pr_debug("%s: disconnect message: line %d: status %d: cause 0x%x\n", - adapter[card]->devicename, + sc_adapter[card]->devicename, rcvmsg.phy_link_no, rcvmsg.rsp_status, rcvmsg.msg_data.byte_array[2]); @@ -165,15 +172,16 @@ irqreturn_t interrupt_handler(int interr * Handle a startProc engine up message */ if (IS_CM_MESSAGE(rcvmsg, 5, 0, MiscEngineUp)) { - pr_debug("%s: Received EngineUp message\n", adapter[card]->devicename); - adapter[card]->EngineUp = 1; + pr_debug("%s: Received EngineUp message\n", + sc_adapter[card]->devicename); + sc_adapter[card]->EngineUp = 1; sendmessage(card, CEPID,ceReqTypeCall,ceReqClass0,ceReqCallGetMyNumber,1,0,NULL); sendmessage(card, CEPID,ceReqTypeCall,ceReqClass0,ceReqCallGetMyNumber,2,0,NULL); - init_timer(&adapter[card]->stat_timer); - adapter[card]->stat_timer.function = check_phystat; - adapter[card]->stat_timer.data = card; - adapter[card]->stat_timer.expires = jiffies + CHECKSTAT_TIME; - add_timer(&adapter[card]->stat_timer); + init_timer(&sc_adapter[card]->stat_timer); + sc_adapter[card]->stat_timer.function = check_phystat; + sc_adapter[card]->stat_timer.data = card; + sc_adapter[card]->stat_timer.expires = jiffies + CHECKSTAT_TIME; + add_timer(&sc_adapter[card]->stat_timer); continue; } @@ -181,7 +189,8 @@ irqreturn_t interrupt_handler(int interr * Start proc response */ if (IS_CM_MESSAGE(rcvmsg, 2, 0, StartProc)) { - pr_debug("%s: StartProc Response Status %d\n", adapter[card]->devicename, + pr_debug("%s: StartProc Response Status %d\n", + sc_adapter[card]->devicename, rcvmsg.rsp_status); continue; } @@ -190,7 +199,7 @@ irqreturn_t interrupt_handler(int interr * Handle a GetMyNumber Rsp */ if (IS_CE_MESSAGE(rcvmsg,Call,0,GetMyNumber)){ - strcpy(adapter[card]->channel[rcvmsg.phy_link_no-1].dn,rcvmsg.msg_data.byte_array); + strcpy(sc_adapter[card]->channel[rcvmsg.phy_link_no-1].dn,rcvmsg.msg_data.byte_array); continue; } @@ -206,9 +215,10 @@ irqreturn_t interrupt_handler(int interr b1stat = (unsigned int) rcvmsg.msg_data.byte_array[0]; b2stat = (unsigned int) rcvmsg.msg_data.byte_array[1]; - adapter[card]->nphystat = (b2stat >> 8) | b1stat; /* endian?? */ - pr_debug("%s: PhyStat is 0x%2x\n", adapter[card]->devicename, - adapter[card]->nphystat); + sc_adapter[card]->nphystat = (b2stat >> 8) | b1stat; /* endian?? */ + pr_debug("%s: PhyStat is 0x%2x\n", + sc_adapter[card]->devicename, + sc_adapter[card]->nphystat); continue; } @@ -223,7 +233,7 @@ irqreturn_t interrupt_handler(int interr * Set board format to HDLC if it wasn't already */ pr_debug("%s: current frame format: 0x%x, will change to HDLC\n", - adapter[card]->devicename, + sc_adapter[card]->devicename, rcvmsg.msg_data.byte_array[0]); sendmessage(card, CEPID, ceReqTypeCall, ceReqClass0, @@ -238,11 +248,13 @@ irqreturn_t interrupt_handler(int interr * Hmm... */ pr_debug("%s: Received unhandled message (%d,%d,%d) link %d\n", - adapter[card]->devicename, rcvmsg.type, rcvmsg.class, rcvmsg.code, + sc_adapter[card]->devicename, + rcvmsg.type, rcvmsg.class, rcvmsg.code, rcvmsg.phy_link_no); } /* while */ - pr_debug("%s: Exiting Interrupt Handler\n", adapter[card]->devicename); + pr_debug("%s: Exiting Interrupt Handler\n", + sc_adapter[card]->devicename); return IRQ_HANDLED; } diff -puN drivers/isdn/sc/ioctl.c~i4l-sc-adapter-fix drivers/isdn/sc/ioctl.c --- 25/drivers/isdn/sc/ioctl.c~i4l-sc-adapter-fix 2004-02-10 02:06:13.000000000 -0800 +++ 25-akpm/drivers/isdn/sc/ioctl.c 2004-02-10 02:13:27.000000000 -0800 @@ -20,7 +20,7 @@ extern int send_and_receive(int, unsigne unsigned char,unsigned char, unsigned char, unsigned char *, RspMessage *, int); -extern board *adapter[]; +extern board *sc_adapter[]; int GetStatus(int card, boardInfo *); @@ -33,8 +33,9 @@ int sc_ioctl(int card, scs_ioctl *data) switch(data->command) { case SCIOCRESET: /* Perform a hard reset of the adapter */ { - pr_debug("%s: SCIOCRESET: ioctl received\n", adapter[card]->devicename); - adapter[card]->StartOnReset = 0; + pr_debug("%s: SCIOCRESET: ioctl received\n", + sc_adapter[card]->devicename); + sc_adapter[card]->StartOnReset = 0; return (reset(card)); } @@ -44,10 +45,11 @@ int sc_ioctl(int card, scs_ioctl *data) char srec[SCIOC_SRECSIZE]; int status; - pr_debug("%s: SCIOLOAD: ioctl received\n", adapter[card]->devicename); - if(adapter[card]->EngineUp) { + pr_debug("%s: SCIOLOAD: ioctl received\n", + sc_adapter[card]->devicename); + if(sc_adapter[card]->EngineUp) { pr_debug("%s: SCIOCLOAD: command failed, LoadProc while engine running.\n", - adapter[card]->devicename); + sc_adapter[card]->devicename); return -1; } @@ -61,25 +63,27 @@ int sc_ioctl(int card, scs_ioctl *data) 0, sizeof(srec), srec, &rcvmsg, SAR_TIMEOUT); if(status) { pr_debug("%s: SCIOCLOAD: command failed, status = %d\n", - adapter[card]->devicename, status); + sc_adapter[card]->devicename, status); return -1; } else { - pr_debug("%s: SCIOCLOAD: command successful\n", adapter[card]->devicename); + pr_debug("%s: SCIOCLOAD: command successful\n", + sc_adapter[card]->devicename); return 0; } } case SCIOCSTART: { - pr_debug("%s: SCIOSTART: ioctl received\n", adapter[card]->devicename); - if(adapter[card]->EngineUp) { + pr_debug("%s: SCIOSTART: ioctl received\n", + sc_adapter[card]->devicename); + if(sc_adapter[card]->EngineUp) { pr_debug("%s: SCIOCSTART: command failed, engine already running.\n", - adapter[card]->devicename); + sc_adapter[card]->devicename); return -1; } - adapter[card]->StartOnReset = 1; + sc_adapter[card]->StartOnReset = 1; startproc(card); return 0; } @@ -90,7 +94,8 @@ int sc_ioctl(int card, scs_ioctl *data) char switchtype; int status; - pr_debug("%s: SCIOSETSWITCH: ioctl received\n", adapter[card]->devicename); + pr_debug("%s: SCIOSETSWITCH: ioctl received\n", + sc_adapter[card]->devicename); /* * Get the switch type from user space @@ -99,17 +104,19 @@ int sc_ioctl(int card, scs_ioctl *data) sizeof(char))) return -EFAULT; - pr_debug("%s: SCIOCSETSWITCH: setting switch type to %d\n", adapter[card]->devicename, + pr_debug("%s: SCIOCSETSWITCH: setting switch type to %d\n", + sc_adapter[card]->devicename, switchtype); status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallSetSwitchType, 0, sizeof(char),&switchtype,&rcvmsg, SAR_TIMEOUT); if(!status && !rcvmsg.rsp_status) { - pr_debug("%s: SCIOCSETSWITCH: command successful\n", adapter[card]->devicename); + pr_debug("%s: SCIOCSETSWITCH: command successful\n", + sc_adapter[card]->devicename); return 0; } else { pr_debug("%s: SCIOCSETSWITCH: command failed (status = %d)\n", - adapter[card]->devicename, status); + sc_adapter[card]->devicename, status); return status; } } @@ -120,7 +127,8 @@ int sc_ioctl(int card, scs_ioctl *data) char switchtype; int status; - pr_debug("%s: SCIOGETSWITCH: ioctl received\n", adapter[card]->devicename); + pr_debug("%s: SCIOGETSWITCH: ioctl received\n", + sc_adapter[card]->devicename); /* * Get the switch type from the board @@ -128,11 +136,12 @@ int sc_ioctl(int card, scs_ioctl *data) status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetSwitchType, 0, 0, 0, &rcvmsg, SAR_TIMEOUT); if (!status && !rcvmsg.rsp_status) { - pr_debug("%s: SCIOCGETSWITCH: command successful\n", adapter[card]->devicename); + pr_debug("%s: SCIOCGETSWITCH: command successful\n", + sc_adapter[card]->devicename); } else { pr_debug("%s: SCIOCGETSWITCH: command failed (status = %d)\n", - adapter[card]->devicename, status); + sc_adapter[card]->devicename, status); return status; } @@ -154,7 +163,8 @@ int sc_ioctl(int card, scs_ioctl *data) char spid[SCIOC_SPIDSIZE]; int status; - pr_debug("%s: SCIOGETSPID: ioctl received\n", adapter[card]->devicename); + pr_debug("%s: SCIOGETSPID: ioctl received\n", + sc_adapter[card]->devicename); /* * Get the spid from the board @@ -162,11 +172,12 @@ int sc_ioctl(int card, scs_ioctl *data) status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetSPID, data->channel, 0, 0, &rcvmsg, SAR_TIMEOUT); if (!status) { - pr_debug("%s: SCIOCGETSPID: command successful\n", adapter[card]->devicename); + pr_debug("%s: SCIOCGETSPID: command successful\n", + sc_adapter[card]->devicename); } else { pr_debug("%s: SCIOCGETSPID: command failed (status = %d)\n", - adapter[card]->devicename, status); + sc_adapter[card]->devicename, status); return status; } strcpy(spid, rcvmsg.msg_data.byte_array); @@ -186,7 +197,8 @@ int sc_ioctl(int card, scs_ioctl *data) char spid[SCIOC_SPIDSIZE]; int status; - pr_debug("%s: DCBIOSETSPID: ioctl received\n", adapter[card]->devicename); + pr_debug("%s: DCBIOSETSPID: ioctl received\n", + sc_adapter[card]->devicename); /* * Get the spid from user space @@ -195,18 +207,18 @@ int sc_ioctl(int card, scs_ioctl *data) return -EFAULT; pr_debug("%s: SCIOCSETSPID: setting channel %d spid to %s\n", - adapter[card]->devicename, data->channel, spid); + sc_adapter[card]->devicename, data->channel, spid); status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallSetSPID, data->channel, strlen(spid), spid, &rcvmsg, SAR_TIMEOUT); if(!status && !rcvmsg.rsp_status) { pr_debug("%s: SCIOCSETSPID: command successful\n", - adapter[card]->devicename); + sc_adapter[card]->devicename); return 0; } else { pr_debug("%s: SCIOCSETSPID: command failed (status = %d)\n", - adapter[card]->devicename, status); + sc_adapter[card]->devicename, status); return status; } } @@ -217,7 +229,8 @@ int sc_ioctl(int card, scs_ioctl *data) char dn[SCIOC_DNSIZE]; int status; - pr_debug("%s: SCIOGETDN: ioctl received\n", adapter[card]->devicename); + pr_debug("%s: SCIOGETDN: ioctl received\n", + sc_adapter[card]->devicename); /* * Get the dn from the board @@ -225,11 +238,12 @@ int sc_ioctl(int card, scs_ioctl *data) status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetMyNumber, data->channel, 0, 0, &rcvmsg, SAR_TIMEOUT); if (!status) { - pr_debug("%s: SCIOCGETDN: command successful\n", adapter[card]->devicename); + pr_debug("%s: SCIOCGETDN: command successful\n", + sc_adapter[card]->devicename); } else { pr_debug("%s: SCIOCGETDN: command failed (status = %d)\n", - adapter[card]->devicename, status); + sc_adapter[card]->devicename, status); return status; } @@ -250,7 +264,8 @@ int sc_ioctl(int card, scs_ioctl *data) char dn[SCIOC_DNSIZE]; int status; - pr_debug("%s: SCIOSETDN: ioctl received\n", adapter[card]->devicename); + pr_debug("%s: SCIOSETDN: ioctl received\n", + sc_adapter[card]->devicename); /* * Get the spid from user space @@ -259,35 +274,38 @@ int sc_ioctl(int card, scs_ioctl *data) return -EFAULT; pr_debug("%s: SCIOCSETDN: setting channel %d dn to %s\n", - adapter[card]->devicename, data->channel, dn); + sc_adapter[card]->devicename, data->channel, dn); status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallSetMyNumber, data->channel, strlen(dn),dn,&rcvmsg, SAR_TIMEOUT); if(!status && !rcvmsg.rsp_status) { pr_debug("%s: SCIOCSETDN: command successful\n", - adapter[card]->devicename); + sc_adapter[card]->devicename); return 0; } else { pr_debug("%s: SCIOCSETDN: command failed (status = %d)\n", - adapter[card]->devicename, status); + sc_adapter[card]->devicename, status); return status; } } case SCIOCTRACE: - pr_debug("%s: SCIOTRACE: ioctl received\n", adapter[card]->devicename); -/* adapter[card]->trace = !adapter[card]->trace; - pr_debug("%s: SCIOCTRACE: tracing turned %s\n", adapter[card]->devicename, - adapter[card]->trace ? "ON" : "OFF"); */ + pr_debug("%s: SCIOTRACE: ioctl received\n", + sc_adapter[card]->devicename); +/* sc_adapter[card]->trace = !sc_adapter[card]->trace; + pr_debug("%s: SCIOCTRACE: tracing turned %s\n", + sc_adapter[card]->devicename, + sc_adapter[card]->trace ? "ON" : "OFF"); */ break; case SCIOCSTAT: { boardInfo bi; - pr_debug("%s: SCIOSTAT: ioctl received\n", adapter[card]->devicename); + pr_debug("%s: SCIOSTAT: ioctl received\n", + sc_adapter[card]->devicename); GetStatus(card, &bi); if (copy_to_user((boardInfo *)data->dataptr, &bi, @@ -303,7 +321,8 @@ int sc_ioctl(int card, scs_ioctl *data) char speed; int status; - pr_debug("%s: SCIOGETSPEED: ioctl received\n", adapter[card]->devicename); + pr_debug("%s: SCIOGETSPEED: ioctl received\n", + sc_adapter[card]->devicename); /* * Get the speed from the board @@ -312,11 +331,11 @@ int sc_ioctl(int card, scs_ioctl *data) ceReqCallGetCallType, data->channel, 0, 0, &rcvmsg, SAR_TIMEOUT); if (!status && !rcvmsg.rsp_status) { pr_debug("%s: SCIOCGETSPEED: command successful\n", - adapter[card]->devicename); + sc_adapter[card]->devicename); } else { pr_debug("%s: SCIOCGETSPEED: command failed (status = %d)\n", - adapter[card]->devicename, status); + sc_adapter[card]->devicename, status); return status; } @@ -332,11 +351,13 @@ int sc_ioctl(int card, scs_ioctl *data) } case SCIOCSETSPEED: - pr_debug("%s: SCIOCSETSPEED: ioctl received\n", adapter[card]->devicename); + pr_debug("%s: SCIOCSETSPEED: ioctl received\n", + sc_adapter[card]->devicename); break; case SCIOCLOOPTST: - pr_debug("%s: SCIOCLOOPTST: ioctl received\n", adapter[card]->devicename); + pr_debug("%s: SCIOCLOOPTST: ioctl received\n", + sc_adapter[card]->devicename); break; default: @@ -354,16 +375,16 @@ int GetStatus(int card, boardInfo *bi) /* * Fill in some of the basic info about the board */ - bi->modelid = adapter[card]->model; - strcpy(bi->serial_no, adapter[card]->hwconfig.serial_no); - strcpy(bi->part_no, adapter[card]->hwconfig.part_no); - bi->iobase = adapter[card]->iobase; - bi->rambase = adapter[card]->rambase; - bi->irq = adapter[card]->interrupt; - bi->ramsize = adapter[card]->hwconfig.ram_size; - bi->interface = adapter[card]->hwconfig.st_u_sense; - strcpy(bi->load_ver, adapter[card]->load_ver); - strcpy(bi->proc_ver, adapter[card]->proc_ver); + bi->modelid = sc_adapter[card]->model; + strcpy(bi->serial_no, sc_adapter[card]->hwconfig.serial_no); + strcpy(bi->part_no, sc_adapter[card]->hwconfig.part_no); + bi->iobase = sc_adapter[card]->iobase; + bi->rambase = sc_adapter[card]->rambase; + bi->irq = sc_adapter[card]->interrupt; + bi->ramsize = sc_adapter[card]->hwconfig.ram_size; + bi->interface = sc_adapter[card]->hwconfig.st_u_sense; + strcpy(bi->load_ver, sc_adapter[card]->load_ver); + strcpy(bi->proc_ver, sc_adapter[card]->proc_ver); /* * Get the current PhyStats and LnkStats @@ -371,7 +392,7 @@ int GetStatus(int card, boardInfo *bi) status = send_and_receive(card, CEPID, ceReqTypePhy, ceReqClass2, ceReqPhyStatus, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); if(!status) { - if(adapter[card]->model < PRI_BOARD) { + if(sc_adapter[card]->model < PRI_BOARD) { bi->l1_status = rcvmsg.msg_data.byte_array[2]; for(i = 0 ; i < BRI_CHANNELS ; i++) bi->status.bristats[i].phy_stat = @@ -389,11 +410,11 @@ int GetStatus(int card, boardInfo *bi) /* * Get the call types for each channel */ - for (i = 0 ; i < adapter[card]->nChannels ; i++) { + for (i = 0 ; i < sc_adapter[card]->nChannels ; i++) { status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetCallType, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); if(!status) { - if (adapter[card]->model == PRI_BOARD) { + if (sc_adapter[card]->model == PRI_BOARD) { bi->status.pristats[i].call_type = rcvmsg.msg_data.byte_array[0]; } @@ -407,7 +428,7 @@ int GetStatus(int card, boardInfo *bi) /* * If PRI, get the call states and service states for each channel */ - if (adapter[card]->model == PRI_BOARD) { + if (sc_adapter[card]->model == PRI_BOARD) { /* * Get the call states */ diff -puN drivers/isdn/sc/message.c~i4l-sc-adapter-fix drivers/isdn/sc/message.c --- 25/drivers/isdn/sc/message.c~i4l-sc-adapter-fix 2004-02-10 02:06:13.000000000 -0800 +++ 25-akpm/drivers/isdn/sc/message.c 2004-02-10 02:14:09.000000000 -0800 @@ -22,7 +22,7 @@ #include "message.h" #include "card.h" -extern board *adapter[]; +extern board *sc_adapter[]; extern unsigned int cinst; /* @@ -46,31 +46,32 @@ int receivemessage(int card, RspMessage return -EINVAL; } - pr_debug("%s: Entered receivemessage\n",adapter[card]->devicename); + pr_debug("%s: Entered receivemessage\n", + sc_adapter[card]->devicename); /* * See if there are messages waiting */ - if (inb(adapter[card]->ioport[FIFO_STATUS]) & RF_HAS_DATA) { + if (inb(sc_adapter[card]->ioport[FIFO_STATUS]) & RF_HAS_DATA) { /* * Map in the DPM to the base page and copy the message */ - spin_lock_irqsave(&adapter[card]->lock, flags); - outb((adapter[card]->shmem_magic >> 14) | 0x80, - adapter[card]->ioport[adapter[card]->shmem_pgport]); - dpm = (DualPortMemory *) adapter[card]->rambase; + spin_lock_irqsave(&sc_adapter[card]->lock, flags); + outb((sc_adapter[card]->shmem_magic >> 14) | 0x80, + sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); + dpm = (DualPortMemory *) sc_adapter[card]->rambase; memcpy_fromio(rspmsg, &(dpm->rsp_queue[dpm->rsp_tail]), MSG_LEN); dpm->rsp_tail = (dpm->rsp_tail+1) % MAX_MESSAGES; - inb(adapter[card]->ioport[FIFO_READ]); - spin_unlock_irqrestore(&adapter[card]->lock, flags); + inb(sc_adapter[card]->ioport[FIFO_READ]); + spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); /* * Tell the board that the message is received */ pr_debug("%s: Received Message seq:%d pid:%d time:%d cmd:%d " "cnt:%d (type,class,code):(%d,%d,%d) " "link:%d stat:0x%x\n", - adapter[card]->devicename, + sc_adapter[card]->devicename, rspmsg->sequence_no, rspmsg->process_id, rspmsg->time_stamp, @@ -112,15 +113,15 @@ int sendmessage(int card, * Make sure we only send CEPID messages when the engine is up * and CMPID messages when it is down */ - if(adapter[card]->EngineUp && procid == CMPID) { + if(sc_adapter[card]->EngineUp && procid == CMPID) { pr_debug("%s: Attempt to send CM message with engine up\n", - adapter[card]->devicename); + sc_adapter[card]->devicename); return -ESRCH; } - if(!adapter[card]->EngineUp && procid == CEPID) { + if(!sc_adapter[card]->EngineUp && procid == CEPID) { pr_debug("%s: Attempt to send CE message with engine down\n", - adapter[card]->devicename); + sc_adapter[card]->devicename); return -ESRCH; } @@ -139,30 +140,30 @@ int sendmessage(int card, } sndmsg.process_id = procid; - sndmsg.sequence_no = adapter[card]->seq_no++ % 256; + sndmsg.sequence_no = sc_adapter[card]->seq_no++ % 256; /* * wait for an empty slot in the queue */ - while (!(inb(adapter[card]->ioport[FIFO_STATUS]) & WF_NOT_FULL)) + while (!(inb(sc_adapter[card]->ioport[FIFO_STATUS]) & WF_NOT_FULL)) udelay(1); /* * Disable interrupts and map in shared memory */ - spin_lock_irqsave(&adapter[card]->lock, flags); - outb((adapter[card]->shmem_magic >> 14) | 0x80, - adapter[card]->ioport[adapter[card]->shmem_pgport]); - dpm = (DualPortMemory *) adapter[card]->rambase; /* Fix me */ + spin_lock_irqsave(&sc_adapter[card]->lock, flags); + outb((sc_adapter[card]->shmem_magic >> 14) | 0x80, + sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); + dpm = (DualPortMemory *) sc_adapter[card]->rambase; /* Fix me */ memcpy_toio(&(dpm->req_queue[dpm->req_head]),&sndmsg,MSG_LEN); dpm->req_head = (dpm->req_head+1) % MAX_MESSAGES; - outb(sndmsg.sequence_no, adapter[card]->ioport[FIFO_WRITE]); - spin_unlock_irqrestore(&adapter[card]->lock, flags); + outb(sndmsg.sequence_no, sc_adapter[card]->ioport[FIFO_WRITE]); + spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); pr_debug("%s: Sent Message seq:%d pid:%d time:%d " "cnt:%d (type,class,code):(%d,%d,%d) " "link:%d\n ", - adapter[card]->devicename, + sc_adapter[card]->devicename, sndmsg.sequence_no, sndmsg.process_id, sndmsg.time_stamp, @@ -194,14 +195,14 @@ int send_and_receive(int card, return -EINVAL; } - adapter[card]->want_async_messages = 1; + sc_adapter[card]->want_async_messages = 1; retval = sendmessage(card, procid, type, class, code, link, data_len, (unsigned int *) data); if (retval) { pr_debug("%s: SendMessage failed in SAR\n", - adapter[card]->devicename); - adapter[card]->want_async_messages = 0; + sc_adapter[card]->devicename); + sc_adapter[card]->want_async_messages = 0; return -EIO; } @@ -216,26 +217,26 @@ int send_and_receive(int card, /* * See if we got our message back */ - if ((adapter[card]->async_msg.type == type) && - (adapter[card]->async_msg.class == class) && - (adapter[card]->async_msg.code == code) && - (adapter[card]->async_msg.phy_link_no == link)) { + if ((sc_adapter[card]->async_msg.type == type) && + (sc_adapter[card]->async_msg.class == class) && + (sc_adapter[card]->async_msg.code == code) && + (sc_adapter[card]->async_msg.phy_link_no == link)) { /* * Got it! */ pr_debug("%s: Got ASYNC message\n", - adapter[card]->devicename); - memcpy(mesgdata, &(adapter[card]->async_msg), + sc_adapter[card]->devicename); + memcpy(mesgdata, &(sc_adapter[card]->async_msg), sizeof(RspMessage)); - adapter[card]->want_async_messages = 0; + sc_adapter[card]->want_async_messages = 0; return 0; } tries++; } - pr_debug("%s: SAR message timeout\n", adapter[card]->devicename); - adapter[card]->want_async_messages = 0; + pr_debug("%s: SAR message timeout\n", sc_adapter[card]->devicename); + sc_adapter[card]->want_async_messages = 0; return -ETIME; } diff -puN drivers/isdn/sc/message.h~i4l-sc-adapter-fix drivers/isdn/sc/message.h diff -puN drivers/isdn/sc/packet.c~i4l-sc-adapter-fix drivers/isdn/sc/packet.c --- 25/drivers/isdn/sc/packet.c~i4l-sc-adapter-fix 2004-02-10 02:06:13.000000000 -0800 +++ 25-akpm/drivers/isdn/sc/packet.c 2004-02-10 02:15:45.000000000 -0800 @@ -20,7 +20,7 @@ #include "message.h" #include "card.h" -extern board *adapter[]; +extern board *sc_adapter[]; extern unsigned int cinst; extern int get_card_from_id(int); @@ -45,26 +45,29 @@ int sndpkt(int devId, int channel, struc } pr_debug("%s: sndpkt: frst = 0x%x nxt = %d f = %d n = %d\n", - adapter[card]->devicename, - adapter[card]->channel[channel].first_sendbuf, - adapter[card]->channel[channel].next_sendbuf, - adapter[card]->channel[channel].free_sendbufs, - adapter[card]->channel[channel].num_sendbufs); - - if(!adapter[card]->channel[channel].free_sendbufs) { - pr_debug("%s: out of TX buffers\n", adapter[card]->devicename); + sc_adapter[card]->devicename, + sc_adapter[card]->channel[channel].first_sendbuf, + sc_adapter[card]->channel[channel].next_sendbuf, + sc_adapter[card]->channel[channel].free_sendbufs, + sc_adapter[card]->channel[channel].num_sendbufs); + + if(!sc_adapter[card]->channel[channel].free_sendbufs) { + pr_debug("%s: out of TX buffers\n", + sc_adapter[card]->devicename); return -EINVAL; } if(data->len > BUFFER_SIZE) { - pr_debug("%s: data overflows buffer size (data > buffer)\n", adapter[card]->devicename); + pr_debug("%s: data overflows buffer size (data > buffer)\n", + sc_adapter[card]->devicename); return -EINVAL; } - ReqLnkWrite.buff_offset = adapter[card]->channel[channel].next_sendbuf * - BUFFER_SIZE + adapter[card]->channel[channel].first_sendbuf; + ReqLnkWrite.buff_offset = sc_adapter[card]->channel[channel].next_sendbuf * + BUFFER_SIZE + sc_adapter[card]->channel[channel].first_sendbuf; ReqLnkWrite.msg_len = data->len; /* sk_buff size */ - pr_debug("%s: writing %d bytes to buffer offset 0x%x\n", adapter[card]->devicename, + pr_debug("%s: writing %d bytes to buffer offset 0x%x\n", + sc_adapter[card]->devicename, ReqLnkWrite.msg_len, ReqLnkWrite.buff_offset); memcpy_toshmem(card, (char *)ReqLnkWrite.buff_offset, data->data, ReqLnkWrite.msg_len); @@ -72,24 +75,25 @@ int sndpkt(int devId, int channel, struc * sendmessage */ pr_debug("%s: sndpkt size=%d, buf_offset=0x%x buf_indx=%d\n", - adapter[card]->devicename, + sc_adapter[card]->devicename, ReqLnkWrite.msg_len, ReqLnkWrite.buff_offset, - adapter[card]->channel[channel].next_sendbuf); + sc_adapter[card]->channel[channel].next_sendbuf); status = sendmessage(card, CEPID, ceReqTypeLnk, ceReqClass1, ceReqLnkWrite, channel+1, sizeof(LLData), (unsigned int*)&ReqLnkWrite); len = data->len; if(status) { - pr_debug("%s: failed to send packet, status = %d\n", adapter[card]->devicename, status); + pr_debug("%s: failed to send packet, status = %d\n", + sc_adapter[card]->devicename, status); return -1; } else { - adapter[card]->channel[channel].free_sendbufs--; - adapter[card]->channel[channel].next_sendbuf = - ++adapter[card]->channel[channel].next_sendbuf == - adapter[card]->channel[channel].num_sendbufs ? 0 : - adapter[card]->channel[channel].next_sendbuf; - pr_debug("%s: packet sent successfully\n", adapter[card]->devicename); + sc_adapter[card]->channel[channel].free_sendbufs--; + sc_adapter[card]->channel[channel].next_sendbuf = + ++sc_adapter[card]->channel[channel].next_sendbuf == + sc_adapter[card]->channel[channel].num_sendbufs ? 0 : + sc_adapter[card]->channel[channel].next_sendbuf; + pr_debug("%s: packet sent successfully\n", sc_adapter[card]->devicename); dev_kfree_skb(data); indicate_status(card,ISDN_STAT_BSENT,channel, (char *)&len); } @@ -110,33 +114,37 @@ void rcvpkt(int card, RspMessage *rcvmsg case 0x01: case 0x02: case 0x70: - pr_debug("%s: error status code: 0x%x\n", adapter[card]->devicename, rcvmsg->rsp_status); + pr_debug("%s: error status code: 0x%x\n", + sc_adapter[card]->devicename, rcvmsg->rsp_status); return; case 0x00: if (!(skb = dev_alloc_skb(rcvmsg->msg_data.response.msg_len))) { printk(KERN_WARNING "%s: rcvpkt out of memory, dropping packet\n", - adapter[card]->devicename); + sc_adapter[card]->devicename); return; } skb_put(skb, rcvmsg->msg_data.response.msg_len); pr_debug("%s: getting data from offset: 0x%x\n", - adapter[card]->devicename,rcvmsg->msg_data.response.buff_offset); + sc_adapter[card]->devicename, + rcvmsg->msg_data.response.buff_offset); memcpy_fromshmem(card, skb_put(skb, rcvmsg->msg_data.response.msg_len), (char *)rcvmsg->msg_data.response.buff_offset, rcvmsg->msg_data.response.msg_len); - adapter[card]->card->rcvcallb_skb(adapter[card]->driverId, + sc_adapter[card]->card->rcvcallb_skb(sc_adapter[card]->driverId, rcvmsg->phy_link_no-1, skb); case 0x03: /* * Recycle the buffer */ - pr_debug("%s: buffer size : %d\n", adapter[card]->devicename, BUFFER_SIZE); + pr_debug("%s: buffer size : %d\n", + sc_adapter[card]->devicename, BUFFER_SIZE); /* memset_shmem(card, rcvmsg->msg_data.response.buff_offset, 0, BUFFER_SIZE); */ newll.buff_offset = rcvmsg->msg_data.response.buff_offset; newll.msg_len = BUFFER_SIZE; - pr_debug("%s: recycled buffer at offset 0x%x size %d\n", adapter[card]->devicename, + pr_debug("%s: recycled buffer at offset 0x%x size %d\n", + sc_adapter[card]->devicename, newll.buff_offset, newll.msg_len); sendmessage(card, CEPID, ceReqTypeLnk, ceReqClass1, ceReqLnkRead, rcvmsg->phy_link_no, sizeof(LLData), (unsigned int *)&newll); @@ -158,40 +166,45 @@ int setup_buffers(int card, int c) /* * Calculate the buffer offsets (send/recv/send/recv) */ - pr_debug("%s: setting up channel buffer space in shared RAM\n", adapter[card]->devicename); + pr_debug("%s: setting up channel buffer space in shared RAM\n", + sc_adapter[card]->devicename); buffer_size = BUFFER_SIZE; - nBuffers = ((adapter[card]->ramsize - BUFFER_BASE) / buffer_size) / 2; + nBuffers = ((sc_adapter[card]->ramsize - BUFFER_BASE) / buffer_size) / 2; nBuffers = nBuffers > BUFFERS_MAX ? BUFFERS_MAX : nBuffers; - pr_debug("%s: calculating buffer space: %d buffers, %d big\n", adapter[card]->devicename, + pr_debug("%s: calculating buffer space: %d buffers, %d big\n", + sc_adapter[card]->devicename, nBuffers, buffer_size); if(nBuffers < 2) { - pr_debug("%s: not enough buffer space\n", adapter[card]->devicename); + pr_debug("%s: not enough buffer space\n", + sc_adapter[card]->devicename); return -1; } cBase = (nBuffers * buffer_size) * (c - 1); - pr_debug("%s: channel buffer offset from shared RAM: 0x%x\n", adapter[card]->devicename, cBase); - adapter[card]->channel[c-1].first_sendbuf = BUFFER_BASE + cBase; - adapter[card]->channel[c-1].num_sendbufs = nBuffers / 2; - adapter[card]->channel[c-1].free_sendbufs = nBuffers / 2; - adapter[card]->channel[c-1].next_sendbuf = 0; + pr_debug("%s: channel buffer offset from shared RAM: 0x%x\n", + sc_adapter[card]->devicename, cBase); + sc_adapter[card]->channel[c-1].first_sendbuf = BUFFER_BASE + cBase; + sc_adapter[card]->channel[c-1].num_sendbufs = nBuffers / 2; + sc_adapter[card]->channel[c-1].free_sendbufs = nBuffers / 2; + sc_adapter[card]->channel[c-1].next_sendbuf = 0; pr_debug("%s: send buffer setup complete: first=0x%x n=%d f=%d, nxt=%d\n", - adapter[card]->devicename, - adapter[card]->channel[c-1].first_sendbuf, - adapter[card]->channel[c-1].num_sendbufs, - adapter[card]->channel[c-1].free_sendbufs, - adapter[card]->channel[c-1].next_sendbuf); + sc_adapter[card]->devicename, + sc_adapter[card]->channel[c-1].first_sendbuf, + sc_adapter[card]->channel[c-1].num_sendbufs, + sc_adapter[card]->channel[c-1].free_sendbufs, + sc_adapter[card]->channel[c-1].next_sendbuf); /* * Prep the receive buffers */ - pr_debug("%s: adding %d RecvBuffers:\n", adapter[card]->devicename, nBuffers /2); + pr_debug("%s: adding %d RecvBuffers:\n", + sc_adapter[card]->devicename, nBuffers /2); for (i = 0 ; i < nBuffers / 2; i++) { RcvBuffOffset.buff_offset = - ((adapter[card]->channel[c-1].first_sendbuf + + ((sc_adapter[card]->channel[c-1].first_sendbuf + (nBuffers / 2) * buffer_size) + (buffer_size * i)); RcvBuffOffset.msg_len = buffer_size; pr_debug("%s: adding RcvBuffer #%d offset=0x%x sz=%d bufsz:%d\n", - adapter[card]->devicename, + sc_adapter[card]->devicename, i + 1, RcvBuffOffset.buff_offset, RcvBuffOffset.msg_len,buffer_size); sendmessage(card, CEPID, ceReqTypeLnk, ceReqClass1, ceReqLnkRead, @@ -202,11 +215,11 @@ int setup_buffers(int card, int c) int print_skb(int card,char *skb_p, int len){ int i,data; - pr_debug("%s: data at 0x%x len: 0x%x\n",adapter[card]->devicename, + pr_debug("%s: data at 0x%x len: 0x%x\n", sc_adapter[card]->devicename, skb_p,len); for(i=1;i<=len;i++,skb_p++){ data = (int) (0xff & (*skb_p)); - pr_debug("%s: data = 0x%x",adapter[card]->devicename,data); + pr_debug("%s: data = 0x%x", sc_adapter[card]->devicename,data); if(!(i%4)) pr_debug(" "); if(!(i%32)) diff -puN drivers/isdn/sc/shmem.c~i4l-sc-adapter-fix drivers/isdn/sc/shmem.c --- 25/drivers/isdn/sc/shmem.c~i4l-sc-adapter-fix 2004-02-10 02:06:13.000000000 -0800 +++ 25-akpm/drivers/isdn/sc/shmem.c 2004-02-10 02:16:35.000000000 -0800 @@ -24,7 +24,7 @@ /* * Main adapter array */ -extern board *adapter[]; +extern board *sc_adapter[]; extern int cinst; /* @@ -49,21 +49,23 @@ void *memcpy_toshmem(int card, void *des * determine the page to load from the address */ ch = (unsigned long) dest / SRAM_PAGESIZE; - pr_debug("%s: loaded page %d\n",adapter[card]->devicename,ch); + pr_debug("%s: loaded page %d\n", sc_adapter[card]->devicename,ch); /* * Block interrupts and load the page */ - spin_lock_irqsave(&adapter[card]->lock, flags); + spin_lock_irqsave(&sc_adapter[card]->lock, flags); - outb(((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80, - adapter[card]->ioport[adapter[card]->shmem_pgport]); - ret = memcpy_toio(adapter[card]->rambase + + outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80, + sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); + ret = memcpy_toio(sc_adapter[card]->rambase + ((unsigned long) dest % 0x4000), src, n); - spin_unlock_irqrestore(&adapter[card]->lock, flags); - pr_debug("%s: set page to %#x\n",adapter[card]->devicename, - ((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80); - pr_debug("%s: copying %d bytes from %#x to %#x\n",adapter[card]->devicename, n, - (unsigned long) src, adapter[card]->rambase + ((unsigned long) dest %0x4000)); + spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); + pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename, + ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80); + pr_debug("%s: copying %d bytes from %#x to %#x\n", + sc_adapter[card]->devicename, n, + (unsigned long) src, + sc_adapter[card]->rambase + ((unsigned long) dest %0x4000)); return ret; } @@ -90,24 +92,24 @@ void *memcpy_fromshmem(int card, void *d * determine the page to load from the address */ ch = (unsigned long) src / SRAM_PAGESIZE; - pr_debug("%s: loaded page %d\n",adapter[card]->devicename,ch); + pr_debug("%s: loaded page %d\n", sc_adapter[card]->devicename,ch); /* * Block interrupts and load the page */ - spin_lock_irqsave(&adapter[card]->lock, flags); + spin_lock_irqsave(&sc_adapter[card]->lock, flags); - outb(((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80, - adapter[card]->ioport[adapter[card]->shmem_pgport]); - ret = memcpy_fromio(dest,(void *)(adapter[card]->rambase + + outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80, + sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); + ret = memcpy_fromio(dest,(void *)(sc_adapter[card]->rambase + ((unsigned long) src % 0x4000)), n); - spin_unlock_irqrestore(&adapter[card]->lock, flags); - pr_debug("%s: set page to %#x\n",adapter[card]->devicename, - ((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80); + spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); + pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename, + ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80); /* pr_debug("%s: copying %d bytes from %#x to %#x\n", - adapter[card]->devicename, n, - adapter[card]->rambase + ((unsigned long) src %0x4000), (unsigned long) dest); */ + sc_adapter[card]->devicename, n, + sc_adapter[card]->rambase + ((unsigned long) src %0x4000), (unsigned long) dest); */ return ret; } @@ -131,20 +133,20 @@ void *memset_shmem(int card, void *dest, * determine the page to load from the address */ ch = (unsigned long) dest / SRAM_PAGESIZE; - pr_debug("%s: loaded page %d\n",adapter[card]->devicename,ch); + pr_debug("%s: loaded page %d\n",sc_adapter[card]->devicename,ch); /* * Block interrupts and load the page */ - spin_lock_irqsave(&adapter[card]->lock, flags); + spin_lock_irqsave(&sc_adapter[card]->lock, flags); - outb(((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80, - adapter[card]->ioport[adapter[card]->shmem_pgport]); - ret = memset_io(adapter[card]->rambase + + outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80, + sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); + ret = memset_io(sc_adapter[card]->rambase + ((unsigned long) dest % 0x4000), c, n); - pr_debug("%s: set page to %#x\n",adapter[card]->devicename, - ((adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80); - spin_unlock_irqrestore(&adapter[card]->lock, flags); + pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename, + ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80); + spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); return ret; } diff -puN drivers/isdn/sc/timer.c~i4l-sc-adapter-fix drivers/isdn/sc/timer.c --- 25/drivers/isdn/sc/timer.c~i4l-sc-adapter-fix 2004-02-10 02:06:13.000000000 -0800 +++ 25-akpm/drivers/isdn/sc/timer.c 2004-02-10 02:17:13.000000000 -0800 @@ -20,7 +20,7 @@ #include "message.h" #include "card.h" -extern board *adapter[]; +extern board *sc_adapter[]; extern void flushreadfifo(int); extern int startproc(int); @@ -35,11 +35,11 @@ extern int sendmessage(int, unsigned in void setup_ports(int card) { - outb((adapter[card]->rambase >> 12), adapter[card]->ioport[EXP_BASE]); + outb((sc_adapter[card]->rambase >> 12), sc_adapter[card]->ioport[EXP_BASE]); /* And the IRQ */ - outb((adapter[card]->interrupt | 0x80), - adapter[card]->ioport[IRQ_SELECT]); + outb((sc_adapter[card]->interrupt | 0x80), + sc_adapter[card]->ioport[IRQ_SELECT]); } /* @@ -57,28 +57,29 @@ void check_reset(unsigned long data) unsigned long sig; int card = (unsigned int) data; - pr_debug("%s: check_timer timer called\n", adapter[card]->devicename); + pr_debug("%s: check_timer timer called\n", + sc_adapter[card]->devicename); /* Setup the io ports */ setup_ports(card); - spin_lock_irqsave(&adapter[card]->lock, flags); - outb(adapter[card]->ioport[adapter[card]->shmem_pgport], - (adapter[card]->shmem_magic>>14) | 0x80); - sig = (unsigned long) *((unsigned long *)(adapter[card]->rambase + SIG_OFFSET)); + spin_lock_irqsave(&sc_adapter[card]->lock, flags); + outb(sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport], + (sc_adapter[card]->shmem_magic>>14) | 0x80); + sig = (unsigned long) *((unsigned long *)(sc_adapter[card]->rambase + SIG_OFFSET)); /* check the signature */ if(sig == SIGNATURE) { flushreadfifo(card); - spin_unlock_irqrestore(&adapter[card]->lock, flags); + spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); /* See if we need to do a startproc */ - if (adapter[card]->StartOnReset) + if (sc_adapter[card]->StartOnReset) startproc(card); } else { pr_debug("%s: No signature yet, waiting another %d jiffies.\n", - adapter[card]->devicename, CHECKRESET_TIME); - mod_timer(&adapter[card]->reset_timer, jiffies+CHECKRESET_TIME); - spin_unlock_irqrestore(&adapter[card]->lock, flags); + sc_adapter[card]->devicename, CHECKRESET_TIME); + mod_timer(&sc_adapter[card]->reset_timer, jiffies+CHECKRESET_TIME); + spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); } } @@ -87,7 +88,7 @@ void check_reset(unsigned long data) * Must be very fast as this function runs in the context of * an interrupt handler. * - * Send check adapter->phystat to see if the channels are up + * Send check sc_adapter->phystat to see if the channels are up * If they are, tell ISDN4Linux that the board is up. If not, * tell IADN4Linux that it is up. Always reset the timer to * fire again (endless loop). @@ -97,31 +98,31 @@ void check_phystat(unsigned long data) unsigned long flags; int card = (unsigned int) data; - pr_debug("%s: Checking status...\n", adapter[card]->devicename); + pr_debug("%s: Checking status...\n", sc_adapter[card]->devicename); /* * check the results of the last PhyStat and change only if * has changed drastically */ - if (adapter[card]->nphystat && !adapter[card]->phystat) { /* All is well */ + if (sc_adapter[card]->nphystat && !sc_adapter[card]->phystat) { /* All is well */ pr_debug("PhyStat transition to RUN\n"); pr_info("%s: Switch contacted, transmitter enabled\n", - adapter[card]->devicename); + sc_adapter[card]->devicename); indicate_status(card, ISDN_STAT_RUN, 0, NULL); } - else if (!adapter[card]->nphystat && adapter[card]->phystat) { /* All is not well */ + else if (!sc_adapter[card]->nphystat && sc_adapter[card]->phystat) { /* All is not well */ pr_debug("PhyStat transition to STOP\n"); pr_info("%s: Switch connection lost, transmitter disabled\n", - adapter[card]->devicename); + sc_adapter[card]->devicename); indicate_status(card, ISDN_STAT_STOP, 0, NULL); } - adapter[card]->phystat = adapter[card]->nphystat; + sc_adapter[card]->phystat = sc_adapter[card]->nphystat; /* Reinitialize the timer */ - spin_lock_irqsave(&adapter[card]->lock, flags); - mod_timer(&adapter[card]->stat_timer, jiffies+CHECKSTAT_TIME); - spin_unlock_irqrestore(&adapter[card]->lock, flags); + spin_lock_irqsave(&sc_adapter[card]->lock, flags); + mod_timer(&sc_adapter[card]->stat_timer, jiffies+CHECKSTAT_TIME); + spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); /* Send a new cePhyStatus message */ sendmessage(card, CEPID,ceReqTypePhy,ceReqClass2, _