diff options
author | Joe Perches <joe@perches.com> | 2012-02-19 19:52:38 -0800 |
---|---|---|
committer | Joe Perches <joe@perches.com> | 2012-02-21 09:04:01 -0800 |
commit | 475be4d85a274d0961593db41cf85689db1d583c (patch) | |
tree | b2b8931eb747794730522c3cf1898e46948527b9 /drivers/isdn/icn | |
parent | 0b0a635f79f91f3755b6518627ea06dd0dbfd523 (diff) |
isdn: whitespace coding style cleanup
isdn source code uses a not-current coding style.
Update the coding style used on a per-line basis
so that git diff -w shows only elided blank lines
at EOF.
Done with emacs and some scripts and some typing.
Built x86 allyesconfig.
No detected change in objdump -d or size.
Signed-off-by: Joe Perches <joe@perches.com>
Diffstat (limited to 'drivers/isdn/icn')
-rw-r--r-- | drivers/isdn/icn/icn.c | 806 | ||||
-rw-r--r-- | drivers/isdn/icn/icn.h | 32 |
2 files changed, 419 insertions, 419 deletions
diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c index 1f355bb85e54..e74df7c4658f 100644 --- a/drivers/isdn/icn/icn.c +++ b/drivers/isdn/icn/icn.c @@ -54,7 +54,7 @@ static int icn_addcard(int, char *, char *); * channel = channel number */ static void -icn_free_queue(icn_card * card, int channel) +icn_free_queue(icn_card *card, int channel) { struct sk_buff_head *queue = &card->spqueue[channel]; struct sk_buff *skb; @@ -93,7 +93,7 @@ icn_shiftout(unsigned short port, * disable a cards shared memory */ static inline void -icn_disable_ram(icn_card * card) +icn_disable_ram(icn_card *card) { OUTB_P(0, ICN_MAPRAM); } @@ -102,7 +102,7 @@ icn_disable_ram(icn_card * card) * enable a cards shared memory */ static inline void -icn_enable_ram(icn_card * card) +icn_enable_ram(icn_card *card) { OUTB_P(0xff, ICN_MAPRAM); } @@ -113,7 +113,7 @@ icn_enable_ram(icn_card * card) * must called with holding the devlock */ static inline void -icn_map_channel(icn_card * card, int channel) +icn_map_channel(icn_card *card, int channel) { #ifdef MAP_DEBUG printk(KERN_DEBUG "icn_map_channel %d %d\n", dev.channel, channel); @@ -139,7 +139,7 @@ icn_map_channel(icn_card * card, int channel) * must called with holding the devlock */ static inline int -icn_lock_channel(icn_card * card, int channel) +icn_lock_channel(icn_card *card, int channel) { register int retval; @@ -194,7 +194,7 @@ icn_release_channel(void) * Return 1 on success, 0 on failure. */ static inline int -icn_trymaplock_channel(icn_card * card, int channel) +icn_trymaplock_channel(icn_card *card, int channel) { ulong flags; @@ -225,7 +225,7 @@ icn_trymaplock_channel(icn_card * card, int channel) * then map same or other channel without locking. */ static inline void -icn_maprelease_channel(icn_card * card, int channel) +icn_maprelease_channel(icn_card *card, int channel) { ulong flags; @@ -246,7 +246,7 @@ icn_maprelease_channel(icn_card * card, int channel) */ static void -icn_pollbchan_receive(int channel, icn_card * card) +icn_pollbchan_receive(int channel, icn_card *card) { int mch = channel + ((card->secondhalf) ? 2 : 0); int eflag; @@ -297,7 +297,7 @@ icn_pollbchan_receive(int channel, icn_card * card) */ static void -icn_pollbchan_send(int channel, icn_card * card) +icn_pollbchan_send(int channel, icn_card *card) { int mch = channel + ((card->secondhalf) ? 2 : 0); int cnt; @@ -309,7 +309,7 @@ icn_pollbchan_send(int channel, icn_card * card) !skb_queue_empty(&card->spqueue[channel]))) return; if (icn_trymaplock_channel(card, mch)) { - while (sbfree && + while (sbfree && (card->sndcount[channel] || !skb_queue_empty(&card->spqueue[channel]) || card->xskb[channel])) { @@ -327,7 +327,7 @@ icn_pollbchan_send(int channel, icn_card * card) /* Pop ACK-flag off skb. * Store length to xlen. */ - if (*(skb_pull(skb,1))) + if (*(skb_pull(skb, 1))) card->xlen[channel] = skb->len; else card->xlen[channel] = 0; @@ -396,7 +396,7 @@ icn_pollbchan(unsigned long data) if (card->flags & (ICN_FLAGS_B1ACTIVE | ICN_FLAGS_B2ACTIVE)) { /* schedule b-channel polling again */ spin_lock_irqsave(&card->lock, flags); - mod_timer(&card->rb_timer, jiffies+ICN_TIMER_BCREAD); + mod_timer(&card->rb_timer, jiffies + ICN_TIMER_BCREAD); card->flags |= ICN_FLAGS_RBTIMER; spin_unlock_irqrestore(&card->lock, flags); } else @@ -428,7 +428,7 @@ static icn_stat icn_stat_table[] = {"E_L1: ACT FAIL", ISDN_STAT_BHUP, 8}, /* Layer-1 activation failed */ {"E_L2: DATA LIN", ISDN_STAT_BHUP, 8}, /* Layer-2 data link lost */ {"E_L1: ACTIVATION FAILED", - ISDN_STAT_BHUP, 8}, /* Layer-1 activation failed */ + ISDN_STAT_BHUP, 8}, /* Layer-1 activation failed */ {NULL, 0, -1} }; /* *INDENT-ON* */ @@ -445,7 +445,7 @@ static icn_stat icn_stat_table[] = */ static void -icn_parse_status(u_char * status, int channel, icn_card * card) +icn_parse_status(u_char *status, int channel, icn_card *card) { icn_stat *s = icn_stat_table; int action = -1; @@ -465,128 +465,128 @@ icn_parse_status(u_char * status, int channel, icn_card * card) cmd.driver = card->myid; cmd.arg = channel; switch (action) { - case 11: - spin_lock_irqsave(&card->lock, flags); - icn_free_queue(card,channel); - card->rcvidx[channel] = 0; - - if (card->flags & - ((channel)?ICN_FLAGS_B2ACTIVE:ICN_FLAGS_B1ACTIVE)) { - - isdn_ctrl ncmd; - - card->flags &= ~((channel)? - ICN_FLAGS_B2ACTIVE:ICN_FLAGS_B1ACTIVE); - - memset(&ncmd, 0, sizeof(ncmd)); - - ncmd.driver = card->myid; - ncmd.arg = channel; - ncmd.command = ISDN_STAT_BHUP; - spin_unlock_irqrestore(&card->lock, flags); - card->interface.statcallb(&cmd); - } else - spin_unlock_irqrestore(&card->lock, flags); - break; - case 1: - spin_lock_irqsave(&card->lock, flags); - icn_free_queue(card,channel); - card->flags |= (channel) ? - ICN_FLAGS_B2ACTIVE : ICN_FLAGS_B1ACTIVE; - spin_unlock_irqrestore(&card->lock, flags); - break; - case 2: - spin_lock_irqsave(&card->lock, flags); + case 11: + spin_lock_irqsave(&card->lock, flags); + icn_free_queue(card, channel); + card->rcvidx[channel] = 0; + + if (card->flags & + ((channel) ? ICN_FLAGS_B2ACTIVE : ICN_FLAGS_B1ACTIVE)) { + + isdn_ctrl ncmd; + card->flags &= ~((channel) ? - ICN_FLAGS_B2ACTIVE : ICN_FLAGS_B1ACTIVE); - icn_free_queue(card, channel); - card->rcvidx[channel] = 0; - spin_unlock_irqrestore(&card->lock, flags); - break; - case 3: - { - char *t = status + 6; - char *s = strchr(t, ','); - - *s++ = '\0'; - strlcpy(cmd.parm.setup.phone, t, - sizeof(cmd.parm.setup.phone)); - s = strchr(t = s, ','); - *s++ = '\0'; - if (!strlen(t)) - cmd.parm.setup.si1 = 0; - else - cmd.parm.setup.si1 = - simple_strtoul(t, NULL, 10); - s = strchr(t = s, ','); - *s++ = '\0'; - if (!strlen(t)) - cmd.parm.setup.si2 = 0; - else - cmd.parm.setup.si2 = - simple_strtoul(t, NULL, 10); - strlcpy(cmd.parm.setup.eazmsn, s, - sizeof(cmd.parm.setup.eazmsn)); - } - cmd.parm.setup.plan = 0; - cmd.parm.setup.screen = 0; - break; - case 4: - sprintf(cmd.parm.setup.phone, "LEASED%d", card->myid); - sprintf(cmd.parm.setup.eazmsn, "%d", channel + 1); - cmd.parm.setup.si1 = 7; - cmd.parm.setup.si2 = 0; - cmd.parm.setup.plan = 0; - cmd.parm.setup.screen = 0; - break; - case 5: - strlcpy(cmd.parm.num, status + 3, sizeof(cmd.parm.num)); - break; - case 6: - snprintf(cmd.parm.num, sizeof(cmd.parm.num), "%d", - (int) simple_strtoul(status + 7, NULL, 16)); - break; - case 7: - status += 3; - if (strlen(status) == 4) - snprintf(cmd.parm.num, sizeof(cmd.parm.num), "%s%c%c", - status + 2, *status, *(status + 1)); - else - strlcpy(cmd.parm.num, status + 1, sizeof(cmd.parm.num)); - break; - case 8: - spin_lock_irqsave(&card->lock, flags); - card->flags &= ~ICN_FLAGS_B1ACTIVE; - icn_free_queue(card, 0); - card->rcvidx[0] = 0; + ICN_FLAGS_B2ACTIVE : ICN_FLAGS_B1ACTIVE); + + memset(&ncmd, 0, sizeof(ncmd)); + + ncmd.driver = card->myid; + ncmd.arg = channel; + ncmd.command = ISDN_STAT_BHUP; spin_unlock_irqrestore(&card->lock, flags); - cmd.arg = 0; - cmd.driver = card->myid; - card->interface.statcallb(&cmd); - cmd.command = ISDN_STAT_DHUP; - cmd.arg = 0; - cmd.driver = card->myid; card->interface.statcallb(&cmd); - cmd.command = ISDN_STAT_BHUP; - spin_lock_irqsave(&card->lock, flags); - card->flags &= ~ICN_FLAGS_B2ACTIVE; - icn_free_queue(card, 1); - card->rcvidx[1] = 0; + } else spin_unlock_irqrestore(&card->lock, flags); - cmd.arg = 1; - cmd.driver = card->myid; - card->interface.statcallb(&cmd); - cmd.command = ISDN_STAT_DHUP; - cmd.arg = 1; - cmd.driver = card->myid; - break; + break; + case 1: + spin_lock_irqsave(&card->lock, flags); + icn_free_queue(card, channel); + card->flags |= (channel) ? + ICN_FLAGS_B2ACTIVE : ICN_FLAGS_B1ACTIVE; + spin_unlock_irqrestore(&card->lock, flags); + break; + case 2: + spin_lock_irqsave(&card->lock, flags); + card->flags &= ~((channel) ? + ICN_FLAGS_B2ACTIVE : ICN_FLAGS_B1ACTIVE); + icn_free_queue(card, channel); + card->rcvidx[channel] = 0; + spin_unlock_irqrestore(&card->lock, flags); + break; + case 3: + { + char *t = status + 6; + char *s = strchr(t, ','); + + *s++ = '\0'; + strlcpy(cmd.parm.setup.phone, t, + sizeof(cmd.parm.setup.phone)); + s = strchr(t = s, ','); + *s++ = '\0'; + if (!strlen(t)) + cmd.parm.setup.si1 = 0; + else + cmd.parm.setup.si1 = + simple_strtoul(t, NULL, 10); + s = strchr(t = s, ','); + *s++ = '\0'; + if (!strlen(t)) + cmd.parm.setup.si2 = 0; + else + cmd.parm.setup.si2 = + simple_strtoul(t, NULL, 10); + strlcpy(cmd.parm.setup.eazmsn, s, + sizeof(cmd.parm.setup.eazmsn)); + } + cmd.parm.setup.plan = 0; + cmd.parm.setup.screen = 0; + break; + case 4: + sprintf(cmd.parm.setup.phone, "LEASED%d", card->myid); + sprintf(cmd.parm.setup.eazmsn, "%d", channel + 1); + cmd.parm.setup.si1 = 7; + cmd.parm.setup.si2 = 0; + cmd.parm.setup.plan = 0; + cmd.parm.setup.screen = 0; + break; + case 5: + strlcpy(cmd.parm.num, status + 3, sizeof(cmd.parm.num)); + break; + case 6: + snprintf(cmd.parm.num, sizeof(cmd.parm.num), "%d", + (int) simple_strtoul(status + 7, NULL, 16)); + break; + case 7: + status += 3; + if (strlen(status) == 4) + snprintf(cmd.parm.num, sizeof(cmd.parm.num), "%s%c%c", + status + 2, *status, *(status + 1)); + else + strlcpy(cmd.parm.num, status + 1, sizeof(cmd.parm.num)); + break; + case 8: + spin_lock_irqsave(&card->lock, flags); + card->flags &= ~ICN_FLAGS_B1ACTIVE; + icn_free_queue(card, 0); + card->rcvidx[0] = 0; + spin_unlock_irqrestore(&card->lock, flags); + cmd.arg = 0; + cmd.driver = card->myid; + card->interface.statcallb(&cmd); + cmd.command = ISDN_STAT_DHUP; + cmd.arg = 0; + cmd.driver = card->myid; + card->interface.statcallb(&cmd); + cmd.command = ISDN_STAT_BHUP; + spin_lock_irqsave(&card->lock, flags); + card->flags &= ~ICN_FLAGS_B2ACTIVE; + icn_free_queue(card, 1); + card->rcvidx[1] = 0; + spin_unlock_irqrestore(&card->lock, flags); + cmd.arg = 1; + cmd.driver = card->myid; + card->interface.statcallb(&cmd); + cmd.command = ISDN_STAT_DHUP; + cmd.arg = 1; + cmd.driver = card->myid; + break; } card->interface.statcallb(&cmd); return; } static void -icn_putmsg(icn_card * card, unsigned char c) +icn_putmsg(icn_card *card, unsigned char c) { ulong flags; @@ -688,7 +688,7 @@ icn_polldchan(unsigned long data) add_timer(&card->rb_timer); } /* schedule again */ - mod_timer(&card->st_timer, jiffies+ICN_TIMER_DCREAD); + mod_timer(&card->st_timer, jiffies + ICN_TIMER_DCREAD); spin_unlock_irqrestore(&card->lock, flags); } @@ -702,7 +702,7 @@ icn_polldchan(unsigned long data) */ static int -icn_sendbuf(int channel, int ack, struct sk_buff *skb, icn_card * card) +icn_sendbuf(int channel, int ack, struct sk_buff *skb, icn_card *card) { int len = skb->len; unsigned long flags; @@ -718,13 +718,13 @@ icn_sendbuf(int channel, int ack, struct sk_buff *skb, icn_card * card) return 0; if (card->sndcount[channel] > ICN_MAX_SQUEUE) return 0; - #warning TODO test headroom or use skb->nb to flag ACK +#warning TODO test headroom or use skb->nb to flag ACK nskb = skb_clone(skb, GFP_ATOMIC); if (nskb) { /* Push ACK flag as one * byte in front of data. */ - *(skb_push(nskb, 1)) = ack?1:0; + *(skb_push(nskb, 1)) = ack ? 1 : 0; skb_queue_tail(&card->spqueue[channel], nskb); dev_kfree_skb(skb); } else @@ -785,20 +785,20 @@ icn_check_loader(int cardnumber) */ #ifdef BOOT_DEBUG -#define SLEEP(sec) { \ -int slsec = sec; \ - printk(KERN_DEBUG "SLEEP(%d)\n",slsec); \ - while (slsec) { \ - msleep_interruptible(1000); \ - slsec--; \ - } \ -} +#define SLEEP(sec) { \ + int slsec = sec; \ + printk(KERN_DEBUG "SLEEP(%d)\n", slsec); \ + while (slsec) { \ + msleep_interruptible(1000); \ + slsec--; \ + } \ + } #else #define SLEEP(sec) #endif static int -icn_loadboot(u_char __user * buffer, icn_card * card) +icn_loadboot(u_char __user *buffer, icn_card *card) { int ret; u_char *codebuf; @@ -896,14 +896,14 @@ icn_loadboot(u_char __user * buffer, icn_card * card) SLEEP(1); ret = (icn_check_loader(1)); - out_kfree: +out_kfree: kfree(codebuf); - out: +out: return ret; } static int -icn_loadproto(u_char __user * buffer, icn_card * card) +icn_loadproto(u_char __user *buffer, icn_card *card) { register u_char __user *p = buffer; u_char codebuf[256]; @@ -1004,7 +1004,7 @@ icn_loadproto(u_char __user * buffer, icn_card * card) /* Read the Status-replies from the Interface */ static int -icn_readstatus(u_char __user *buf, int len, icn_card * card) +icn_readstatus(u_char __user *buf, int len, icn_card *card) { int count; u_char __user *p; @@ -1022,7 +1022,7 @@ icn_readstatus(u_char __user *buf, int len, icn_card * card) /* Put command-strings into the command-queue of the Interface */ static int -icn_writecmd(const u_char * buf, int len, int user, icn_card * card) +icn_writecmd(const u_char *buf, int len, int user, icn_card *card) { int mch = card->secondhalf ? 2 : 0; int pp; @@ -1057,9 +1057,9 @@ icn_writecmd(const u_char * buf, int len, int user, icn_card * card) icn_putmsg(card, '>'); for (p = msg, pp = readb(&cmd_i), i = count; i > 0; i--, p++, pp - ++) { + ++) { writeb((*p == '\n') ? 0xff : *p, - &dev.shmem->comm_buffers.pcio_buf[pp & 0xff]); + &dev.shmem->comm_buffers.pcio_buf[pp & 0xff]); len--; xcount++; icn_putmsg(card, *p); @@ -1093,7 +1093,7 @@ icn_writecmd(const u_char * buf, int len, int user, icn_card * card) * Delete card's pending timers, send STOP to linklevel */ static void -icn_stopcard(icn_card * card) +icn_stopcard(icn_card *card) { unsigned long flags; isdn_ctrl cmd; @@ -1150,7 +1150,7 @@ icn_disable_cards(void) } static int -icn_command(isdn_ctrl * c, icn_card * card) +icn_command(isdn_ctrl *c, icn_card *card) { ulong a; ulong flags; @@ -1161,275 +1161,275 @@ icn_command(isdn_ctrl * c, icn_card * card) char __user *arg; switch (c->command) { - case ISDN_CMD_IOCTL: - memcpy(&a, c->parm.num, sizeof(ulong)); - arg = (char __user *)a; - switch (c->arg) { - case ICN_IOCTL_SETMMIO: - if (dev.memaddr != (a & 0x0ffc000)) { - if (!request_mem_region(a & 0x0ffc000, 0x4000, "icn-isdn (all cards)")) { - printk(KERN_WARNING - "icn: memory at 0x%08lx in use.\n", - a & 0x0ffc000); - return -EINVAL; - } - release_mem_region(a & 0x0ffc000, 0x4000); - icn_stopallcards(); - spin_lock_irqsave(&card->lock, flags); - if (dev.mvalid) { - iounmap(dev.shmem); - release_mem_region(dev.memaddr, 0x4000); - } - dev.mvalid = 0; - dev.memaddr = a & 0x0ffc000; - spin_unlock_irqrestore(&card->lock, flags); - printk(KERN_INFO - "icn: (%s) mmio set to 0x%08lx\n", - CID, - dev.memaddr); - } - break; - case ICN_IOCTL_GETMMIO: - return (long) dev.memaddr; - case ICN_IOCTL_SETPORT: - if (a == 0x300 || a == 0x310 || a == 0x320 || a == 0x330 - || a == 0x340 || a == 0x350 || a == 0x360 || - a == 0x308 || a == 0x318 || a == 0x328 || a == 0x338 - || a == 0x348 || a == 0x358 || a == 0x368) { - if (card->port != (unsigned short) a) { - if (!request_region((unsigned short) a, ICN_PORTLEN, "icn-isdn")) { - printk(KERN_WARNING - "icn: (%s) ports 0x%03x-0x%03x in use.\n", - CID, (int) a, (int) a + ICN_PORTLEN); - return -EINVAL; - } - release_region((unsigned short) a, ICN_PORTLEN); - icn_stopcard(card); - spin_lock_irqsave(&card->lock, flags); - if (card->rvalid) - release_region(card->port, ICN_PORTLEN); - card->port = (unsigned short) a; - card->rvalid = 0; - if (card->doubleS0) { - card->other->port = (unsigned short) a; - card->other->rvalid = 0; - } - spin_unlock_irqrestore(&card->lock, flags); - printk(KERN_INFO - "icn: (%s) port set to 0x%03x\n", - CID, card->port); - } - } else + case ISDN_CMD_IOCTL: + memcpy(&a, c->parm.num, sizeof(ulong)); + arg = (char __user *)a; + switch (c->arg) { + case ICN_IOCTL_SETMMIO: + if (dev.memaddr != (a & 0x0ffc000)) { + if (!request_mem_region(a & 0x0ffc000, 0x4000, "icn-isdn (all cards)")) { + printk(KERN_WARNING + "icn: memory at 0x%08lx in use.\n", + a & 0x0ffc000); + return -EINVAL; + } + release_mem_region(a & 0x0ffc000, 0x4000); + icn_stopallcards(); + spin_lock_irqsave(&card->lock, flags); + if (dev.mvalid) { + iounmap(dev.shmem); + release_mem_region(dev.memaddr, 0x4000); + } + dev.mvalid = 0; + dev.memaddr = a & 0x0ffc000; + spin_unlock_irqrestore(&card->lock, flags); + printk(KERN_INFO + "icn: (%s) mmio set to 0x%08lx\n", + CID, + dev.memaddr); + } + break; + case ICN_IOCTL_GETMMIO: + return (long) dev.memaddr; + case ICN_IOCTL_SETPORT: + if (a == 0x300 || a == 0x310 || a == 0x320 || a == 0x330 + || a == 0x340 || a == 0x350 || a == 0x360 || + a == 0x308 || a == 0x318 || a == 0x328 || a == 0x338 + || a == 0x348 || a == 0x358 || a == 0x368) { + if (card->port != (unsigned short) a) { + if (!request_region((unsigned short) a, ICN_PORTLEN, "icn-isdn")) { + printk(KERN_WARNING + "icn: (%s) ports 0x%03x-0x%03x in use.\n", + CID, (int) a, (int) a + ICN_PORTLEN); return -EINVAL; - break; - case ICN_IOCTL_GETPORT: - return (int) card->port; - case ICN_IOCTL_GETDOUBLE: - return (int) card->doubleS0; - case ICN_IOCTL_DEBUGVAR: - if (copy_to_user(arg, - &card, - sizeof(ulong))) - return -EFAULT; - a += sizeof(ulong); - { - ulong l = (ulong) & dev; - if (copy_to_user(arg, - &l, - sizeof(ulong))) - return -EFAULT; } - return 0; - case ICN_IOCTL_LOADBOOT: - if (dev.firstload) { - icn_disable_cards(); - dev.firstload = 0; - } - icn_stopcard(card); - return (icn_loadboot(arg, card)); - case ICN_IOCTL_LOADPROTO: + release_region((unsigned short) a, ICN_PORTLEN); icn_stopcard(card); - if ((i = (icn_loadproto(arg, card)))) - return i; - if (card->doubleS0) - i = icn_loadproto(arg + ICN_CODE_STAGE2, card->other); - return i; - break; - case ICN_IOCTL_ADDCARD: - if (!dev.firstload) - return -EBUSY; - if (copy_from_user(&cdef, - arg, - sizeof(cdef))) - return -EFAULT; - return (icn_addcard(cdef.port, cdef.id1, cdef.id2)); - break; - case ICN_IOCTL_LEASEDCFG: - if (a) { - if (!card->leased) { - card->leased = 1; - while (card->ptype == ISDN_PTYPE_UNKNOWN) { - msleep_interruptible(ICN_BOOT_TIMEOUT1); - } - msleep_interruptible(ICN_BOOT_TIMEOUT1); - sprintf(cbuf, "00;FV2ON\n01;EAZ%c\n02;EAZ%c\n", - (a & 1)?'1':'C', (a & 2)?'2':'C'); - i = icn_writecmd(cbuf, strlen(cbuf), 0, card); - printk(KERN_INFO - "icn: (%s) Leased-line mode enabled\n", - CID); - cmd.command = ISDN_STAT_RUN; - cmd.driver = card->myid; - cmd.arg = 0; - card->interface.statcallb(&cmd); - } - } else { - if (card->leased) { - card->leased = 0; - sprintf(cbuf, "00;FV2OFF\n"); - i = icn_writecmd(cbuf, strlen(cbuf), 0, card); - printk(KERN_INFO - "icn: (%s) Leased-line mode disabled\n", - CID); - cmd.command = ISDN_STAT_RUN; - cmd.driver = card->myid; - cmd.arg = 0; - card->interface.statcallb(&cmd); - } + spin_lock_irqsave(&card->lock, flags); + if (card->rvalid) + release_region(card->port, ICN_PORTLEN); + card->port = (unsigned short) a; + card->rvalid = 0; + if (card->doubleS0) { + card->other->port = (unsigned short) a; + card->other->rvalid = 0; } - return 0; - default: - return -EINVAL; - } + spin_unlock_irqrestore(&card->lock, flags); + printk(KERN_INFO + "icn: (%s) port set to 0x%03x\n", + CID, card->port); + } + } else + return -EINVAL; break; - case ISDN_CMD_DIAL: - if (!(card->flags & ICN_FLAGS_RUNNING)) - return -ENODEV; - if (card->leased) - break; - if ((c->arg & 255) < ICN_BCH) { - char *p; - char dial[50]; - char dcode[4]; - - a = c->arg; - p = c->parm.setup.phone; - if (*p == 's' || *p == 'S') { - /* Dial for SPV */ - p++; - strcpy(dcode, "SCA"); - } else - /* Normal Dial */ - strcpy(dcode, "CAL"); - strcpy(dial, p); - sprintf(cbuf, "%02d;D%s_R%s,%02d,%02d,%s\n", (int) (a + 1), - dcode, dial, c->parm.setup.si1, - c->parm.setup.si2, c->parm.setup.eazmsn); - i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + case ICN_IOCTL_GETPORT: + return (int) card->port; + case ICN_IOCTL_GETDOUBLE: + return (int) card->doubleS0; + case ICN_IOCTL_DEBUGVAR: + if (copy_to_user(arg, + &card, + sizeof(ulong))) + return -EFAULT; + a += sizeof(ulong); + { + ulong l = (ulong)&dev; + if (copy_to_user(arg, + &l, + sizeof(ulong))) + return -EFAULT; } + return 0; + case ICN_IOCTL_LOADBOOT: + if (dev.firstload) { + icn_disable_cards(); + dev.firstload = 0; + } + icn_stopcard(card); + return (icn_loadboot(arg, card)); + case ICN_IOCTL_LOADPROTO: + icn_stopcard(card); + if ((i = (icn_loadproto(arg, card)))) + return i; + if (card->doubleS0) + i = icn_loadproto(arg + ICN_CODE_STAGE2, card->other); + return i; + break; + case ICN_IOCTL_ADDCARD: + if (!dev.firstload) + return -EBUSY; + if (copy_from_user(&cdef, + arg, + sizeof(cdef))) + return -EFAULT; + return (icn_addcard(cdef.port, cdef.id1, cdef.id2)); break; - case ISDN_CMD_ACCEPTD: - if (!(card->flags & ICN_FLAGS_RUNNING)) - return -ENODEV; - if (c->arg < ICN_BCH) { - a = c->arg + 1; - if (card->fw_rev >= 300) { - switch (card->l2_proto[a - 1]) { - case ISDN_PROTO_L2_X75I: - sprintf(cbuf, "%02d;BX75\n", (int) a); - break; - case ISDN_PROTO_L2_HDLC: - sprintf(cbuf, "%02d;BTRA\n", (int) a); - break; + case ICN_IOCTL_LEASEDCFG: + if (a) { + if (!card->leased) { + card->leased = 1; + while (card->ptype == ISDN_PTYPE_UNKNOWN) { + msleep_interruptible(ICN_BOOT_TIMEOUT1); } + msleep_interruptible(ICN_BOOT_TIMEOUT1); + sprintf(cbuf, "00;FV2ON\n01;EAZ%c\n02;EAZ%c\n", + (a & 1) ? '1' : 'C', (a & 2) ? '2' : 'C'); i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + printk(KERN_INFO + "icn: (%s) Leased-line mode enabled\n", + CID); + cmd.command = ISDN_STAT_RUN; + cmd.driver = card->myid; + cmd.arg = 0; + card->interface.statcallb(&cmd); + } + } else { + if (card->leased) { + card->leased = 0; + sprintf(cbuf, "00;FV2OFF\n"); + i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + printk(KERN_INFO + "icn: (%s) Leased-line mode disabled\n", + CID); + cmd.command = ISDN_STAT_RUN; + cmd.driver = card->myid; + cmd.arg = 0; + card->interface.statcallb(&cmd); } - sprintf(cbuf, "%02d;DCON_R\n", (int) a); - i = icn_writecmd(cbuf, strlen(cbuf), 0, card); } + return 0; + default: + return -EINVAL; + } + break; + case ISDN_CMD_DIAL: + if (!(card->flags & ICN_FLAGS_RUNNING)) + return -ENODEV; + if (card->leased) break; - case ISDN_CMD_ACCEPTB: - if (!(card->flags & ICN_FLAGS_RUNNING)) - return -ENODEV; - if (c->arg < ICN_BCH) { - a = c->arg + 1; - if (card->fw_rev >= 300) - switch (card->l2_proto[a - 1]) { - case ISDN_PROTO_L2_X75I: - sprintf(cbuf, "%02d;BCON_R,BX75\n", (int) a); - break; - case ISDN_PROTO_L2_HDLC: - sprintf(cbuf, "%02d;BCON_R,BTRA\n", (int) a); - break; - } else - sprintf(cbuf, "%02d;BCON_R\n", (int) a); + if ((c->arg & 255) < ICN_BCH) { + char *p; + char dial[50]; + char dcode[4]; + + a = c->arg; + p = c->parm.setup.phone; + if (*p == 's' || *p == 'S') { + /* Dial for SPV */ + p++; + strcpy(dcode, "SCA"); + } else + /* Normal Dial */ + strcpy(dcode, "CAL"); + strcpy(dial, p); + sprintf(cbuf, "%02d;D%s_R%s,%02d,%02d,%s\n", (int) (a + 1), + dcode, dial, c->parm.setup.si1, + c->parm.setup.si2, c->parm.setup.eazmsn); + i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + } + break; + case ISDN_CMD_ACCEPTD: + if (!(card->flags & ICN_FLAGS_RUNNING)) + return -ENODEV; + if (c->arg < ICN_BCH) { + a = c->arg + 1; + if (card->fw_rev >= 300) { + switch (card->l2_proto[a - 1]) { + case ISDN_PROTO_L2_X75I: + sprintf(cbuf, "%02d;BX75\n", (int) a); + break; + case ISDN_PROTO_L2_HDLC: + sprintf(cbuf, "%02d;BTRA\n", (int) a); + break; + } i = icn_writecmd(cbuf, strlen(cbuf), 0, card); } + sprintf(cbuf, "%02d;DCON_R\n", (int) a); + i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + } + break; + case ISDN_CMD_ACCEPTB: + if (!(card->flags & ICN_FLAGS_RUNNING)) + return -ENODEV; + if (c->arg < ICN_BCH) { + a = c->arg + 1; + if (card->fw_rev >= 300) + switch (card->l2_proto[a - 1]) { + case ISDN_PROTO_L2_X75I: + sprintf(cbuf, "%02d;BCON_R,BX75\n", (int) a); + break; + case ISDN_PROTO_L2_HDLC: + sprintf(cbuf, "%02d;BCON_R,BTRA\n", (int) a); + break; + } else + sprintf(cbuf, "%02d;BCON_R\n", (int) a); + i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + } + break; + case ISDN_CMD_HANGUP: + if (!(card->flags & ICN_FLAGS_RUNNING)) + return -ENODEV; + if (c->arg < ICN_BCH) { + a = c->arg + 1; + sprintf(cbuf, "%02d;BDIS_R\n%02d;DDIS_R\n", (int) a, (int) a); + i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + } + break; + case ISDN_CMD_SETEAZ: + if (!(card->flags & ICN_FLAGS_RUNNING)) + return -ENODEV; + if (card->leased) break; - case ISDN_CMD_HANGUP: - if (!(card->flags & ICN_FLAGS_RUNNING)) - return -ENODEV; - if (c->arg < ICN_BCH) { - a = c->arg + 1; - sprintf(cbuf, "%02d;BDIS_R\n%02d;DDIS_R\n", (int) a, (int) a); - i = icn_writecmd(cbuf, strlen(cbuf), 0, card); - } + if (c->arg < ICN_BCH) { + a = c->arg + 1; + if (card->ptype == ISDN_PTYPE_EURO) { + sprintf(cbuf, "%02d;MS%s%s\n", (int) a, + c->parm.num[0] ? "N" : "ALL", c->parm.num); + } else + sprintf(cbuf, "%02d;EAZ%s\n", (int) a, + c->parm.num[0] ? (char *)(c->parm.num) : "0123456789"); + i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + } + break; + case ISDN_CMD_CLREAZ: + if (!(card->flags & ICN_FLAGS_RUNNING)) + return -ENODEV; + if (card->leased) break; - case ISDN_CMD_SETEAZ: - if (!(card->flags & ICN_FLAGS_RUNNING)) - return -ENODEV; - if (card->leased) + if (c->arg < ICN_BCH) { + a = c->arg + 1; + if (card->ptype == ISDN_PTYPE_EURO) + sprintf(cbuf, "%02d;MSNC\n", (int) a); + else + sprintf(cbuf, "%02d;EAZC\n", (int) a); + i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + } + break; + case ISDN_CMD_SETL2: + if (!(card->flags & ICN_FLAGS_RUNNING)) + return -ENODEV; + if ((c->arg & 255) < ICN_BCH) { + a = c->arg; + switch (a >> 8) { + case ISDN_PROTO_L2_X75I: + sprintf(cbuf, "%02d;BX75\n", (int) (a & 255) + 1); break; - if (c->arg < ICN_BCH) { - a = c->arg + 1; - if (card->ptype == ISDN_PTYPE_EURO) { - sprintf(cbuf, "%02d;MS%s%s\n", (int) a, - c->parm.num[0] ? "N" : "ALL", c->parm.num); - } else - sprintf(cbuf, "%02d;EAZ%s\n", (int) a, - c->parm.num[0] ? (char *)(c->parm.num) : "0123456789"); - i = icn_writecmd(cbuf, strlen(cbuf), 0, card); - } - break; - case ISDN_CMD_CLREAZ: - if (!(card->flags & ICN_FLAGS_RUNNING)) - return -ENODEV; - if (card->leased) + case ISDN_PROTO_L2_HDLC: + sprintf(cbuf, "%02d;BTRA\n", (int) (a & 255) + 1); break; - if (c->arg < ICN_BCH) { - a = c->arg + 1; - if (card->ptype == ISDN_PTYPE_EURO) - sprintf(cbuf, "%02d;MSNC\n", (int) a); - else - sprintf(cbuf, "%02d;EAZC\n", (int) a); - i = icn_writecmd(cbuf, strlen(cbuf), 0, card); - } - break; - case ISDN_CMD_SETL2: - if (!(card->flags & ICN_FLAGS_RUNNING)) - return -ENODEV; - if ((c->arg & 255) < ICN_BCH) { - a = c->arg; - switch (a >> 8) { - case ISDN_PROTO_L2_X75I: - sprintf(cbuf, "%02d;BX75\n", (int) (a & 255) + 1); - break; - case ISDN_PROTO_L2_HDLC: - sprintf(cbuf, "%02d;BTRA\n", (int) (a & 255) + 1); - break; - default: - return -EINVAL; - } - i = icn_writecmd(cbuf, strlen(cbuf), 0, card); - card->l2_proto[a & 255] = (a >> 8); + default: + return -EINVAL; } - break; - case ISDN_CMD_SETL3: - if (!(card->flags & ICN_FLAGS_RUNNING)) - return -ENODEV; - return 0; - default: - return -EINVAL; + i = icn_writecmd(cbuf, strlen(cbuf), 0, card); + card->l2_proto[a & 255] = (a >> 8); + } + break; + case ISDN_CMD_SETL3: + if (!(card->flags & ICN_FLAGS_RUNNING)) + return -ENODEV; + return 0; + default: + return -EINVAL; } return 0; } @@ -1454,7 +1454,7 @@ icn_findcard(int driverid) * Wrapper functions for interface to linklevel */ static int -if_command(isdn_ctrl * c) +if_command(isdn_ctrl *c) { icn_card *card = icn_findcard(c->driver); @@ -1537,9 +1537,9 @@ icn_initcard(int port, char *id) card->interface.writecmd = if_writecmd; card->interface.readstat = if_readstatus; card->interface.features = ISDN_FEATURE_L2_X75I | - ISDN_FEATURE_L2_HDLC | - ISDN_FEATURE_L3_TRANS | - ISDN_FEATURE_P_UNKNOWN; + ISDN_FEATURE_L2_HDLC | + ISDN_FEATURE_L3_TRANS | + ISDN_FEATURE_P_UNKNOWN; card->ptype = ISDN_PTYPE_UNKNOWN; strlcpy(card->interface.id, id, sizeof(card->interface.id)); card->msg_buf_write = card->msg_buf; @@ -1619,7 +1619,7 @@ icn_setup(char *line) icn_id2 = sid2; } } - return(1); + return (1); } __setup("icn=", icn_setup); #endif /* MODULE */ diff --git a/drivers/isdn/icn/icn.h b/drivers/isdn/icn/icn.h index 7d7245fb0b32..b713466997a0 100644 --- a/drivers/isdn/icn/icn.h +++ b/drivers/isdn/icn/icn.h @@ -54,7 +54,7 @@ typedef struct icn_cdef { /* some useful macros for debugging */ #ifdef ICN_DEBUG_PORT -#define OUTB_P(v,p) {printk(KERN_DEBUG "icn: outb_p(0x%02x,0x%03x)\n",v,p); outb_p(v,p);} +#define OUTB_P(v, p) {printk(KERN_DEBUG "icn: outb_p(0x%02x,0x%03x)\n", v, p); outb_p(v, p);} #else #define OUTB_P outb #endif @@ -71,8 +71,8 @@ typedef struct icn_cdef { #define ICN_BOOT_TIMEOUT1 1000 /* Delay for Boot-download (msecs) */ -#define ICN_TIMER_BCREAD (HZ/100) /* B-Channel poll-cycle */ -#define ICN_TIMER_DCREAD (HZ/2) /* D-Channel poll-cycle */ +#define ICN_TIMER_BCREAD (HZ / 100) /* B-Channel poll-cycle */ +#define ICN_TIMER_DCREAD (HZ / 2) /* D-Channel poll-cycle */ #define ICN_CODE_STAGE1 4096 /* Size of bootcode */ #define ICN_CODE_STAGE2 65536 /* Size of protocol-code */ @@ -140,7 +140,7 @@ typedef struct icn_card { int myid; /* Driver-Nr. assigned by linklevel */ int rvalid; /* IO-portregion has been requested */ int leased; /* Flag: This Adapter is connected */ - /* to a leased line */ + /* to a leased line */ unsigned short flags; /* Statusflags */ int doubleS0; /* Flag: ICN4B */ int secondhalf; /* Flag: Second half of a doubleS0 */ @@ -197,16 +197,16 @@ static icn_dev dev; /* Macros for accessing ports */ #define ICN_CFG (card->port) -#define ICN_MAPRAM (card->port+1) -#define ICN_RUN (card->port+2) -#define ICN_BANK (card->port+3) +#define ICN_MAPRAM (card->port + 1) +#define ICN_RUN (card->port + 2) +#define ICN_BANK (card->port + 3) /* Return true, if there is a free transmit-buffer */ -#define sbfree (((readb(&dev.shmem->data_control.scns)+1) & 0xf) != \ +#define sbfree (((readb(&dev.shmem->data_control.scns) + 1) & 0xf) != \ readb(&dev.shmem->data_control.scnr)) /* Switch to next transmit-buffer */ -#define sbnext (writeb((readb(&dev.shmem->data_control.scns)+1) & 0xf, \ +#define sbnext (writeb((readb(&dev.shmem->data_control.scns) + 1) & 0xf, \ &dev.shmem->data_control.scns)) /* Shortcuts for transmit-buffer-access */ @@ -220,7 +220,7 @@ static icn_dev dev; readb(&dev.shmem->data_control.ecns)) /* Switch to next receive-buffer */ -#define rbnext (writeb((readb(&dev.shmem->data_control.ecnr)+1) & 0xf, \ +#define rbnext (writeb((readb(&dev.shmem->data_control.ecnr) + 1) & 0xf, \ &dev.shmem->data_control.ecnr)) /* Shortcuts for receive-buffer-access */ @@ -234,18 +234,18 @@ static icn_dev dev; #define cmd_i (dev.shmem->comm_control.pcio_i) /* Return free space in command-buffer */ -#define cmd_free ((readb(&cmd_i)>=readb(&cmd_o))? \ - 0x100-readb(&cmd_i)+readb(&cmd_o): \ - readb(&cmd_o)-readb(&cmd_i)) +#define cmd_free ((readb(&cmd_i) >= readb(&cmd_o)) ? \ + 0x100 - readb(&cmd_i) + readb(&cmd_o) : \ + readb(&cmd_o) - readb(&cmd_i)) /* Shortcuts for message-buffer-access */ #define msg_o (dev.shmem->comm_control.iopc_o) #define msg_i (dev.shmem->comm_control.iopc_i) /* Return length of Message, if avail. */ -#define msg_avail ((readb(&msg_o)>readb(&msg_i))? \ - 0x100-readb(&msg_o)+readb(&msg_i): \ - readb(&msg_i)-readb(&msg_o)) +#define msg_avail ((readb(&msg_o) > readb(&msg_i)) ? \ + 0x100 - readb(&msg_o) + readb(&msg_i) : \ + readb(&msg_i) - readb(&msg_o)) #define CID (card->interface.id) |