Index: drivers/dahdi/dahdi-base.c =================================================================== --- drivers/dahdi/dahdi-base.c (revision 7493) +++ drivers/dahdi/dahdi-base.c (working copy) @@ -3454,7 +3454,7 @@ /* Switch to other master if current master in alarm */ for (x=1; xalarms && (spans[x]->flags & DAHDI_FLAG_RUNNING)) { - if(master != spans[x]) + if (master != spans[x]) module_printk(KERN_NOTICE, "Master changed to %s\n", spans[x]->name); master = spans[x]; break; @@ -3468,27 +3468,27 @@ return -EINVAL; \ if (!spans[j]) \ return -ENXIO; \ -} while(0) +} while (0) #define CHECK_VALID_SPAN(j) do { \ /* Start a given span */ \ if (get_user(j, (int *)data)) \ return -EFAULT; \ VALID_SPAN(j); \ -} while(0) +} while (0) #define VALID_CHANNEL(j) do { \ if ((j >= DAHDI_MAX_CHANNELS) || (j < 1)) \ return -EINVAL; \ if (!chans[j]) \ return -ENXIO; \ -} while(0) +} while (0) static int dahdi_timer_ioctl(struct inode *node, struct file *file, unsigned int cmd, unsigned long data, struct dahdi_timer *timer) { int j; unsigned long flags; - switch(cmd) { + switch (cmd) { case DAHDI_TIMERCONFIG: get_user(j, (int *)data); if (j < 0) @@ -3667,7 +3667,7 @@ int return_master = 0; size_t size_to_copy; - switch(cmd) { + switch (cmd) { /* get channel parameters */ case DAHDI_GET_PARAMS_V1: /* Intentional drop through. */ case DAHDI_GET_PARAMS: @@ -3965,7 +3965,7 @@ struct dahdi_chan *newmaster; unsigned long flags; int rv; - switch(cmd) { + switch (cmd) { case DAHDI_INDIRECT: { struct dahdi_indirect_data ind; @@ -4396,7 +4396,7 @@ i = spans[maint.spanno]->maintstat; /* set maint mode */ spans[maint.spanno]->maintstat = maint.command; - switch(maint.command) { + switch (maint.command) { case DAHDI_MAINT_NONE: case DAHDI_MAINT_LOCALLOOP: case DAHDI_MAINT_REMOTELOOP: @@ -4525,7 +4525,7 @@ if (!chan) return -EINVAL; - switch(cmd) { + switch (cmd) { case DAHDI_DIALING: spin_lock_irqsave(&chan->lock, flags); j = chan->dialing; @@ -4621,7 +4621,7 @@ spin_unlock_irqrestore(&chan->lock, flags); break; case DAHDI_SYNC: /* wait for no tx */ - for(;;) /* loop forever */ + for (;;) /* loop forever */ { spin_lock_irqsave(&chan->lock, flags); /* Know if there is a write pending */ @@ -4635,7 +4635,7 @@ case DAHDI_IOMUX: /* wait for something to happen */ get_user(chan->iomask,(int*)data); /* save mask */ if (!chan->iomask) return(-EINVAL); /* cant wait for nothing */ - for(;;) /* loop forever */ + for (;;) /* loop forever */ { /* has to have SOME mask */ ret = 0; /* start with empty return value */ @@ -4859,7 +4859,7 @@ } rv = 0; /* clear return value */ /* look for already existant specified combination */ - for(i = 1; i <= DAHDI_MAX_CONF; i++) + for (i = 1; i <= DAHDI_MAX_CONF; i++) { /* if found, exit */ if ((conf_links[i].src == stack.conf.chan) && @@ -4881,7 +4881,7 @@ if (stack.conf.confmode) /* if to add link */ { /* look for empty location */ - for(i = 1; i <= DAHDI_MAX_CONF; i++) + for (i = 1; i <= DAHDI_MAX_CONF; i++) { /* if empty, exit loop */ if ((!conf_links[i].src) && @@ -4912,10 +4912,10 @@ if (!(chan->flags & DAHDI_FLAG_AUDIO)) return (-EINVAL); get_user(j,(int *)data); /* get conf # */ /* loop thru the interesting ones */ - for(i = ((j) ? j : 1); i <= ((j) ? j : DAHDI_MAX_CONF); i++) + for (i = ((j) ? j : 1); i <= ((j) ? j : DAHDI_MAX_CONF); i++) { c = 0; - for(k = 1; k < DAHDI_MAX_CHANNELS; k++) + for (k = 1; k < DAHDI_MAX_CHANNELS; k++) { /* skip if no pointer */ if (!chans[k]) continue; @@ -4926,7 +4926,7 @@ module_printk(KERN_NOTICE, "chan %d, mode %x\n", k,chans[k]->confmode); } rv = 0; - for(k = 1; k <= DAHDI_MAX_CONF; k++) + for (k = 1; k <= DAHDI_MAX_CONF; k++) { if (conf_links[k].dst == i) { @@ -5216,7 +5216,7 @@ if (!chan) return -ENOSYS; - switch(cmd) { + switch (cmd) { case DAHDI_SETSIGFREEZE: get_user(j, (int *)data); spin_lock_irqsave(&chan->lock, flags); @@ -5592,7 +5592,7 @@ if (chan) { module_printk(KERN_NOTICE, "Huh? Prechan already has private data??\n"); } - switch(cmd) { + switch (cmd) { case DAHDI_SPECIFY: get_user(channo,(int *)data); if (channo < 1) @@ -5953,7 +5953,7 @@ /* * Set up mu-law conversion table */ - for(i = 0;i < 256;i++) + for (i = 0;i < 256;i++) { short mu,e,f,y; static short etab[]={0,132,396,924,1980,4092,8316,16764}; @@ -5971,7 +5971,7 @@ } #ifndef CONFIG_CALC_XLAW /* set up the reverse (mu-law) conversion table */ - for(i = -32768; i < 32768; i += 4) + for (i = -32768; i < 32768; i += 4) { __dahdi_lin2mu[((unsigned short)(short)i) >> 2] = __dahdi_lineartoulaw(i); __dahdi_lin2a[((unsigned short)(short)i) >> 2] = __dahdi_lineartoalaw(i); @@ -6004,7 +6004,7 @@ if ((!ms->confmute && !ms->dialing) || (ms->flags & DAHDI_FLAG_PSEUDO)) { /* Handle conferencing on non-clear channel and non-HDLC channels */ - switch(ms->confmode & DAHDI_CONF_MODE_MASK) { + switch (ms->confmode & DAHDI_CONF_MODE_MASK) { case DAHDI_CONF_NORMAL: /* Do nuffin */ break; @@ -6233,7 +6233,7 @@ /* Let's pick something to transmit. First source to try is our write-out buffer. Always check it first because its our 'fast path' for whatever that's worth. */ - while(bytes) { + while (bytes) { if ((ms->outwritebuf > -1) && !ms->txdisable) { buf= ms->writebuf[ms->outwritebuf]; left = ms->writen[ms->outwritebuf] - ms->writeidx[ms->outwritebuf]; @@ -6242,7 +6242,7 @@ if (ms->flags & DAHDI_FLAG_HDLC) { /* If this is an HDLC channel we only send a byte of HDLC. */ - for(x=0;xtxhdlc)) /* Load a byte of data only if needed */ fasthdlc_tx_load_nocheck(&ms->txhdlc, buf[ms->writeidx[ms->outwritebuf]++]); @@ -6384,7 +6384,7 @@ /* the only way this could have gotten here, is if a channel went onf hook longer then the wink or flash detect timeout */ /* Called with chan->lock held */ - switch(chan->sig) + switch (chan->sig) { case DAHDI_SIG_FXOLS: /* if FXO, its definitely on hook */ case DAHDI_SIG_FXOGS: @@ -6423,7 +6423,7 @@ chan->otimer = 0; /* Move to the next timer state */ - switch(chan->txstate) { + switch (chan->txstate) { case DAHDI_TXSTATE_RINGOFF: /* Turn on the ringer now that the silent time has passed */ ++chan->cadencepos; @@ -6564,10 +6564,10 @@ (!chan->ringdebtimer)) __qevent(chan,DAHDI_EVENT_RINGBEGIN); #endif - switch(chan->sig) { + switch (chan->sig) { case DAHDI_SIG_EM: /* E and M */ case DAHDI_SIG_EM_E1: - switch(rxsig) { + switch (rxsig) { case DAHDI_RXSIG_OFFHOOK: /* went off hook */ /* The interface is going off hook */ #ifdef EMFLASH @@ -6668,7 +6668,7 @@ /* fall through intentionally */ case DAHDI_SIG_FXOLS: /* FXO Loopstart */ case DAHDI_SIG_FXOKS: /* FXO Kewlstart */ - switch(rxsig) { + switch (rxsig) { case DAHDI_RXSIG_OFFHOOK: /* went off hook */ /* if asserti ng ring, stop it */ if (chan->txstate == DAHDI_TXSTATE_START) { @@ -6758,7 +6758,7 @@ if ((chan->flags & DAHDI_FLAG_SIGFREEZE)) return; spin_lock_irqsave(&chan->lock, flags); - switch(chan->sig) { + switch (chan->sig) { case DAHDI_SIG_FXOGS: /* FXO Groundstart */ /* B-bit only matters for FXO GS */ if (!(cursig & DAHDI_BBIT)) { @@ -6968,14 +6968,14 @@ #define NB 14 /* number of bits to shift left */ /* determine energy level before filtering */ - for(i = 0; i < samples; i++) + for (i = 0; i < samples; i++) { if (amp[i] < 0) s->e1 -= amp[i]; else s->e1 += amp[i]; } /* do 2nd order IIR notch filter at given freq. and calculate energy */ - for(i = 0; i < samples; i++) + for (i = 0; i < samples; i++) { x = amp[i] << NB; y = s->x2 + (p1 * (s->x1 >> NB)) + x; @@ -7040,7 +7040,7 @@ r = sf_detect(&ms->rd,putlin,DAHDI_CHUNKSIZE,ms->rxp1, ms->rxp2,ms->rxp3); /* Convert back */ - for(x=0;xconfmute && !ms->afterdialingtimer) || (ms->flags & DAHDI_FLAG_PSEUDO)) { - switch(ms->confmode & DAHDI_CONF_MODE_MASK) { + switch (ms->confmode & DAHDI_CONF_MODE_MASK) { case DAHDI_CONF_NORMAL: /* Normal mode */ /* Do nothing. rx goes output */ break; @@ -7083,7 +7083,7 @@ ACSS(putlin, chans[ms->confna]->putlin); } /* Convert back */ - for(x=0;xconfna]->getlin); } /* Convert back */ - for(x=0;xconfna]->getlin); ACSS(putlin, chans[ms->confna]->putlin); /* Convert back */ - for(x=0;x_confn]); } /* Convert back */ - for(x=0;x_confn]); } /* Convert back */ - for(x=0;xputlin, putlin, DAHDI_CHUNKSIZE * sizeof(short)); break; @@ -7268,7 +7268,7 @@ int left, x; - while(bytes) { + while (bytes) { #if defined(CONFIG_DAHDI_NET) || defined(CONFIG_DAHDI_PPP) skb = NULL; #endif @@ -7816,7 +7816,7 @@ unsigned char silly[DAHDI_CHUNKSIZE]; /* Called with chan->lock locked */ #ifdef OPTIMIZE_CHANMUTE - if(likely(chan->chanmute)) + if (likely(chan->chanmute)) return; #endif if (!buf) @@ -7838,7 +7838,7 @@ { /* Called with chan->lock held */ #ifdef OPTIMIZE_CHANMUTE - if(likely(chan->chanmute)) + if (likely(chan->chanmute)) return; #endif if (chan->confmode) { @@ -7858,7 +7858,7 @@ short getlin; /* Called with ms->lock held */ - while(bytes) { + while (bytes) { /* Receive silence, or tone */ if (ms->curtone) { left = ms->curtone->tonesamples - ms->tonep; @@ -7901,7 +7901,7 @@ unsigned char waste[DAHDI_CHUNKSIZE]; #ifdef OPTIMIZE_CHANMUTE - if(likely(chan->chanmute)) + if (likely(chan->chanmute)) return; #endif if (!buf) { @@ -7924,7 +7924,7 @@ { /* Called with chan->lock held */ #ifdef OPTIMIZE_CHANMUTE - if(likely(chan->chanmute)) + if (likely(chan->chanmute)) return; #endif if (chan->confmode) { @@ -7972,7 +7972,7 @@ } span->chans[z]->writechunk[y] = data[pos++]; z = span->chans[z]->nextslave; - } while(z); + } while (z); } } else { /* Process independents elsewise */ @@ -8241,12 +8241,12 @@ do { data[pos++] = span->chans[z]->readchunk[y]; if (pos == DAHDI_CHUNKSIZE) { - if(!(span->chans[x]->flags & DAHDI_FLAG_NOSTDTXRX)) + if (!(span->chans[x]->flags & DAHDI_FLAG_NOSTDTXRX)) __dahdi_receive_chunk(span->chans[x], data); pos = 0; } z=span->chans[z]->nextslave; - } while(z); + } while (z); } } else { /* Process a normal channel */ Index: drivers/dahdi/dahdi_dummy.c =================================================================== --- drivers/dahdi/dahdi_dummy.c (revision 7493) +++ drivers/dahdi/dahdi_dummy.c (working copy) @@ -120,13 +120,13 @@ * a tick */ overrun = hrtimer_forward(&zaptimer, hrtimer_get_expires(htmr), ktime_set(0, DAHDI_TIME_NS)); - if(overrun > 1) { - if(printk_ratelimit()) + if (overrun > 1) { + if (printk_ratelimit()) printk(KERN_NOTICE "dahdi_dummy: HRTimer missed %lu ticks\n", overrun - 1); } - if(debug && DEBUG_TICKS) { + if (debug && DEBUG_TICKS) { static int count = 0; /* Printk every 5 seconds, good test to see if timer is * running properly */ Index: drivers/dahdi/dahdi_dynamic.c =================================================================== --- drivers/dahdi/dahdi_dynamic.c (revision 7493) +++ drivers/dahdi/dahdi_dynamic.c (working copy) @@ -136,7 +136,7 @@ struct dahdi_dynamic *z, *master=NULL; spin_lock_irqsave(&dlock, flags); z = dspans; - while(z) { + while (z) { if (z->timing) { z->master = 0; if (!(z->span.alarms & DAHDI_ALARM_RED) && @@ -229,7 +229,7 @@ int y; spin_lock_irqsave(&dlock, flags); z = dspans; - while(z) { + while (z) { if (!z->dead) { /* Ignore dead spans */ for (y=0;yspan.channels;y++) { @@ -249,7 +249,7 @@ read_lock(&drvlock); drv = drivers; - while(drv) { + while (drv) { /* Flush any traffic still pending in the driver */ if (drv->flush) { drv->flush(); @@ -442,7 +442,7 @@ { struct dahdi_dynamic *z; z = dspans; - while(z) { + while (z) { if (!strcmp(z->dname, zds->driver) && !strcmp(z->addr, zds->addr)) break; @@ -455,7 +455,7 @@ { struct dahdi_dynamic_driver *ztd; ztd = drivers; - while(ztd) { + while (ztd) { /* here's our driver */ if (!strcmp(name, ztd->name)) break; @@ -482,7 +482,7 @@ } /* Unlink it */ cur = dspans; - while(cur) { + while (cur) { if (cur == z) { if (prev) prev->next = z->next; @@ -696,7 +696,7 @@ { struct dahdi_dynamic_span zds; int res; - switch(cmd) { + switch (cmd) { case 0: /* This is called just before rotation. If none of our spans are pulling timing, then now is the time to process @@ -750,7 +750,7 @@ unsigned long flags; write_lock_irqsave(&drvlock, flags); cur = drivers; - while(cur) { + while (cur) { if (cur == dri) { if (prev) prev->next = cur->next; @@ -765,7 +765,7 @@ spin_lock_irqsave(&dlock, flags); z = dspans; zp = NULL; - while(z) { + while (z) { zn = z->next; if (z->driver == dri) { /* Unlink */ @@ -795,7 +795,7 @@ struct dahdi_dynamic *z; spin_lock_irqsave(&dlock, flags); z = dspans; - while(z) { + while (z) { newalarm = z->span.alarms & ~DAHDI_ALARM_RED; /* If nothing received for a second, consider that RED ALARM */ if ((jiffies - z->rxjif) > 1 * HZ) { Index: drivers/dahdi/dahdi_dynamic_eth.c =================================================================== --- drivers/dahdi/dahdi_dynamic_eth.c (revision 7493) +++ drivers/dahdi/dahdi_dynamic_eth.c (working copy) @@ -66,7 +66,7 @@ struct dahdi_span *span = NULL; spin_lock_irqsave(&zlock, flags); z = zdevs; - while(z) { + while (z) { if (!memcmp(addr, z->addr, ETH_ALEN) && z->subaddr == subaddr) break; @@ -114,12 +114,12 @@ struct net_device *dev = ptr; struct ztdeth *z; unsigned long flags; - switch(event) { + switch (event) { case NETDEV_GOING_DOWN: case NETDEV_DOWN: spin_lock_irqsave(&zlock, flags); z = zdevs; - while(z) { + while (z) { /* Note that the device no longer exists */ if (z->dev == dev) z->dev = NULL; @@ -130,7 +130,7 @@ case NETDEV_UP: spin_lock_irqsave(&zlock, flags); z = zdevs; - while(z) { + while (z) { /* Now that the device exists again, use it */ if (!strcmp(z->ethdev, dev->name)) z->dev = dev; @@ -214,7 +214,7 @@ static int digit2int(char d) { - switch(d) { + switch (d) { case 'F': case 'E': case 'D': @@ -276,7 +276,7 @@ struct ztdeth *prev=NULL, *cur; spin_lock_irqsave(&zlock, flags); cur = zdevs; - while(cur) { + while (cur) { if (cur == z) { if (prev) prev->next = cur->next; @@ -393,7 +393,7 @@ z->next = zdevs; zdevs = z; spin_unlock_irqrestore(&zlock, flags); - if(!try_module_get(THIS_MODULE)) + if (!try_module_get(THIS_MODULE)) printk(KERN_DEBUG "TDMoE: Unable to increment module use count\n"); } return z; Index: drivers/dahdi/dahdi_dynamic_loc.c =================================================================== --- drivers/dahdi/dahdi_dynamic_loc.c (revision 7493) +++ drivers/dahdi/dahdi_dynamic_loc.c (working copy) @@ -91,7 +91,7 @@ static int digit2int(char d) { - switch(d) { + switch (d) { case 'F': case 'E': case 'D': @@ -129,7 +129,7 @@ spin_lock_irqsave(&zlock, flags); cur = zdevs; - while(cur) { + while (cur) { if (cur->peer == z) cur->peer = NULL; if (cur->monitor_rx_peer == z) @@ -137,7 +137,7 @@ cur = cur->next; } cur = zdevs; - while(cur) { + while (cur) { if (cur == z) { if (prev) prev->next = cur->next; @@ -216,7 +216,7 @@ z->next = zdevs; zdevs = z; spin_unlock_irqrestore(&zlock, flags); - if(!try_module_get(THIS_MODULE)) + if (!try_module_get(THIS_MODULE)) printk(KERN_DEBUG "TDMoL: Unable to increment module use count\n"); printk(KERN_INFO "TDMoL: Added new interface for %s, key %d id %d\n", span->name, z->key, z->id); Index: drivers/dahdi/datamods/hdlc_cisco.c =================================================================== --- drivers/dahdi/datamods/hdlc_cisco.c (revision 7493) +++ drivers/dahdi/datamods/hdlc_cisco.c (working copy) @@ -102,7 +102,7 @@ data->address != CISCO_UNICAST) return __constant_htons(ETH_P_HDLC); - switch(data->protocol) { + switch (data->protocol) { case __constant_htons(ETH_P_IP): case __constant_htons(ETH_P_IPX): case __constant_htons(ETH_P_IPV6): @@ -130,7 +130,7 @@ data->address != CISCO_UNICAST) goto rx_error; - switch(ntohs(data->protocol)) { + switch (ntohs(data->protocol)) { case CISCO_SYS_INFO: /* Packet is not needed, drop it. */ dev_kfree_skb_any(skb); @@ -147,7 +147,7 @@ cisco_data = (cisco_packet*)(skb->data + sizeof(hdlc_header)); - switch(ntohl (cisco_data->type)) { + switch (ntohl (cisco_data->type)) { case CISCO_ADDR_REQ: /* Stolen from syncppp.c :-) */ in_dev = dev->ip_ptr; addr = 0; @@ -201,8 +201,8 @@ dev_kfree_skb_any(skb); return NET_RX_SUCCESS; - } /* switch(keepalive type) */ - } /* switch(protocol) */ + } /* switch (keepalive type) */ + } /* switch (protocol) */ printk(KERN_INFO "%s: Unsupported protocol %x\n", dev->name, data->protocol); @@ -295,10 +295,10 @@ return 0; case IF_PROTO_CISCO: - if(!capable(CAP_NET_ADMIN)) + if (!capable(CAP_NET_ADMIN)) return -EPERM; - if(dev->flags & IFF_UP) + if (dev->flags & IFF_UP) return -EBUSY; if (copy_from_user(&new_settings, cisco_s, size)) Index: drivers/dahdi/datamods/hdlc_fr.c =================================================================== --- drivers/dahdi/datamods/hdlc_fr.c (revision 7493) +++ drivers/dahdi/datamods/hdlc_fr.c (working copy) @@ -1191,10 +1191,10 @@ return 0; case IF_PROTO_FR: - if(!capable(CAP_NET_ADMIN)) + if (!capable(CAP_NET_ADMIN)) return -EPERM; - if(dev->flags & IFF_UP) + if (dev->flags & IFF_UP) return -EBUSY; if (copy_from_user(&new_settings, fr_s, size)) @@ -1246,7 +1246,7 @@ case IF_PROTO_FR_DEL_PVC: case IF_PROTO_FR_ADD_ETH_PVC: case IF_PROTO_FR_DEL_ETH_PVC: - if(!capable(CAP_NET_ADMIN)) + if (!capable(CAP_NET_ADMIN)) return -EPERM; if (copy_from_user(&pvc, ifr->ifr_settings.ifs_ifsu.fr_pvc, Index: drivers/dahdi/datamods/hdlc_generic.c =================================================================== --- drivers/dahdi/datamods/hdlc_generic.c (revision 7493) +++ drivers/dahdi/datamods/hdlc_generic.c (working copy) @@ -234,7 +234,7 @@ if (cmd != SIOCWANDEV) return -EINVAL; - switch(ifr->ifr_settings.type) { + switch (ifr->ifr_settings.type) { case IF_PROTO_HDLC: case IF_PROTO_HDLC_ETH: case IF_PROTO_PPP: @@ -248,7 +248,7 @@ proto = hdlc->proto.id; } - switch(proto) { + switch (proto) { case IF_PROTO_HDLC: return hdlc_raw_ioctl(dev, ifr); case IF_PROTO_HDLC_ETH: return hdlc_raw_eth_ioctl(dev, ifr); case IF_PROTO_PPP: return hdlc_ppp_ioctl(dev, ifr); Index: drivers/dahdi/datamods/hdlc_ppp.c =================================================================== --- drivers/dahdi/datamods/hdlc_ppp.c (revision 7493) +++ drivers/dahdi/datamods/hdlc_ppp.c (working copy) @@ -84,10 +84,10 @@ return 0; /* return protocol only, no settable parameters */ case IF_PROTO_PPP: - if(!capable(CAP_NET_ADMIN)) + if (!capable(CAP_NET_ADMIN)) return -EPERM; - if(dev->flags & IFF_UP) + if (dev->flags & IFF_UP) return -EBUSY; /* no settable parameters */ Index: drivers/dahdi/datamods/syncppp.c =================================================================== --- drivers/dahdi/datamods/syncppp.c (revision 7493) +++ drivers/dahdi/datamods/syncppp.c (working copy) @@ -287,7 +287,7 @@ goto drop; case PPP_IP: if (sp->ipcp.state == IPCP_STATE_OPENED) { - if(sp->pp_flags&PP_DEBUG) + if (sp->pp_flags&PP_DEBUG) printk(KERN_DEBUG "Yow an IP frame.\n"); skb->protocol=htons(ETH_P_IP); netif_rx(skb); @@ -366,7 +366,7 @@ struct ppp_header *h; skb_push(skb,sizeof(struct ppp_header)); h=(struct ppp_header *)skb->data; - if(sp->pp_flags&PP_CISCO) + if (sp->pp_flags&PP_CISCO) { h->address = CISCO_UNICAST; h->control = 0; @@ -376,11 +376,11 @@ h->address = PPP_ALLSTATIONS; h->control = PPP_UI; } - if(sp->pp_flags & PP_CISCO) + if (sp->pp_flags & PP_CISCO) { h->protocol = htons(type); } - else switch(type) + else switch (type) { case ETH_P_IP: h->protocol = htons(PPP_IP); @@ -854,7 +854,7 @@ skb=alloc_skb(dev->hard_header_len+PPP_HEADER_LEN+CISCO_PACKET_LEN, GFP_ATOMIC); - if(skb==NULL) + if (skb==NULL) return; skb_reserve(skb, dev->hard_header_len); @@ -990,7 +990,7 @@ static int sppp_change_mtu(struct net_device *dev, int new_mtu) { - if(new_mtu<128||new_mtu>PPP_MTU||(dev->flags&IFF_UP)) + if (new_mtu<128||new_mtu>PPP_MTU||(dev->flags&IFF_UP)) return -EINVAL; dev->mtu=new_mtu; return 0; @@ -1012,13 +1012,13 @@ { struct sppp *sp = (struct sppp *)sppp_of(dev); - if(dev->flags&IFF_UP) + if (dev->flags&IFF_UP) return -EBUSY; - if(!capable(CAP_NET_ADMIN)) + if (!capable(CAP_NET_ADMIN)) return -EPERM; - switch(cmd) + switch (cmd) { case SPPPIOCCISCO: sp->pp_flags|=PP_CISCO; @@ -1030,15 +1030,15 @@ break; case SPPPIOCDEBUG: sp->pp_flags&=~PP_DEBUG; - if(ifr->ifr_flags) + if (ifr->ifr_flags) sp->pp_flags|=PP_DEBUG; break; case SPPPIOCGFLAGS: - if(copy_to_user(ifr->ifr_data, &sp->pp_flags, sizeof(sp->pp_flags))) + if (copy_to_user(ifr->ifr_data, &sp->pp_flags, sizeof(sp->pp_flags))) return -EFAULT; break; case SPPPIOCSFLAGS: - if(copy_from_user(&sp->pp_flags, ifr->ifr_data, sizeof(sp->pp_flags))) + if (copy_from_user(&sp->pp_flags, ifr->ifr_data, sizeof(sp->pp_flags))) return -EFAULT; break; default: @@ -1464,7 +1464,7 @@ static int __init sync_ppp_init(void) { - if(debug) + if (debug) debug=PP_DEBUG; printk(banner); skb_queue_head_init(&tx_queue); Index: drivers/dahdi/makefw.c =================================================================== --- drivers/dahdi/makefw.c (revision 7493) +++ drivers/dahdi/makefw.c (working copy) @@ -50,7 +50,7 @@ nbytes = 0; printf("static unsigned char %s[] = {\n",argv[2]); i = 0; - while(fgets(buf,sizeof(buf) - 1,fp)) + while (fgets(buf,sizeof(buf) - 1,fp)) { if (!buf[0]) continue; if (buf[strlen(buf) - 1] < ' ') buf[strlen(buf) - 1] = 0; @@ -60,7 +60,7 @@ if (strlen(buf) < 32) continue; if ((buf[0] != '0') && (buf[0] != '1')) continue; c = 0; - for(j = 0; buf[j]; j++) + for (j = 0; buf[j]; j++) { if (buf[j] > '0') c |= 1 << (j & 7); if ((j & 7) == 7) Index: drivers/dahdi/pciradio.c =================================================================== --- drivers/dahdi/pciradio.c (revision 7493) +++ drivers/dahdi/pciradio.c (working copy) @@ -424,7 +424,7 @@ int i; if (!code) return(0); - for(i = 0; cttable_tx[i].code || (!i); i++) + for (i = 0; cttable_tx[i].code || (!i); i++) { if (cttable_tx[i].code == code) { @@ -439,7 +439,7 @@ int i; if (!code) return(0); - for(i = 0; cttable_rx[i].code || (!i); i++) + for (i = 0; cttable_rx[i].code || (!i); i++) { if (cttable_rx[i].code == code) { @@ -455,7 +455,7 @@ int i; if (!code) return(0); - for(i = 0; dcstable[i].code || (!i); i++) + for (i = 0; dcstable[i].code || (!i); i++) { if (dcstable[i].code == code) { @@ -483,7 +483,7 @@ DECLARE_WAIT_QUEUE_HEAD(mywait); - for(;;) + for (;;) { spin_lock_irqsave(&rad->lock,flags); x = rad->remote_locked || (__pciradio_getcreg(rad,0xc) & 2); @@ -496,7 +496,7 @@ /* enable and address RBI serializer */ __pciradio_setcreg(rad,0xf,rad->pfsave | (n << 4) | 0x40); /* output commands */ - for(x = 0; x < 5; x++) __pciradio_setcreg(rad,0xc,rbicmd[x]); + for (x = 0; x < 5; x++) __pciradio_setcreg(rad,0xc,rbicmd[x]); /* output it */ __pciradio_setcreg(rad,0xb,1); rad->remote_locked = 0; @@ -513,7 +513,7 @@ static void mx828_command(struct pciradio *rad,int channel, unsigned char command, unsigned char *byte1, unsigned char *byte2) { - if(channel > 3) + if (channel > 3) return; rad->mx828_addr = channel; @@ -531,7 +531,7 @@ spin_lock_irqsave(&rad->lock,flags); - while(rad->encdec.state) + while (rad->encdec.state) { spin_unlock_irqrestore(&rad->lock,flags); interruptible_sleep_on_timeout(&mywait,2); @@ -539,14 +539,14 @@ } rad->encdec.lastcmd = jiffies + 1000; spin_unlock_irqrestore(&rad->lock,flags); - while(__pciradio_getcreg(rad,0xc) & 1); + while (__pciradio_getcreg(rad,0xc) & 1); rad->encdec.lastcmd = jiffies + 1000; spin_lock_irqsave(&rad->lock,flags); rad->encdec.lastcmd = jiffies + 1000; mx828_command(rad,channel,command,byte1,byte2); spin_unlock_irqrestore(&rad->lock,flags); rad->encdec.lastcmd = jiffies + 1000; - while(__pciradio_getcreg(rad,0xc) & 1); + while (__pciradio_getcreg(rad,0xc) & 1); rad->encdec.lastcmd = jiffies; } @@ -560,10 +560,10 @@ if (__pciradio_getcreg(rad,0xc) & 1) return; n = 0; byte2 = 0; - switch(rad->encdec.state) + switch (rad->encdec.state) { case 0: - for(i = 0; i < rad->nchans; i++) + for (i = 0; i < rad->nchans; i++) { n = (unsigned)(i - rad->intcount) % rad->nchans; if (rad->encdec.req[n]) break; @@ -581,7 +581,7 @@ /* if something in code 0 for rx, is DCS */ if (rad->rxcode[n][0]) rad->encdec.dcsrx[n] = 1; else { /* otherwise, if something in other codes, is CT rx */ - for(i = 1; i <= NUM_CODES; i++) + for (i = 1; i <= NUM_CODES; i++) { if (rad->rxcode[n][1]) rad->encdec.ctrx[n] = 1; } @@ -780,7 +780,7 @@ /* set ctcss to 1 if decoding ctcss */ if (!rad->rxcode[x][0]) { - for(i = 1; i <= NUM_CODES; i++) + for (i = 1; i <= NUM_CODES; i++) { if (rad->rxcode[x][i]) { @@ -823,15 +823,15 @@ gotslowctcss = 1; rad->present_code[x] = 0; } - if(rad->newctcssstate[x] != gotctcss){ + if (rad->newctcssstate[x] != gotctcss){ rad->newctcssstate[x] = gotctcss; - if(rad->newctcssstate[x]) + if (rad->newctcssstate[x]) rad->ctcsstimer[x]=rad->ctcssacquiretime[x]; else rad->ctcsstimer[x]=rad->ctcsstalkofftime[x]; } else{ - if(!rad->ctcsstimer[x]) + if (!rad->ctcsstimer[x]) rad->ctcssstate[x] = rad->newctcssstate[x]; else rad->ctcsstimer[x]--; @@ -848,7 +848,7 @@ rad->last_code[x] = rad->present_code[x]; } _do_encdec(rad); - for(x = 0; x < rad->nchans; x++) + for (x = 0; x < rad->nchans; x++) { unsigned char mask = 1 << x; @@ -930,7 +930,7 @@ } rad->srxtimer++; /* if something in rx to read */ - while(__pciradio_getcreg(rad,9) & 0x10) + while (__pciradio_getcreg(rad,9) & 0x10) { unsigned char c = __pciradio_getcreg(rad,4); rad->srxtimer = 0; @@ -943,7 +943,7 @@ pciradio_receiveprep(rad, ints); pciradio_transmitprep(rad, ints); i = 0; - for(x = 0; x < 4; x++) + for (x = 0; x < 4; x++) { if (rad->gottx[x]) i |= (1 << (x * 2)); if (rad->gotrx[x]) i |= (2 << (x * 2)); @@ -973,7 +973,7 @@ if (copy_from_user(&stack.p, (__user void *) data, sizeof(stack.p))) return -EFAULT; spin_lock_irqsave(&rad->lock,flags); stack.p.data = 0; /* start with 0 value in output */ - switch(stack.p.radpar) { + switch (stack.p.radpar) { case DAHDI_RADPAR_INVERTCOR: if (rad->radmode[chan->chanpos - 1] & RADMODE_INVERTCOR) stack.p.data = 1; @@ -1071,7 +1071,7 @@ case DAHDI_RADIO_SETPARAM: if (copy_from_user(&stack.p, (__user void *) data, sizeof(stack.p))) return -EFAULT; spin_lock_irqsave(&rad->lock,flags); - switch(stack.p.radpar) { + switch (stack.p.radpar) { case DAHDI_RADPAR_INVERTCOR: if (stack.p.data) rad->radmode[chan->chanpos - 1] |= RADMODE_INVERTCOR; @@ -1118,14 +1118,14 @@ rad->radmode[chan->chanpos - 1] &= ~RADMODE_EXTINVERT; break; case DAHDI_RADPAR_INITTONE: - for(i = 0; i <= NUM_CODES; i++) + for (i = 0; i <= NUM_CODES; i++) { rad->rxcode[chan->chanpos - 1][i] = 0; rad->rxclass[chan->chanpos - 1][i] = 0; rad->txcode[chan->chanpos - 1][i] = 0; } spin_unlock_irqrestore(&rad->lock,flags); - for(i = 0; i < NUM_CODES; i++) + for (i = 0; i < NUM_CODES; i++) { /* set to no encode/decode */ byte1 = 0; @@ -1261,7 +1261,7 @@ break; } spin_unlock_irqrestore(&rad->lock,flags); - for(;;) + for (;;) { int x; @@ -1290,7 +1290,7 @@ while (jiffies < rad->lastremcmd + 10) interruptible_sleep_on_timeout(&mywait,10); rad->lastremcmd = jiffies; - for(;;) + for (;;) { if (!(__pciradio_getcreg(rad,0xc) & 2)) break; interruptible_sleep_on_timeout(&mywait,2); @@ -1306,7 +1306,7 @@ rad->srxtimer = 0; memset(stack.p.buf,0,SERIAL_BUFLEN); stack.p.index = 0; - if (stack.p.data) for(;;) + if (stack.p.data) for (;;) { rad->rxbuf[rad->rxindex] = 0; if ((rad->rxindex < stack.p.data) && @@ -1332,7 +1332,7 @@ (!stack.p.data)) { /* wait for TX to be done if not already */ - while(rad->txlen && (rad->txindex < rad->txlen)) + while (rad->txlen && (rad->txindex < rad->txlen)) { spin_unlock_irqrestore(&rad->lock,flags); interruptible_sleep_on_timeout(&mywait,2); @@ -1441,7 +1441,7 @@ { struct pciradio *rad = chan->pvt; - switch(txsig) { + switch (txsig) { case DAHDI_TXSIG_START: case DAHDI_TXSIG_OFFHOOK: rad->gottx[chan->chanpos - 1] = 1; @@ -1498,7 +1498,7 @@ { long newjiffies; newjiffies = jiffies + foo; - while(jiffies < newjiffies); + while (jiffies < newjiffies); } static int pciradio_hardware_init(struct pciradio *rad) @@ -1627,7 +1627,7 @@ /* Wait 1/4 of a second more */ wait_just_a_bit(HZ/4); - for(x = 0; x < rad->nchans; x++) + for (x = 0; x < rad->nchans; x++) { mx828_command_wait(rad,x, MX828_GEN_RESET, &byte1, &byte2 ); byte1 = 0x3f; @@ -1696,7 +1696,7 @@ int x; static int initd_ifaces=0; - if(initd_ifaces){ + if (initd_ifaces){ memset((void *)ifaces,0,(sizeof(struct pciradio *))*RAD_MAX_IFACES); initd_ifaces=1; } @@ -1722,7 +1722,7 @@ rad->ioaddr = pci_resource_start(pdev, 0); rad->dev = pdev; rad->pos = x; - for(i = 0; i < rad->nchans; i++) rad->lasttx[x] = rad->gotrx1[i] = -1; + for (i = 0; i < rad->nchans; i++) rad->lasttx[x] = rad->gotrx1[i] = -1; /* Keep track of whether we need to free the region */ if (request_region(rad->ioaddr, 0xff, "pciradio")) rad->freeregion = 1; Index: drivers/dahdi/tor2.c =================================================================== --- drivers/dahdi/tor2.c (revision 7493) +++ drivers/dahdi/tor2.c (working copy) @@ -1017,7 +1017,7 @@ if (p->tor->cardtype == TYPE_E1) { - switch(cmd) { + switch (cmd) { case DAHDI_MAINT_NONE: t1out(p->tor,tspan,0xa8,0); /* no loops */ break; @@ -1037,7 +1037,7 @@ } return 0; } - switch(cmd) { + switch (cmd) { case DAHDI_MAINT_NONE: t1out(p->tor,tspan,0x19,(japan ? 0x80 : 0x00)); /* no local loop */ t1out(p->tor,tspan,0x0a,0); /* no remote loop */ @@ -1501,7 +1501,7 @@ static int tor2_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long data) { - switch(cmd) { + switch (cmd) { default: return -ENOTTY; } Index: drivers/dahdi/voicebus/GpakApi.c =================================================================== --- drivers/dahdi/voicebus/GpakApi.c (revision 7493) +++ drivers/dahdi/voicebus/GpakApi.c (working copy) @@ -1225,7 +1225,7 @@ *pFramingError3Count = ReadBuffer[2]; *pDmaStopErrorCount = ReadBuffer[3]; - if(pDmaSlipStatsBuffer != 0) + if (pDmaSlipStatsBuffer != 0) // If users want to get the DMA slips count { pDmaSlipStatsBuffer[0] = ReadBuffer[4]; Index: drivers/dahdi/wcb4xxp/base.c =================================================================== --- drivers/dahdi/wcb4xxp/base.c (revision 7493) +++ drivers/dahdi/wcb4xxp/base.c (working copy) @@ -1232,7 +1232,7 @@ /* First, disable the expired timer; hfc_force_st_state() may activate it again. */ s->hfc_timer_on[t_no] = 0; - switch(t_no) { + switch (t_no) { case HFC_T1: /* switch to G4 (pending deact.), resume auto mode */ hfc_force_st_state(b4, s->port, 4, 1); break; @@ -1310,7 +1310,7 @@ oldtimer = s->alarmtimer; if (nt) { - switch(sta) { + switch (sta) { default: /* Invalid NT state */ case 0x0: /* NT state G0: Reset */ case 0x1: /* NT state G1: Deactivated */ @@ -1326,7 +1326,7 @@ break; } } else { - switch(sta) { + switch (sta) { default: /* Invalid TE state */ case 0x0: /* TE state F0: Reset */ case 0x2: /* TE state F2: Sensing */ @@ -2120,7 +2120,7 @@ */ static int b4xxp_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long data) { - switch(cmd) { + switch (cmd) { default: return -ENOTTY; } Index: drivers/dahdi/wcb4xxp/wcb4xxp.h =================================================================== --- drivers/dahdi/wcb4xxp/wcb4xxp.h (revision 7493) +++ drivers/dahdi/wcb4xxp/wcb4xxp.h (working copy) @@ -506,7 +506,7 @@ f2 = hfc_readcounter8(b4, A_F2); \ flen = f1 - f2; \ \ - if(flen < 0) \ + if (flen < 0) \ flen += (HFC_FMAX - HFC_FMIN) + 1; \ } @@ -515,7 +515,7 @@ z2 = hfc_readcounter16(b4, A_Z2); \ zlen = z1 - z2; \ \ - if(zlen < 0) \ + if (zlen < 0) \ zlen += (HFC_ZMAX - HFC_ZMIN) + 1; \ } Index: drivers/dahdi/wcfxo.c =================================================================== --- drivers/dahdi/wcfxo.c (revision 7493) +++ drivers/dahdi/wcfxo.c (working copy) @@ -292,7 +292,7 @@ } /* Prepare the command to follow it */ - switch(wc->regs[x].flags) { + switch (wc->regs[x].flags) { case FLAG_READ: cmd = (wc->regs[x].reg | 0x20) << 8; break; @@ -348,7 +348,7 @@ realval = (le32_to_cpu(readchunk[(x << 1) +wc->alt]) >> 16) & 0xff; if ((realval == 0x89) && (realreg != WC_DAA_PLL2_N2_M2)) { /* Some sort of slippage, correct for it */ - while(realreg != WC_DAA_PLL2_N2_M2) { + while (realreg != WC_DAA_PLL2_N2_M2) { /* Find register 9 */ realreg = wecareregs[(wc->regs[x].index + ++wc->regoffset) % (sizeof(wecareregs) / sizeof(wecareregs[0]))]; @@ -594,7 +594,7 @@ { struct wcfxo *wc = chan->pvt; int reg=0; - switch(txsig) { + switch (txsig) { case DAHDI_TXSIG_START: case DAHDI_TXSIG_OFFHOOK: /* Take off hook and enable normal mode reception. This must @@ -855,7 +855,7 @@ /* REVB: reg. 13, bits 5:2 */ chip_revb = (wc->readregs[WC_DAA_CHIPB_REV] >> 2) & 0xF; wcfxo_dbg(wc->span, "DAA chip REVB is %x\n", chip_revb); - switch(chip_revb) { + switch (chip_revb) { case 1: case 2: case 3: /* This is a si3034. Nothing to do */ break; Index: drivers/dahdi/wct1xxp.c =================================================================== --- drivers/dahdi/wct1xxp.c (revision 7493) +++ drivers/dahdi/wct1xxp.c (working copy) @@ -390,7 +390,7 @@ /* Wait 100ms to give plenty of time for reset */ endjiffies = jiffies + 10; - while(endjiffies < jiffies); + while (endjiffies < jiffies); spin_lock_irqsave(&wc->lock, flags); @@ -454,13 +454,13 @@ __t1_set_reg(wc,0x20,0x1b); /* TAFR */ __t1_set_reg(wc,0x21,0x5f); /* TNAFR */ __t1_set_reg(wc,0x40,0xb); /* TSR1 */ - for(i = 0x41; i <= 0x4f; i++) __t1_set_reg(wc,i,0x55); - for(i = 0x22; i <= 0x25; i++) __t1_set_reg(wc,i,0xff); + for (i = 0x41; i <= 0x4f; i++) __t1_set_reg(wc,i,0x55); + for (i = 0x22; i <= 0x25; i++) __t1_set_reg(wc,i,0xff); spin_unlock_irqrestore(&wc->lock, flags); /* Wait 100ms to give plenty of time for reset */ endjiffies = jiffies + 10; - while(endjiffies < jiffies); + while (endjiffies < jiffies); spin_lock_irqsave(&wc->lock, flags); @@ -598,7 +598,7 @@ static int t1xxp_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long data) { - switch(cmd) { + switch (cmd) { default: return -ENOTTY; } @@ -611,7 +611,7 @@ int i,alreadyrunning = span->flags & DAHDI_FLAG_RUNNING; /* initialize the start value for the entire chunk of last ec buffer */ - for(i = 0; i < span->channels; i++) + for (i = 0; i < span->channels; i++) { memset(wc->ec_chunk1[i], DAHDI_LIN2X(0,span->chans[i]),DAHDI_CHUNKSIZE); @@ -657,7 +657,7 @@ unsigned long flags; spin_lock_irqsave(&wc->lock, flags); if (wc->ise1) { - switch(cmd) { + switch (cmd) { case DAHDI_MAINT_NONE: __t1_set_reg(wc,0xa8,0); /* no loops */ break; @@ -678,7 +678,7 @@ break; } } else { - switch(cmd) { + switch (cmd) { case DAHDI_MAINT_NONE: __t1_set_reg(wc,0x19,0); /* no local loop */ __t1_set_reg(wc,0x0a,0); /* no remote loop */ @@ -1184,7 +1184,7 @@ /* Do some things that we don't have to do very often */ x = wc->intcount & 15 /* 63 */; - switch(x) { + switch (x) { case 0: case 1: case 2: Index: drivers/dahdi/wct4xxp/base.c =================================================================== --- drivers/dahdi/wct4xxp/base.c (revision 7493) +++ drivers/dahdi/wct4xxp/base.c (working copy) @@ -595,7 +595,7 @@ static inline void wait_a_little(void) { unsigned long newjiffies=jiffies+2; - while(jiffies < newjiffies); + while (jiffies < newjiffies); } static inline unsigned int __t4_vpm_in(struct t4 *wc, int unit, const unsigned int addr) @@ -664,7 +664,7 @@ __t4_raw_oct_out(wc, 0x000a, (addr >> 4) & ((1 << 16) - 1)); __t4_raw_oct_out(wc, 0x0000, (((addr >> 1) & 0x7) << 9) | (1 << 8) | (1)); #ifdef PEDANTIC_OCTASIC_CHECKING - while((__t4_raw_oct_in(wc, 0x0000) & (1 << 8)) && --count); + while ((__t4_raw_oct_in(wc, 0x0000) & (1 << 8)) && --count); if (count != 1000) printk(KERN_DEBUG "Yah, read can be slow...\n"); if (!count) @@ -728,7 +728,7 @@ __t4_raw_oct_out(wc, 0x0004, value); __t4_raw_oct_out(wc, 0x0000, (((addr >> 1) & 0x7) << 9) | (1 << 8) | (3 << 12) | 1); #ifdef PEDANTIC_OCTASIC_CHECKING - while((__t4_raw_oct_in(wc, 0x0000) & (1 << 8)) && --count); + while ((__t4_raw_oct_in(wc, 0x0000) & (1 << 8)) && --count); if (count != 1000) printk(KERN_DEBUG "Yah, write can be slow\n"); if (!count) @@ -760,7 +760,7 @@ int channel, tone, start, span; if (vpm450m_checkirq(wc->vpm450m)) { - while(vpm450m_getdtmf(wc->vpm450m, &channel, &tone, &start)) { + while (vpm450m_getdtmf(wc->vpm450m, &channel, &tone, &start)) { span = channel & 0x3; channel >>= 2; if (!wc->t1e1) @@ -810,7 +810,7 @@ lastio = newio; - for(x = 0; x < 8; x++) { + for (x = 0; x < 8; x++) { if (newio & (1 << (7 - x))) continue; ts = wc->tspans[x%4]; @@ -822,8 +822,8 @@ t4_vpm_out(wc, x, 0xb9, regbyte); regval |= regbyte; - for(i = 0; (i < MAX_DTMF_DET) && regval; i++) { - if(regval & 0x0001) { + for (i = 0; (i < MAX_DTMF_DET) && regval; i++) { + if (regval & 0x0001) { int channel = (i << 1) + (x >> 2); int base = channel - 1; @@ -873,8 +873,8 @@ t4_vpm_out(wc, x, 0xbd, regbyte); regval |= regbyte; - for(i = 0; (i < MAX_DTMF_DET) && regval; i++) { - if(regval & 0x0001) { + for (i = 0; (i < MAX_DTMF_DET) && regval; i++) { + if (regval & 0x0001) { int channel = (i << 1) + (x >> 2); int base = channel - 1; @@ -1106,7 +1106,7 @@ static int t4_vpm_unit(int span, int channel) { int unit = 0; - switch(vpmspans) { + switch (vpmspans) { case 4: unit = span; unit += (channel & 1) << 2; @@ -1222,7 +1222,7 @@ } #endif - switch(cmd) { + switch (cmd) { case WCT4_GET_REGS: for (x=0;xowner; if (ts->spantype == TYPE_E1) { - switch(cmd) { + switch (cmd) { case DAHDI_MAINT_NONE: printk(KERN_INFO "XXX Turn off local and remote loops E1 XXX\n"); break; @@ -1352,7 +1352,7 @@ break; } } else { - switch(cmd) { + switch (cmd) { case DAHDI_MAINT_NONE: printk(KERN_NOTICE "XXX Turn off local and remote loops T1 XXX\n"); break; @@ -1387,7 +1387,7 @@ struct t4_span *ts = wc->tspans[chan->span->offset]; unsigned long flags; - if(debug & DEBUG_RBS) printk(KERN_DEBUG "Setting bits to %d on channel %s\n", bits, chan->name); + if (debug & DEBUG_RBS) printk(KERN_DEBUG "Setting bits to %d on channel %s\n", bits, chan->name); spin_lock_irqsave(&wc->reglock, flags); k = chan->span->offset; if (ts->spantype == TYPE_E1) { /* do it E1 way */ @@ -1501,7 +1501,7 @@ lc->sync = 0; /* remove this span number from the current sync sources, if there */ - for(i = 0; i < wc->numspans; i++) { + for (i = 0; i < wc->numspans; i++) { if (wc->tspans[i]->sync == span->spanno) { wc->tspans[i]->sync = 0; wc->tspans[i]->psync = 0; @@ -1955,7 +1955,7 @@ __t4_framer_out(wc, unit, 0x39, 0x15); /* PCR: 22 "ones" clear LOS */ /* Generate pulse mask for T1 */ - switch(mytxlevel) { + switch (mytxlevel) { case 3: __t4_framer_out(wc, unit, 0x26, 0x07); /* XPM0 */ __t4_framer_out(wc, unit, 0x27, 0x01); /* XPM1 */ @@ -2092,7 +2092,7 @@ #ifdef SUPPORT_GEN1 /* initialize the start value for the entire chunk of last ec buffer */ - for(i = 0; i < span->channels; i++) + for (i = 0; i < span->channels; i++) { memset(ts->ec_chunk1[i], DAHDI_LIN2X(0,span->chans[i]),DAHDI_CHUNKSIZE); @@ -2955,7 +2955,7 @@ t4_do_counters(wc); x = wc->intcount & 15 /* 63 */; - switch(x) { + switch (x) { case 0: case 1: case 2: @@ -3163,7 +3163,7 @@ static unsigned int t4_vpm_mask(int chip) { unsigned int mask=0; - switch(vpmspans) { + switch (vpmspans) { case 4: mask = 0x55555555 << (chip >> 2); break; @@ -3180,7 +3180,7 @@ static int t4_vpm_spanno(int chip) { int spanno = 0; - switch(vpmspans) { + switch (vpmspans) { case 4: spanno = chip & 0x3; break; @@ -3195,7 +3195,7 @@ static int t4_vpm_echotail(void) { int echotail = 0x01ff; - switch(vpmspans) { + switch (vpmspans) { case 4: echotail = 0x007f; break; @@ -3323,7 +3323,7 @@ return; } - switch(vpmspans) { + switch (vpmspans) { case 4: case 2: case 1: @@ -3718,7 +3718,7 @@ /* Initialize hardware */ t4_hardware_init_1(wc, dt->flags); - for(x = 0; x < MAX_T4_CARDS; x++) { + for (x = 0; x < MAX_T4_CARDS; x++) { if (!cards[x]) break; } Index: drivers/dahdi/wct4xxp/vpm450m.c =================================================================== --- drivers/dahdi/wct4xxp/vpm450m.c (revision 7493) +++ drivers/dahdi/wct4xxp/vpm450m.c (working copy) @@ -331,7 +331,7 @@ if (channel) *channel = tonefound.ulUserChanId; if (tone) { - switch(tonefound.ulToneDetected) { + switch (tonefound.ulToneDetected) { case SOUT_DTMF_1: *tone = '1'; break; Index: drivers/dahdi/wctdm.c =================================================================== --- drivers/dahdi/wctdm.c (revision 7493) +++ drivers/dahdi/wctdm.c (working copy) @@ -635,7 +635,7 @@ } - if(count > (MAX-1)) printk(KERN_NOTICE " ##### Loop error (%02x) #####\n", data); + if (count > (MAX-1)) printk(KERN_NOTICE " ##### Loop error (%02x) #####\n", data); return 0; } @@ -663,7 +663,7 @@ return 0; } spin_lock_irqsave(&wc->lock, flags); - if(!__wait_access(wc, card)) { + if (!__wait_access(wc, card)) { __wctdm_setreg(wc, card, IDA_LO,(unsigned char)(data & 0xFF)); __wctdm_setreg(wc, card, IDA_HI,(unsigned char)((data & 0xFF00)>>8)); __wctdm_setreg(wc, card, IAA,address); @@ -708,7 +708,7 @@ for (i=0; iintcount & 0x3; mode = wc->intcount & 0xc; if (wc->cardflag & (1 << x)) { - switch(mode) { + switch (mode) { case 0: /* Rest */ break; @@ -1280,7 +1280,7 @@ /* Wait for one second */ origjiffies = jiffies; - while((vbat = wctdm_getreg(wc, card, 82)) > 0x6) { + while ((vbat = wctdm_getreg(wc, card, 82)) > 0x6) { if ((jiffies - origjiffies) >= (HZ/2)) break;; } @@ -1314,7 +1314,7 @@ if (fast) return 0; - while((vbat = wctdm_getreg(wc, card, 82)) < 0xc0) { + while ((vbat = wctdm_getreg(wc, card, 82)) < 0xc0) { /* Wait no more than 500ms */ if ((jiffies - origjiffies) > HZ/2) { break; @@ -1350,7 +1350,7 @@ wctdm_setreg(wc, card, 93, 0x19 /* was 0x19 */); #if 0 origjiffies = jiffies; - while(0x80 & wctdm_getreg(wc, card, 93)) { + while (0x80 & wctdm_getreg(wc, card, 93)) { if ((jiffies - origjiffies) > 2 * HZ) { printk(KERN_DEBUG "Timeout waiting for DC-DC calibration on module %d\n", card); return -1; @@ -1359,7 +1359,7 @@ #if 0 /* Wait a full two seconds */ - while((jiffies - origjiffies) < 2 * HZ); + while ((jiffies - origjiffies) < 2 * HZ); /* Just check to be sure */ vbat = wctdm_getreg(wc, card, 82); @@ -1384,8 +1384,8 @@ wctdm_setreg(wc, card, 96, 0x47); //(0x47) Calibrate common mode and differential DAC mode DAC + ILIM origjiffies=jiffies; - while( wctdm_getreg(wc,card,96)!=0 ){ - if((jiffies-origjiffies)>80) + while ( wctdm_getreg(wc,card,96)!=0 ){ + if ((jiffies-origjiffies)>80) return -1; } //Initialized DR 98 and 99 to get consistant results. @@ -1395,7 +1395,7 @@ /*******************************This is also available as a function *******************************************/ // Delay 10ms origjiffies=jiffies; - while((jiffies-origjiffies)<1); + while ((jiffies-origjiffies)<1); wctdm_proslic_setreg_indirect(wc, card, 88, 0); wctdm_proslic_setreg_indirect(wc, card, 89, 0); wctdm_proslic_setreg_indirect(wc, card, 90, 0); @@ -1410,8 +1410,8 @@ { wctdm_setreg(wc, card, 98, i); origjiffies=jiffies; - while((jiffies-origjiffies)<4); - if((wctdm_getreg(wc, card, 88)) == 0) + while ((jiffies-origjiffies)<4); + if ((wctdm_getreg(wc, card, 88)) == 0) break; } // for @@ -1419,15 +1419,15 @@ { wctdm_setreg(wc, card, 99, i); origjiffies=jiffies; - while((jiffies-origjiffies)<4); - if((wctdm_getreg(wc, card, 89)) == 0) + while ((jiffies-origjiffies)<4); + if ((wctdm_getreg(wc, card, 89)) == 0) break; }//for /*******************************The preceding is the manual gain mismatch calibration****************************/ /**********************************The following is the longitudinal Balance Cal***********************************/ wctdm_setreg(wc,card,64,1); - while((jiffies-origjiffies)<10); // Sleep 100? + while ((jiffies-origjiffies)<10); // Sleep 100? wctdm_setreg(wc, card, 64, 0); wctdm_setreg(wc, card, 23, 0x4); // enable interrupt for the balance Cal @@ -1457,7 +1457,7 @@ /* Wait for it to finish */ origjiffies = jiffies; - while(wctdm_getreg(wc, card, 96)) { + while (wctdm_getreg(wc, card, 96)) { if ((jiffies - origjiffies) > 2 * HZ) { printk(KERN_NOTICE "Timeout waiting for calibration of module %d\n", card); return -1; @@ -1479,7 +1479,7 @@ { long newjiffies; newjiffies = jiffies + foo; - while(jiffies < newjiffies); + while (jiffies < newjiffies); } /********************************************************************* @@ -1629,7 +1629,7 @@ reg16 |= (fxo_modes[_opermode].rt); wctdm_setreg(wc, card, 16, reg16); - if(fwringdetect) { + if (fwringdetect) { /* Enable ring detector full-wave rectifier mode */ wctdm_setreg(wc, card, 18, 2); wctdm_setreg(wc, card, 24, 0); @@ -1674,7 +1674,7 @@ /* Wait 1000ms for ISO-cap to come up */ newjiffies = jiffies; newjiffies += 2 * HZ; - while((jiffies < newjiffies) && !(wctdm_getreg(wc, card, 11) & 0xf0)) + while ((jiffies < newjiffies) && !(wctdm_getreg(wc, card, 11) & 0xf0)) wait_just_a_bit(HZ/10); if (!(wctdm_getreg(wc, card, 11) & 0xf0)) { @@ -1698,7 +1698,7 @@ wctdm_set_hwgain(wc, card, 7, 1); } - if(debug) + if (debug) printk(KERN_DEBUG "DEBUG fxotxgain:%i.%i fxorxgain:%i.%i\n", (wctdm_getreg(wc, card, 38)/16)?-(wctdm_getreg(wc, card, 38) - 16) : wctdm_getreg(wc, card, 38), (wctdm_getreg(wc, card, 40)/16)? -(wctdm_getreg(wc, card, 40) - 16):wctdm_getreg(wc, card, 40), (wctdm_getreg(wc, card, 39)/16)? -(wctdm_getreg(wc, card, 39) - 16) : wctdm_getreg(wc, card, 39),(wctdm_getreg(wc, card, 41)/16)?-(wctdm_getreg(wc, card, 41) - 16):wctdm_getreg(wc, card, 41)); return 0; @@ -1784,7 +1784,7 @@ } #ifndef NO_CALIBRATION /* Perform calibration */ - if(manual) { + if (manual) { if (wctdm_proslic_manual_calibrate(wc, card)) { //printk(KERN_NOTICE "Proslic failed on Manual Calibration\n"); if (wctdm_proslic_manual_calibrate(wc, card)) { @@ -1795,7 +1795,7 @@ } } else { - if(wctdm_proslic_calibrate(wc, card)) { + if (wctdm_proslic_calibrate(wc, card)) { //printk(KERN_NOTICE "ProSlic died on Auto Calibration.\n"); if (wctdm_proslic_calibrate(wc, card)) { printk(KERN_NOTICE "Proslic Failed on Second Attempt to Auto Calibrate\n"); @@ -1883,7 +1883,7 @@ return -1; } - if(fxstxgain || fxsrxgain) { + if (fxstxgain || fxsrxgain) { r9 = wctdm_getreg(wc, card, 9); switch (fxstxgain) { @@ -1911,7 +1911,7 @@ wctdm_setreg(wc,card,9,r9); } - if(debug) + if (debug) printk(KERN_DEBUG "DEBUG: fxstxgain:%s fxsrxgain:%s\n",((wctdm_getreg(wc, card, 9)/8) == 1)?"3.5":(((wctdm_getreg(wc,card,9)/4) == 1)?"-3.5":"0.0"),((wctdm_getreg(wc, card, 9)/2) == 1)?"3.5":((wctdm_getreg(wc,card,9)%2)?"-3.5":"0.0")); fxs->lasttxhook = fxs->idletxhookstate; @@ -2256,7 +2256,7 @@ int chan_entry = chan->chanpos - 1; if (wc->modtype[chan_entry] == MOD_TYPE_FXO) { /* XXX Enable hooksig for FXO XXX */ - switch(txsig) { + switch (txsig) { case DAHDI_TXSIG_START: case DAHDI_TXSIG_OFFHOOK: wc->mod[chan_entry].fxo.offhook = 1; @@ -2271,9 +2271,9 @@ } } else { struct fxs *const fxs = &wc->mod[chan_entry].fxs; - switch(txsig) { + switch (txsig) { case DAHDI_TXSIG_ONHOOK: - switch(chan->sig) { + switch (chan->sig) { case DAHDI_SIG_FXOKS: case DAHDI_SIG_FXOLS: /* Can't change Ring Generator during OHT */ @@ -2296,7 +2296,7 @@ } break; case DAHDI_TXSIG_OFFHOOK: - switch(chan->sig) { + switch (chan->sig) { case DAHDI_SIG_EM: fxs->lasttxhook = SLIC_LF_ACTIVE_REV; break; @@ -2487,7 +2487,7 @@ } printk(KERN_INFO "Module %d: Installed -- AUTO FXS/DPO\n",x); } else { - if(ret!=-2) { + if (ret!=-2) { sane=1; /* Init with Manual Calibration */ if (!wctdm_init_proslic(wc, x, 0, 1, sane)) { Index: drivers/dahdi/wctdm24xxp/base.c =================================================================== --- drivers/dahdi/wctdm24xxp/base.c (revision 7493) +++ drivers/dahdi/wctdm24xxp/base.c (working copy) @@ -1072,7 +1072,7 @@ } - if(count > (MAX-1)) printk(KERN_NOTICE " ##### Loop error (%02x) #####\n", data); + if (count > (MAX-1)) printk(KERN_NOTICE " ##### Loop error (%02x) #####\n", data); return 0; } @@ -1098,7 +1098,7 @@ if (address == 255) return 0; } - if(!wait_access(wc, card)) { + if (!wait_access(wc, card)) { wctdm_setreg(wc, card, IDA_LO,(unsigned char)(data & 0xFF)); wctdm_setreg(wc, card, IDA_HI,(unsigned char)((data & 0xFF00)>>8)); wctdm_setreg(wc, card, IAA,address); @@ -1139,7 +1139,7 @@ for (i = 0; i < ARRAY_SIZE(indirect_regs); i++) { - if(wctdm_proslic_setreg_indirect(wc, card, indirect_regs[i].address,indirect_regs[i].initial)) + if (wctdm_proslic_setreg_indirect(wc, card, indirect_regs[i].address,indirect_regs[i].initial)) return -1; } @@ -1154,7 +1154,7 @@ for (i = 0; i < ARRAY_SIZE(indirect_regs); i++) { - if((j = wctdm_proslic_getreg_indirect(wc, card, (unsigned char) indirect_regs[i].address)) < 0) { + if ((j = wctdm_proslic_getreg_indirect(wc, card, (unsigned char) indirect_regs[i].address)) < 0) { printk(KERN_NOTICE "Failed to read indirect register %d\n", i); return -1; } @@ -1309,7 +1309,7 @@ wctdm_setreg_intr(wc, card, 5, 0x8); } if (!fxo->offhook) { - if(fwringdetect || neonmwi_monitor) { + if (fwringdetect || neonmwi_monitor) { /* Look for ring status bits (Ring Detect Signal Negative and * Ring Detect Signal Positive) to transition back and forth * some number of times to indicate that a ring is occurring. @@ -1332,7 +1332,7 @@ /* If ring detect signal has transversed */ if (res && res != fxo->lastrdtx) { /* if there are at least 3 ring polarity transversals */ - if(++fxo->lastrdtx_count >= 2) { + if (++fxo->lastrdtx_count >= 2) { fxo->wasringing = 1; if (debug) printk("FW RING on %d/%d!\n", wc->span.spanno, card + 1); @@ -1544,7 +1544,7 @@ fxo->neonmwi_last_voltage = b; if (NEONMWI_ON_DEBOUNCE == fxo->neonmwi_debounce) { fxo->neonmwi_offcounter = neonmwi_offlimit_cycles; - if(0 == fxo->neonmwi_state) { + if (0 == fxo->neonmwi_state) { dahdi_qevent_lock(wc->chans[card], DAHDI_EVENT_NEONMWI_ACTIVE); fxo->neonmwi_state = 1; if (debug) @@ -1914,7 +1914,7 @@ /* Wait for one second */ origjiffies = jiffies; - while((vbat = wctdm_getreg(wc, card, 82)) > 0x6) { + while ((vbat = wctdm_getreg(wc, card, 82)) > 0x6) { if ((jiffies - origjiffies) >= (HZ/2)) break;; } @@ -1948,7 +1948,7 @@ if (fast) return 0; - while((vbat = wctdm_getreg(wc, card, 82)) < 0xc0) { + while ((vbat = wctdm_getreg(wc, card, 82)) < 0xc0) { /* Wait no more than 500ms */ if ((jiffies - origjiffies) > HZ/2) { break; @@ -1981,7 +1981,7 @@ wctdm_setreg(wc, card, 93, 0x19 /* was 0x19 */); #if 0 origjiffies = jiffies; - while(0x80 & wctdm_getreg(wc, card, 93)) { + while (0x80 & wctdm_getreg(wc, card, 93)) { if ((jiffies - origjiffies) > 2 * HZ) { printk(KERN_DEBUG "Timeout waiting for DC-DC calibration on module %d\n", card); return -1; @@ -1990,7 +1990,7 @@ #if 0 /* Wait a full two seconds */ - while((jiffies - origjiffies) < 2 * HZ); + while ((jiffies - origjiffies) < 2 * HZ); /* Just check to be sure */ vbat = wctdm_getreg(wc, card, 82); @@ -2016,8 +2016,8 @@ wctdm_setreg(wc, card, 96, 0x47); //(0x47) Calibrate common mode and differential DAC mode DAC + ILIM origjiffies=jiffies; - while( wctdm_getreg(wc,card,96)!=0 ){ - if((jiffies-origjiffies)>80) + while ( wctdm_getreg(wc,card,96)!=0 ){ + if ((jiffies-origjiffies)>80) return -1; } //Initialized DR 98 and 99 to get consistant results. @@ -2027,7 +2027,7 @@ /*******************************This is also available as a function *******************************************/ // Delay 10ms origjiffies=jiffies; - while((jiffies-origjiffies)<1); + while ((jiffies-origjiffies)<1); wctdm_proslic_setreg_indirect(wc, card, 88,0); wctdm_proslic_setreg_indirect(wc,card,89,0); wctdm_proslic_setreg_indirect(wc,card,90,0); @@ -2042,8 +2042,8 @@ { wctdm_setreg(wc, card, 98,i); origjiffies=jiffies; - while((jiffies-origjiffies)<4); - if((wctdm_getreg(wc,card,88)) == 0) + while ((jiffies-origjiffies)<4); + if ((wctdm_getreg(wc,card,88)) == 0) break; } // for @@ -2051,15 +2051,15 @@ { wctdm_setreg(wc, card, 99,i); origjiffies=jiffies; - while((jiffies-origjiffies)<4); - if((wctdm_getreg(wc,card,89)) == 0) + while ((jiffies-origjiffies)<4); + if ((wctdm_getreg(wc,card,89)) == 0) break; }//for /*******************************The preceding is the manual gain mismatch calibration****************************/ /**********************************The following is the longitudinal Balance Cal***********************************/ wctdm_setreg(wc,card,64,1); - while((jiffies-origjiffies)<10); // Sleep 100? + while ((jiffies-origjiffies)<10); // Sleep 100? wctdm_setreg(wc, card, 64, 0); wctdm_setreg(wc, card, 23, 0x4); // enable interrupt for the balance Cal @@ -2089,7 +2089,7 @@ /* Wait for it to finish */ origjiffies = jiffies; - while(wctdm_getreg(wc, card, 96)) { + while (wctdm_getreg(wc, card, 96)) { if ((jiffies - origjiffies) > 2 * HZ) { printk(KERN_NOTICE "Timeout waiting for calibration of module %d\n", card); return -1; @@ -2110,7 +2110,7 @@ { long newjiffies; newjiffies = jiffies + foo; - while(jiffies < newjiffies); + while (jiffies < newjiffies); } /********************************************************************* @@ -2260,7 +2260,7 @@ reg16 |= (fxo_modes[_opermode].rt); wctdm_setreg(wc, card, 16, reg16); - if(fwringdetect || neonmwi_monitor) { + if (fwringdetect || neonmwi_monitor) { /* Enable ring detector full-wave rectifier mode */ wctdm_setreg(wc, card, 18, 2); wctdm_setreg(wc, card, 24, 0); @@ -2302,7 +2302,7 @@ /* Wait 1000ms for ISO-cap to come up */ newjiffies = jiffies; newjiffies += 2 * HZ; - while((jiffies < newjiffies) && !(wctdm_getreg(wc, card, 11) & 0xf0)) + while ((jiffies < newjiffies) && !(wctdm_getreg(wc, card, 11) & 0xf0)) wait_just_a_bit(HZ/10); if (!(wctdm_getreg(wc, card, 11) & 0xf0)) { @@ -2320,7 +2320,7 @@ wctdm_set_hwgain(wc, card, fxotxgain, 1); wctdm_set_hwgain(wc, card, fxorxgain, 0); - if(debug) + if (debug) printk(KERN_DEBUG "DEBUG fxotxgain:%i.%i fxorxgain:%i.%i\n", (wctdm_getreg(wc, card, 38)/16) ? -(wctdm_getreg(wc, card, 38) - 16) : wctdm_getreg(wc, card, 38), (wctdm_getreg(wc, card, 40)/16) ? -(wctdm_getreg(wc, card, 40) - 16) : wctdm_getreg(wc, card, 40), (wctdm_getreg(wc, card, 39)/16) ? -(wctdm_getreg(wc, card, 39) - 16): wctdm_getreg(wc, card, 39), (wctdm_getreg(wc, card, 41)/16)?-(wctdm_getreg(wc, card, 41) - 16) : wctdm_getreg(wc, card, 41)); return 0; @@ -2406,7 +2406,7 @@ } #ifndef NO_CALIBRATION /* Perform calibration */ - if(manual) { + if (manual) { if (wctdm_proslic_manual_calibrate(wc, card)) { //printk(KERN_NOTICE "Proslic failed on Manual Calibration\n"); if (wctdm_proslic_manual_calibrate(wc, card)) { @@ -2417,7 +2417,7 @@ } } else { - if(wctdm_proslic_calibrate(wc, card)) { + if (wctdm_proslic_calibrate(wc, card)) { //printk(KERN_NOTICE "ProSlic died on Auto Calibration.\n"); if (wctdm_proslic_calibrate(wc, card)) { printk(KERN_NOTICE "Proslic Failed on Second Attempt to Auto Calibrate\n"); @@ -2609,18 +2609,18 @@ wc->modtype[card] = MOD_TYPE_NONE; return 1; } - for(x = 0; x < 0x30; x++) + for (x = 0; x < 0x30; x++) { if ((x >= 0x1c) && (x <= 0x1e)) wctdm_setreg(wc,card,x,0xff); else wctdm_setreg(wc,card,x,0); } wctdm_setreg(wc,card,0,0x80); endjif = jiffies + (HZ/10); - while(endjif > jiffies); + while (endjif > jiffies); wctdm_setreg(wc,card,0,0x10); wctdm_setreg(wc,card,0,0x10); endjif = jiffies + (HZ/10); - while(endjif > jiffies); + while (endjif > jiffies); /* set up modes */ wctdm_setreg(wc,card,0,0x1c); /* set up I/O directions */ @@ -2882,7 +2882,7 @@ if (copy_from_user(&stack.p, (__user void *) data, sizeof(stack.p))) return -EFAULT; stack.p.data = 0; /* start with 0 value in output */ - switch(stack.p.radpar) { + switch (stack.p.radpar) { case DAHDI_RADPAR_INVERTCOR: if (wc->radmode[chan->chanpos - 1] & RADMODE_INVERTCOR) stack.p.data = 1; @@ -2940,7 +2940,7 @@ return -ENOTTY; if (copy_from_user(&stack.p, (__user void *) data, sizeof(stack.p))) return -EFAULT; - switch(stack.p.radpar) { + switch (stack.p.radpar) { case DAHDI_RADPAR_INVERTCOR: if (stack.p.data) wc->radmode[chan->chanpos - 1] |= RADMODE_INVERTCOR; @@ -3088,7 +3088,7 @@ int reg=0,qrvcard; if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_QRV) { qrvcard = (chan->chanpos - 1) & 0xfc; - switch(txsig) { + switch (txsig) { case DAHDI_TXSIG_START: case DAHDI_TXSIG_OFFHOOK: wc->qrvhook[chan->chanpos - 1] = 1; @@ -3105,7 +3105,7 @@ wc->sethook[qrvcard] = CMD_WR(3, reg); /* wctdm_setreg(wc, qrvcard, 3, reg); */ } else if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_FXO) { - switch(txsig) { + switch (txsig) { case DAHDI_TXSIG_START: case DAHDI_TXSIG_OFFHOOK: wc->mods[chan->chanpos - 1].fxo.offhook = 1; @@ -3124,9 +3124,9 @@ unsigned long flags; struct fxs *const fxs = &wc->mods[chan->chanpos - 1].fxs; spin_lock_irqsave(&fxs->lasttxhooklock, flags); - switch(txsig) { + switch (txsig) { case DAHDI_TXSIG_ONHOOK: - switch(chan->sig) { + switch (chan->sig) { case DAHDI_SIG_EM: case DAHDI_SIG_FXOKS: case DAHDI_SIG_FXOLS: @@ -3145,7 +3145,7 @@ } break; case DAHDI_TXSIG_OFFHOOK: - switch(chan->sig) { + switch (chan->sig) { case DAHDI_SIG_EM: if (POLARITY_XOR(chan->chanpos -1)) { fxs->lasttxhook = SLIC_LF_OPPENDING | @@ -3202,7 +3202,7 @@ /* proslic */ wctdm_setreg(wc, srccard, PCM_XMIT_START_COUNT_LSB, ((srccard+24) * 8) & 0xff); wctdm_setreg(wc, srccard, PCM_XMIT_START_COUNT_MSB, ((srccard+24) * 8) >> 8); - } else if(wc->modtype[srccard] == MOD_TYPE_FXO) { + } else if (wc->modtype[srccard] == MOD_TYPE_FXO) { /* daa */ wctdm_setreg(wc, srccard, 34, ((srccard+24) * 8) & 0xff); /* TX */ wctdm_setreg(wc, srccard, 35, ((srccard+24) * 8) >> 8); /* TX */ @@ -3213,7 +3213,7 @@ /* proslic */ wctdm_setreg(wc, dstcard, PCM_RCV_START_COUNT_LSB, ((srccard+24) * 8) & 0xff); wctdm_setreg(wc, dstcard, PCM_RCV_START_COUNT_MSB, ((srccard+24) * 8) >> 8); - } else if(wc->modtype[dstcard] == MOD_TYPE_FXO) { + } else if (wc->modtype[dstcard] == MOD_TYPE_FXO) { /* daa */ wctdm_setreg(wc, dstcard, 36, ((srccard+24) * 8) & 0xff); /* RX */ wctdm_setreg(wc, dstcard, 37, ((srccard+24) * 8) >> 8); /* RX */ @@ -3228,10 +3228,10 @@ printk(KERN_DEBUG "wctdm_dacs_disconnect: restoring TX for %d and RX for %d\n",wc->dacssrc[card], card); /* restore TX (source card) */ - if(wc->modtype[wc->dacssrc[card]] == MOD_TYPE_FXS){ + if (wc->modtype[wc->dacssrc[card]] == MOD_TYPE_FXS){ wctdm_setreg(wc, wc->dacssrc[card], PCM_XMIT_START_COUNT_LSB, (wc->dacssrc[card] * 8) & 0xff); wctdm_setreg(wc, wc->dacssrc[card], PCM_XMIT_START_COUNT_MSB, (wc->dacssrc[card] * 8) >> 8); - } else if(wc->modtype[wc->dacssrc[card]] == MOD_TYPE_FXO){ + } else if (wc->modtype[wc->dacssrc[card]] == MOD_TYPE_FXO){ wctdm_setreg(wc, card, 34, (card * 8) & 0xff); wctdm_setreg(wc, card, 35, (card * 8) >> 8); } else { @@ -3239,10 +3239,10 @@ } /* restore RX (this card) */ - if(wc->modtype[card] == MOD_TYPE_FXS){ + if (wc->modtype[card] == MOD_TYPE_FXS){ wctdm_setreg(wc, card, PCM_RCV_START_COUNT_LSB, (card * 8) & 0xff); wctdm_setreg(wc, card, PCM_RCV_START_COUNT_MSB, (card * 8) >> 8); - } else if(wc->modtype[card] == MOD_TYPE_FXO){ + } else if (wc->modtype[card] == MOD_TYPE_FXO){ wctdm_setreg(wc, card, 36, (card * 8) & 0xff); wctdm_setreg(wc, card, 37, (card * 8) >> 8); } else { @@ -3257,12 +3257,12 @@ { struct wctdm *wc; - if(!nativebridge) + if (!nativebridge) return 0; /* should this return -1 since unsuccessful? */ wc = dst->pvt; - if(src) { + if (src) { wctdm_dacs_connect(wc, src->chanpos - 1, dst->chanpos - 1); if (debug) printk(KERN_DEBUG "dacs connecct: %d -> %d!\n\n", src->chanpos, dst->chanpos); @@ -3599,7 +3599,7 @@ } printk(KERN_INFO "Port %d: Installed -- AUTO FXS/DPO\n", x + 1); } else { - if(ret!=-2) { + if (ret!=-2) { sane=1; /* Init with Manual Calibration */ if (!wctdm_init_proslic(wc, x, 0, 1, sane)) { Index: drivers/dahdi/wcte11xp.c =================================================================== --- drivers/dahdi/wcte11xp.c (revision 7493) +++ drivers/dahdi/wcte11xp.c (working copy) @@ -418,7 +418,7 @@ struct t4_regs regs; int x; struct t1 *wc; - switch(cmd) { + switch (cmd) { case WCT4_GET_REGS: wc = chan->pvt; for (x=0;xpvt; if (wc->spantype == TYPE_E1) { - switch(cmd) { + switch (cmd) { case DAHDI_MAINT_NONE: printk(KERN_INFO "XXX Turn off local and remote loops E1 XXX\n"); break; @@ -471,7 +471,7 @@ break; } } else { - switch(cmd) { + switch (cmd) { case DAHDI_MAINT_NONE: printk(KERN_INFO "XXX Turn off local and remote loops T1 XXX\n"); break; @@ -505,7 +505,7 @@ struct t1 *wc = chan->pvt; unsigned long flags; - if(debug > 1) printk(KERN_DEBUG "Setting bits to %d on channel %s\n", bits, chan->name); + if (debug > 1) printk(KERN_DEBUG "Setting bits to %d on channel %s\n", bits, chan->name); spin_lock_irqsave(&wc->lock, flags); if (wc->spantype == TYPE_E1) { /* do it E1 way */ if (chan->chanpos == 16) { @@ -755,7 +755,7 @@ __t1_framer_out(wc, 0x24, 0x80); /* J1 overide */ /* Generate pulse mask for T1 */ - switch(mytxlevel) { + switch (mytxlevel) { case 3: __t1_framer_out(wc, 0x26, 0x07); /* XPM0 */ __t1_framer_out(wc, 0x27, 0x01); /* XPM1 */ @@ -886,7 +886,7 @@ int i,alreadyrunning = span->flags & DAHDI_FLAG_RUNNING; /* initialize the start value for the entire chunk of last ec buffer */ - for(i = 0; i < span->channels; i++) + for (i = 0; i < span->channels; i++) { memset(wc->ec_chunk1[i], DAHDI_LIN2X(0,span->chans[i]),DAHDI_CHUNKSIZE); @@ -1354,7 +1354,7 @@ /* Do some things that we don't have to do very often */ x = wc->intcount & 15 /* 63 */; - switch(x) { + switch (x) { case 0: case 1: break; Index: drivers/dahdi/wcte12xp/base.c =================================================================== --- drivers/dahdi/wcte12xp/base.c (revision 7493) +++ drivers/dahdi/wcte12xp/base.c (working copy) @@ -1625,7 +1625,7 @@ cmd_dequeue(wc, writechunk, x, y); } #ifdef VPM_SUPPORT - if(likely(wc->vpmadt032)) { + if (likely(wc->vpmadt032)) { spin_lock(&wc->reglock); cmd_dequeue_vpmadt032(wc, writechunk, x); spin_unlock(&wc->reglock); @@ -1848,7 +1848,7 @@ return; #ifdef VPM_SUPPORT - if(vpm) { + if (vpm) { wc->vpmadt032 = NULL; clear_bit(VPM150M_DTMFDETECT, &vpm->control); clear_bit(VPM150M_ACTIVE, &vpm->control); @@ -1864,7 +1864,7 @@ wc->vb = NULL; #ifdef VPM_SUPPORT - if(vpm) { + if (vpm) { spin_lock_irqsave(&wc->reglock, flags); spin_unlock_irqrestore(&wc->reglock, flags); vpmadt032_free(vpm); Index: drivers/dahdi/xpp/card_bri.c =================================================================== --- drivers/dahdi/xpp/card_bri.c (revision 7493) +++ drivers/dahdi/xpp/card_bri.c (working copy) @@ -79,7 +79,7 @@ _E(NT_DEACTIVTING), }; #undef _E - if(is_nt) { + if (is_nt) { if ((state < ST_RESET) || (state > ST_NT_DEACTIVTING)) p = "NT ???"; else @@ -253,7 +253,7 @@ int n = 0; debug_buf[0] = '\0'; - for(i = 0; i < len && n < DEBUG_BUF_SIZE; i++) + for (i = 0; i < len && n < DEBUG_BUF_SIZE; i++) n += snprintf(&debug_buf[n], DEBUG_BUF_SIZE - n, "%02X ", buf[i]); XPD_NOTICE(xpd, "%s[0..%zd]: %s%s\n", msg, len-1, debug_buf, (n >= DEBUG_BUF_SIZE)?"...":""); @@ -269,19 +269,19 @@ priv = xpd->priv; BUG_ON(!priv); - if(transmit) { + if (transmit) { direction = "TX"; frame_begin = priv->txframe_begin; } else { direction = "RX"; frame_begin = 1; } - if(frame_begin) { /* Packet start */ - if(!IS_SET(buf[0], 7)) + if (frame_begin) { /* Packet start */ + if (!IS_SET(buf[0], 7)) ftype = 'I'; /* Information */ - else if(IS_SET(buf[0], 7) && !IS_SET(buf[0], 6)) + else if (IS_SET(buf[0], 7) && !IS_SET(buf[0], 6)) ftype = 'S'; /* Supervisory */ - else if(IS_SET(buf[0], 7) && IS_SET(buf[0], 6)) + else if (IS_SET(buf[0], 7) && IS_SET(buf[0], 6)) ftype = 'U'; /* Unnumbered */ else XPD_NOTICE(xpd, "Unknown frame type 0x%X\n", buf[0]); @@ -295,7 +295,7 @@ static void set_bri_timer(xpd_t *xpd, const char *name, int *bri_timer, int value) { - if(value == HFC_TIMER_OFF) + if (value == HFC_TIMER_OFF) XPD_DBG(SIGNAL, xpd, "Timer %s DISABLE\n", name); else XPD_DBG(SIGNAL, xpd, "Timer %s: set to %d\n", name, value); @@ -309,9 +309,9 @@ BUG_ON(!xpd); priv = xpd->priv; BUG_ON(!priv); - if(priv->dchan_alive == up) + if (priv->dchan_alive == up) return; - if(up) { + if (up) { XPD_DBG(SIGNAL, xpd, "STATE CHANGE: D-Channel RUNNING\n"); priv->dchan_alive = 1; } else { @@ -329,11 +329,11 @@ BUG_ON(!xpd); priv = xpd->priv; BUG_ON(!priv); - if(priv->layer1_up == up) + if (priv->layer1_up == up) return; priv->layer1_up = up; XPD_DBG(SIGNAL, xpd, "STATE CHANGE: Layer1 %s\n", (up)?"UP":"DOWN"); - if(!up) + if (!up) dchan_state(xpd, 0); } @@ -349,8 +349,8 @@ curr_state = priv->state_register.bits.v_su_sta; xbus = xpd->xbus; XPD_DBG(SIGNAL, xpd, "%s\n", (on)?"ON":"OFF"); - if(on) { - if(curr_state == ST_TE_DEACTIVATED) { + if (on) { + if (curr_state == ST_TE_DEACTIVATED) { XPD_DBG(SIGNAL, xpd, "HFC_L1_ACTIVATE_TE\n"); set_bit(HFC_L1_ACTIVATING, &priv->l1_flags); write_state_register(xpd, STA_ACTIVATE); @@ -394,8 +394,8 @@ curr_state = priv->state_register.bits.v_su_sta; xbus = xpd->xbus; XPD_DBG(SIGNAL, xpd, "%s\n", (on)?"ON":"OFF"); - if(on) { - switch(curr_state) { + if (on) { + switch (curr_state) { case ST_RESET: /* F/G 0 */ case ST_NT_DEACTIVATED: /* G1 */ case ST_NT_DEACTIVTING: /* G4 */ @@ -412,7 +412,7 @@ break; } } else { - switch(curr_state) { + switch (curr_state) { case ST_RESET: /* F/G 0 */ case ST_NT_DEACTIVATED: /* G1 */ case ST_NT_DEACTIVTING: /* G4 */ @@ -443,7 +443,7 @@ priv = xpd->priv; BUG_ON(!priv); #ifdef CONFIG_DAHDI_BRI_DCHANS - if(debug & DBG_COMMANDS) + if (debug & DBG_COMMANDS) dump_hex_buf(xpd, "D-Chan(abort) RX: dchan_rbuf", priv->dchan_rbuf, priv->dchan_r_idx); priv->dchan_r_idx = 0; @@ -460,7 +460,7 @@ priv = xpd->priv; BUG_ON(!priv); #ifdef CONFIG_DAHDI_BRI_DCHANS - if(priv->dchan_r_idx < 4) { + if (priv->dchan_r_idx < 4) { XPD_NOTICE(xpd, "D-Chan RX short frame (dchan_r_idx=%d)\n", priv->dchan_r_idx); dump_hex_buf(xpd, "D-Chan RX: current packet", buf, len); @@ -468,17 +468,17 @@ return -EPROTO; } #else - if(len <= 0) { + if (len <= 0) { XPD_NOTICE(xpd, "D-Chan RX DROP: short frame (len=%d)\n", len); bri_hdlc_abort(xpd, dchan, DAHDI_EVENT_ABORT); return -EPROTO; } #endif status = buf[len-1]; - if(status) { + if (status) { int event = DAHDI_EVENT_ABORT; - if(status == 0xFF) { + if (status == 0xFF) { XPD_NOTICE(xpd, "D-Chan RX DROP: ABORT: %d\n", status); } else { XPD_NOTICE(xpd, "D-Chan RX DROP: BADFCS: %d\n", status); @@ -503,7 +503,7 @@ BUG_ON(!priv); dchan_buf = dchan->readchunk; idx = priv->dchan_r_idx; - if(idx + len >= DCHAN_BUFSIZE) { + if (idx + len >= DCHAN_BUFSIZE) { XPD_ERR(xpd, "D-Chan RX overflow: %d\n", idx); dump_hex_buf(xpd, " current packet", buf, len); dump_hex_buf(xpd, " dchan_buf", dchan_buf, idx); @@ -550,9 +550,9 @@ src = REG_XDATA(regcmd); len = regcmd->bytes; eoframe = regcmd->eoframe; - if(len <= 0) + if (len <= 0) return 0; - if(!SPAN_REGISTERED(xpd)) /* Nowhere to copy data */ + if (!SPAN_REGISTERED(xpd)) /* Nowhere to copy data */ return 0; BUG_ON(!xpd); priv = xpd->priv; @@ -562,10 +562,10 @@ xbus_log(xbus, xpd, 0, regcmd, sizeof(reg_cmd_t)); /* 0 = RX */ #endif dchan = XPD_CHAN(xpd, 2); - if(!IS_OFFHOOK(xpd, 2)) { /* D-chan is used? */ + if (!IS_OFFHOOK(xpd, 2)) { /* D-chan is used? */ static int rate_limit; - if((rate_limit++ % 1000) == 0) + if ((rate_limit++ % 1000) == 0) XPD_DBG(SIGNAL, xpd, "D-Chan unused\n"); dchan->bytes2receive = 0; dchan->bytes2transmit = 0; @@ -573,12 +573,12 @@ } dchan_buf = dchan->readchunk; idx = priv->dchan_r_idx; - if(idx + len >= DCHAN_BUFSIZE) { + if (idx + len >= DCHAN_BUFSIZE) { XPD_ERR(xpd, "D-Chan RX overflow: %d\n", idx); dump_hex_buf(xpd, " current packet", src, len); dump_hex_buf(xpd, " dchan_buf", dchan_buf, idx); ret = -ENOSPC; - if(eoframe) + if (eoframe) goto drop; goto out; } @@ -586,23 +586,23 @@ idx += len; priv->dchan_r_idx = idx; memcpy(dst, src, len); - if(!eoframe) + if (!eoframe) goto out; - if(idx < 4) { + if (idx < 4) { XPD_NOTICE(xpd, "D-Chan RX short frame (idx=%d)\n", idx); dump_hex_buf(xpd, "D-Chan RX: current packet", src, len); dump_hex_buf(xpd, "D-Chan RX: chan_buf", dchan_buf, idx); ret = -EPROTO; goto drop; } - if((ret = bri_check_stat(xpd, dchan, dchan_buf, idx)) < 0) + if ((ret = bri_check_stat(xpd, dchan, dchan_buf, idx)) < 0) goto drop; - if(debug) + if (debug) dump_dchan_packet(xpd, 0, dchan_buf, idx /* - 3 */); /* Print checksum? */ /* * Tell Dahdi that we received idx-1 bytes. They include the data and a 2-byte checksum. * The last byte (that we don't pass on) is 0 if the checksum is correct. If it were wrong, - * we would drop the packet in the "if(dchan_buf[idx-1])" above. + * we would drop the packet in the "if (dchan_buf[idx-1])" above. */ dchan->bytes2receive = idx - 1; dchan->eofrx = 1; @@ -627,9 +627,9 @@ src = REG_XDATA(regcmd); len = regcmd->bytes; eoframe = regcmd->eoframe; - if(len <= 0) + if (len <= 0) return 0; - if(!SPAN_REGISTERED(xpd)) /* Nowhere to copy data */ + if (!SPAN_REGISTERED(xpd)) /* Nowhere to copy data */ return 0; BUG_ON(!xpd); priv = xpd->priv; @@ -639,10 +639,10 @@ xbus_log(xbus, xpd, 0, regcmd, sizeof(reg_cmd_t)); /* 0 = RX */ #endif dchan = XPD_CHAN(xpd, 2); - if(!IS_OFFHOOK(xpd, 2)) { /* D-chan is used? */ + if (!IS_OFFHOOK(xpd, 2)) { /* D-chan is used? */ static int rate_limit; - if((rate_limit++ % 1000) == 0) + if ((rate_limit++ % 1000) == 0) XPD_DBG(SIGNAL, xpd, "D-Chan unused\n"); #ifdef CONFIG_DAHDI_BRI_DCHANS dchan->bytes2receive = 0; @@ -652,16 +652,16 @@ } XPD_DBG(GENERAL, xpd, "D-Chan RX: eoframe=%d len=%d\n", eoframe, len); ret = bri_hdlc_putbuf(xpd, dchan, src, (eoframe) ? len - 1 : len); - if(ret < 0) + if (ret < 0) goto out; - if(!eoframe) + if (!eoframe) goto out; - if((ret = bri_check_stat(xpd, dchan, src, len)) < 0) + if ((ret = bri_check_stat(xpd, dchan, src, len)) < 0) goto out; /* * Tell Dahdi that we received len-1 bytes. They include the data and a 2-byte checksum. * The last byte (that we don't pass on) is 0 if the checksum is correct. If it were wrong, - * we would drop the packet in the "if(src[len-1])" above. + * we would drop the packet in the "if (src[len-1])" above. */ bri_hdlc_finish(xpd, dchan); priv->dchan_rx_counter++; @@ -698,7 +698,7 @@ #ifdef CONFIG_DAHDI_BRI_DCHANS len = dchan->bytes2transmit; /* dchan's hdlc package len */ - if(len > *size) + if (len > *size) len = *size; /* Silent truncation */ eoframe = dchan->eoftx; /* dchan's end of frame */ dchan->bytes2transmit = 0; @@ -723,42 +723,42 @@ priv = xpd->priv; BUG_ON(!priv); #ifndef CONFIG_DAHDI_BRI_DCHANS - if(atomic_read(&priv->hdlc_pending) == 0) + if (atomic_read(&priv->hdlc_pending) == 0) return 0; #endif - if(!SPAN_REGISTERED(xpd) || !(xpd->span.flags & DAHDI_FLAG_RUNNING)) + if (!SPAN_REGISTERED(xpd) || !(xpd->span.flags & DAHDI_FLAG_RUNNING)) return 0; dchan = XPD_CHAN(xpd, 2); len = ARRAY_SIZE(priv->dchan_tbuf); - if(len > MULTIBYTE_MAX_LEN) + if (len > MULTIBYTE_MAX_LEN) len = MULTIBYTE_MAX_LEN; eoframe = bri_hdlc_getbuf(dchan, priv->dchan_tbuf, &len); - if(len <= 0) + if (len <= 0) return 0; /* Nothing to transmit on D channel */ - if(len > MULTIBYTE_MAX_LEN) { + if (len > MULTIBYTE_MAX_LEN) { XPD_ERR(xpd, "%s: len=%d. need to split. Unimplemented.\n", __FUNCTION__, len); dump_hex_buf(xpd, "D-Chan TX:", priv->dchan_tbuf, len); return -EINVAL; } - if(!test_bit(HFC_L1_ACTIVATED, &priv->l1_flags) && !test_bit(HFC_L1_ACTIVATING, &priv->l1_flags)) { + if (!test_bit(HFC_L1_ACTIVATED, &priv->l1_flags) && !test_bit(HFC_L1_ACTIVATING, &priv->l1_flags)) { XPD_DBG(SIGNAL, xpd, "Want to transmit: Kick D-Channel transmiter\n"); - if(xpd->direction == TO_PSTN) + if (xpd->direction == TO_PSTN) te_activation(xpd, 1); else nt_activation(xpd, 1); } - if(debug) + if (debug) dump_dchan_packet(xpd, 1, priv->dchan_tbuf, len); - if(eoframe) + if (eoframe) priv->txframe_begin = 1; else priv->txframe_begin = 0; XPD_DBG(COMMANDS, xpd, "eoframe=%d len=%d\n", eoframe, len); ret = send_multibyte_request(xpd->xbus, xpd->addr.unit, xpd->addr.subunit, eoframe, priv->dchan_tbuf, len); - if(ret < 0) + if (ret < 0) XPD_NOTICE(xpd, "%s: failed sending xframe\n", __FUNCTION__); - if(eoframe) { + if (eoframe) { #ifndef CONFIG_DAHDI_BRI_DCHANS atomic_dec(&priv->hdlc_pending); #endif @@ -778,7 +778,7 @@ priv = xpd->priv; XPD_DBG(PROC, xpd, "\n"); #ifdef CONFIG_PROC_FS - if(priv->bri_info) { + if (priv->bri_info) { XPD_DBG(PROC, xpd, "Removing '%s'\n", PROC_BRI_INFO_FNAME); remove_proc_entry(PROC_BRI_INFO_FNAME, xpd->proc_xpd_dir); } @@ -795,7 +795,7 @@ #ifdef CONFIG_PROC_FS XPD_DBG(PROC, xpd, "Creating '%s'\n", PROC_BRI_INFO_FNAME); priv->bri_info = create_proc_read_entry(PROC_BRI_INFO_FNAME, 0444, xpd->proc_xpd_dir, proc_bri_info_read, xpd); - if(!priv->bri_info) { + if (!priv->bri_info) { XPD_ERR(xpd, "Failed to create proc file '%s'\n", PROC_BRI_INFO_FNAME); goto err; } @@ -813,17 +813,17 @@ xpd_t *xpd = NULL; int channels = min(3, CHANNELS_PERXPD); - if(subunit_ports != 1) { + if (subunit_ports != 1) { XBUS_ERR(xbus, "Bad subunit_ports=%d\n", subunit_ports); return NULL; } XBUS_DBG(GENERAL, xbus, "\n"); xpd = xpd_alloc(xbus, unit, subunit, subtype, subunits, sizeof(struct BRI_priv_data), proto_table, channels); - if(!xpd) + if (!xpd) return NULL; xpd->direction = (to_phone) ? TO_PHONE : TO_PSTN; xpd->type_name = (to_phone) ? "BRI_NT" : "BRI_TE"; - if(bri_proc_create(xbus, xpd) < 0) + if (bri_proc_create(xbus, xpd) < 0) goto err; return xpd; err: @@ -868,7 +868,7 @@ priv = xpd->priv; BUG_ON(!xbus); XPD_DBG(GENERAL, xpd, "%s\n", (on)?"on":"off"); - if(!on) { + if (!on) { /* Nothing to do yet */ return 0; } @@ -886,7 +886,7 @@ xpd->addr.unit, xpd->addr.subunit, i); cur_chan->chanpos = i + 1; cur_chan->pvt = xpd; - if(i == 2) { /* D-CHAN */ + if (i == 2) { /* D-CHAN */ cur_chan->sigcap = BRI_DCHAN_SIGCAP; clear_bit(DAHDI_FLAGBIT_HDLC, &cur_chan->flags); priv->txframe_begin = 1; @@ -952,7 +952,7 @@ int mod; BUG_ON(!xpd); - if(IS_NT(xpd)) { + if (IS_NT(xpd)) { which_led = RED_LED; other_led = GREEN_LED; } else { @@ -962,10 +962,10 @@ priv = xpd->priv; BUG_ON(!priv); timer_count = xpd->timer_count; - if(xpd->blink_mode) { - if((timer_count % DEFAULT_LED_PERIOD) == 0) { + if (xpd->blink_mode) { + if ((timer_count % DEFAULT_LED_PERIOD) == 0) { // led state is toggled - if(priv->ledstate[which_led] == BRI_LED_OFF) { + if (priv->ledstate[which_led] == BRI_LED_OFF) { DO_LED(xpd, which_led, BRI_LED_ON); DO_LED(xpd, other_led, BRI_LED_ON); } else { @@ -975,11 +975,11 @@ } return; } - if(priv->ledstate[other_led] != BRI_LED_OFF) + if (priv->ledstate[other_led] != BRI_LED_OFF) DO_LED(xpd, other_led, BRI_LED_OFF); - if(priv->dchan_alive) { + if (priv->dchan_alive) { mod = timer_count % 1000; - switch(mod) { + switch (mod) { case 0: DO_LED(xpd, which_led, BRI_LED_ON); break; @@ -987,9 +987,9 @@ DO_LED(xpd, which_led, BRI_LED_OFF); break; } - } else if(priv->layer1_up) { + } else if (priv->layer1_up) { mod = timer_count % 1000; - switch(mod) { + switch (mod) { case 0: case 100: DO_LED(xpd, which_led, BRI_LED_ON); @@ -1000,7 +1000,7 @@ break; } } else { - if(priv->ledstate[which_led] != BRI_LED_ON) + if (priv->ledstate[which_led] != BRI_LED_ON) DO_LED(xpd, which_led, BRI_LED_ON); } } @@ -1012,12 +1012,12 @@ BUG_ON(!xpd); priv = xpd->priv; BUG_ON(!priv); - if(IS_NT(xpd)) { + if (IS_NT(xpd)) { if (priv->t1 > HFC_TIMER_OFF) { if (--priv->t1 == 0) { set_bri_timer(xpd, "T1", &priv->t1, HFC_TIMER_OFF); - if(!nt_keepalive) { - if(priv->state_register.bits.v_su_sta == ST_NT_ACTIVATING) { /* G2 */ + if (!nt_keepalive) { + if (priv->state_register.bits.v_su_sta == ST_NT_ACTIVATING) { /* G2 */ XPD_DBG(SIGNAL, xpd, "T1 Expired. Deactivate NT\n"); clear_bit(HFC_L1_ACTIVATING, &priv->l1_flags); nt_activation(xpd, 0); /* Deactivate NT */ @@ -1051,9 +1051,9 @@ BUG_ON(!xpd); priv = xpd->priv; BUG_ON(!priv); - if(!priv->initialized || !xbus->self_ticking) + if (!priv->initialized || !xbus->self_ticking) return 0; - if(poll_interval != 0 && (priv->tick_counter % poll_interval) == 0) { + if (poll_interval != 0 && (priv->tick_counter % poll_interval) == 0) { // XPD_DBG(GENERAL, xpd, "%d\n", priv->tick_counter); priv->poll_counter++; xpp_register_request(xbus, xpd, @@ -1068,7 +1068,7 @@ 0 /* should_reply */ ); - if(IS_NT(xpd) && nt_keepalive && + if (IS_NT(xpd) && nt_keepalive && !test_bit(HFC_L1_ACTIVATED, &priv->l1_flags) && !test_bit(HFC_L1_ACTIVATING, &priv->l1_flags)) { XPD_DBG(SIGNAL, xpd, "Kick NT D-Channel\n"); @@ -1079,18 +1079,18 @@ priv->dchan_notx_ticks++; priv->dchan_norx_ticks++; priv->dchan_alive_ticks++; - if(priv->dchan_alive && (priv->dchan_notx_ticks > DCHAN_LOST || priv->dchan_norx_ticks > DCHAN_LOST)) { + if (priv->dchan_alive && (priv->dchan_notx_ticks > DCHAN_LOST || priv->dchan_norx_ticks > DCHAN_LOST)) { /* * No tx_dchan() or rx_dchan() for many ticks * This D-Channel is probabelly dead. */ dchan_state(xpd, 0); - } else if(priv->dchan_rx_counter > 1 && priv->dchan_tx_counter > 1) { - if(!priv->dchan_alive) + } else if (priv->dchan_rx_counter > 1 && priv->dchan_tx_counter > 1) { + if (!priv->dchan_alive) dchan_state(xpd, 1); } /* Detect Layer1 disconnect */ - if(priv->reg30_good && priv->reg30_ticks > poll_interval * REG30_LOST) { + if (priv->reg30_good && priv->reg30_ticks > poll_interval * REG30_LOST) { /* No reply for 1/2 a second */ XPD_ERR(xpd, "Lost state tracking for %d ticks\n", priv->reg30_ticks); priv->reg30_good = 0; @@ -1107,7 +1107,7 @@ static int BRI_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long arg) { BUG_ON(!xpd); - if(!XBUS_IS(xpd->xbus, READY)) + if (!XBUS_IS(xpd->xbus, READY)) return -ENODEV; switch (cmd) { case DAHDI_TONEDETECT: @@ -1130,7 +1130,7 @@ BUG_ON(!xpd); priv = xpd->priv; - if(pos == 2) { + if (pos == 2) { LINE_DBG(SIGNAL, xpd, pos, "OFFHOOK the whole span\n"); BIT_SET(xpd->offhook_state, 0); BIT_SET(xpd->offhook_state, 1); @@ -1152,7 +1152,7 @@ chan->bytes2transmit = 0; chan->eoftx = 0; #endif - if(pos == 2) { + if (pos == 2) { LINE_DBG(SIGNAL, xpd, pos, "ONHOOK the whole span\n"); BIT_CLR(xpd->offhook_state, 0); BIT_CLR(xpd->offhook_state, 1); @@ -1230,14 +1230,14 @@ BUG_ON(!xpd); priv = xpd->priv; BUG_ON(!priv); - if(!XBUS_IS(xpd->xbus, READY)) { + if (!XBUS_IS(xpd->xbus, READY)) { XPD_DBG(GENERAL, xpd, "Startup called by dahdi. No Hardware. Ignored\n"); return -ENODEV; } XPD_DBG(GENERAL, xpd, "STARTUP\n"); // Turn on all channels CALL_XMETHOD(XPD_STATE, xpd->xbus, xpd, 1); - if(SPAN_REGISTERED(xpd)) { + if (SPAN_REGISTERED(xpd)) { dchan = XPD_CHAN(xpd, 2); span->flags |= DAHDI_FLAG_RUNNING; /* @@ -1265,7 +1265,7 @@ BUG_ON(!xpd); priv = xpd->priv; BUG_ON(!priv); - if(!XBUS_IS(xpd->xbus, READY)) { + if (!XBUS_IS(xpd->xbus, READY)) { XPD_DBG(GENERAL, xpd, "Shutdown called by dahdi. No Hardware. Ignored\n"); return -ENODEV; } @@ -1286,7 +1286,7 @@ BUG_ON(!xpd); main_xpd = xpd_byaddr(xbus, xpd->addr.unit, 0); - if(!main_xpd) { + if (!main_xpd) { XPD_DBG(DEVICES, xpd, "Unit 0 is already gone. Ignore request\n"); return; } @@ -1297,19 +1297,19 @@ spin_lock_irqsave(&main_xpd->lock_recompute_pcm, flags); line_count = 0; pcm_mask = 0; - for(i = 0; i < MAX_SUBUNIT; i++) { + for (i = 0; i < MAX_SUBUNIT; i++) { xpd_t *sub_xpd = xpd_byaddr(xbus, main_xpd->addr.unit, i); - if(sub_xpd) { + if (sub_xpd) { xpp_line_t lines = sub_xpd->offhook_state & ~sub_xpd->digital_signalling; - if(lines) { + if (lines) { pcm_mask |= PCM_SHIFT(lines, i); line_count += 2; } /* subunits have fake pcm_len and wanted_pcm_mask */ - if(i > 0) { + if (i > 0) { update_wanted_pcm_mask(sub_xpd, lines, 0); } } @@ -1318,7 +1318,7 @@ * FIXME: Workaround a bug in sync code of the Astribank. * Send dummy PCM for sync. */ - if(main_xpd->addr.unit == 0 && line_count == 0) { + if (main_xpd->addr.unit == 0 && line_count == 0) { pcm_mask = BIT(0); line_count = 1; } @@ -1346,23 +1346,23 @@ BUG_ON(!xpd); BUG_ON(!pack); pcm = RPACKET_FIELD(pack, GLOBAL, PCM_WRITE, pcm); - for(subunit = 0; subunit < MAX_SUBUNIT; subunit++) { + for (subunit = 0; subunit < MAX_SUBUNIT; subunit++) { xpd_t *tmp_xpd; tmp_xpd = xpd_byaddr(xbus, xpd->addr.unit, subunit); - if(!tmp_xpd || !tmp_xpd->card_present) + if (!tmp_xpd || !tmp_xpd->card_present) continue; spin_lock_irqsave(&tmp_xpd->lock, flags); wanted_lines = tmp_xpd->wanted_pcm_mask; for_each_line(tmp_xpd, i) { struct dahdi_chan *chan = XPD_CHAN(tmp_xpd, i); - if(IS_SET(wanted_lines, i)) { - if(SPAN_REGISTERED(tmp_xpd)) { + if (IS_SET(wanted_lines, i)) { + if (SPAN_REGISTERED(tmp_xpd)) { #ifdef DEBUG_PCMTX int channo = chan->channo; - if(pcmtx >= 0 && pcmtx_chan == channo) + if (pcmtx >= 0 && pcmtx_chan == channo) memset((u_char *)pcm, pcmtx, DAHDI_CHUNKSIZE); else #endif @@ -1390,26 +1390,26 @@ /* * Subunit 0 handle all other subunits */ - if(xpd->addr.subunit != 0) + if (xpd->addr.subunit != 0) return; - if(!SPAN_REGISTERED(xpd)) + if (!SPAN_REGISTERED(xpd)) return; pcm = RPACKET_FIELD(pack, GLOBAL, PCM_READ, pcm); pcm_mask = RPACKET_FIELD(pack, GLOBAL, PCM_WRITE, lines); - for(subunit = 0; subunit < MAX_SUBUNIT; subunit++, pcm_mask >>= SUBUNIT_PCM_SHIFT) { + for (subunit = 0; subunit < MAX_SUBUNIT; subunit++, pcm_mask >>= SUBUNIT_PCM_SHIFT) { xpd_t *tmp_xpd; - if(!pcm_mask) + if (!pcm_mask) break; /* optimize */ tmp_xpd = xpd_byaddr(xbus, xpd->addr.unit, subunit); - if(!tmp_xpd || !tmp_xpd->card_present || !SPAN_REGISTERED(tmp_xpd)) + if (!tmp_xpd || !tmp_xpd->card_present || !SPAN_REGISTERED(tmp_xpd)) continue; spin_lock_irqsave(&tmp_xpd->lock, flags); for (i = 0; i < 2; i++) { xpp_line_t tmp_mask = pcm_mask & (BIT(0) | BIT(1)); volatile u_char *r; - if(IS_SET(tmp_mask, i)) { + if (IS_SET(tmp_mask, i)) { r = XPD_CHAN(tmp_xpd, i)->readchunk; // memset((u_char *)r, 0x5A, DAHDI_CHUNKSIZE); // DEBUG memcpy((u_char *)r, pcm, DAHDI_CHUNKSIZE); @@ -1430,14 +1430,14 @@ BUG_ON(!xpd); priv = xpd->priv; XPD_DBG(GENERAL, xpd, "%s\n", (on)?"ON":"OFF"); - if(on) { - if(!test_bit(HFC_L1_ACTIVATED, &priv->l1_flags)) { - if(xpd->direction == TO_PSTN) + if (on) { + if (!test_bit(HFC_L1_ACTIVATED, &priv->l1_flags)) { + if (xpd->direction == TO_PSTN) te_activation(xpd, 1); else nt_activation(xpd, 1); } - } else if(IS_NT(xpd)) + } else if (IS_NT(xpd)) nt_activation(xpd, 0); return 0; } @@ -1496,12 +1496,12 @@ priv = xpd->priv; BUG_ON(!priv); xbus = xpd->xbus; - if(!priv->initialized) { + if (!priv->initialized) { XPD_ERR(xpd, "%s called on uninitialized AB\n", __FUNCTION__); return; } new_state.reg = reg_x30; - if(new_state.bits.v_su_t2_exp) { + if (new_state.bits.v_su_t2_exp) { XPD_NOTICE(xpd, "T2 Expired\n"); } priv->reg30_ticks = 0; @@ -1514,7 +1514,7 @@ new_state.bits.v_su_info0, IS_NT(xpd)?"G":"F", new_state.bits.v_su_sta); - if(!IS_NT(xpd)) { + if (!IS_NT(xpd)) { switch (new_state.bits.v_su_sta) { case ST_TE_DEACTIVATED: /* F3 */ XPD_DBG(SIGNAL, xpd, "State ST_TE_DEACTIVATED (F3)\n"); @@ -1561,7 +1561,7 @@ case ST_NT_ACTIVATING: /* G2 */ XPD_DBG(SIGNAL, xpd, "State ST_NT_ACTIVATING (G2)\n"); layer1_state(xpd, 0); - if(!test_bit(HFC_L1_ACTIVATED, &priv->l1_flags)) + if (!test_bit(HFC_L1_ACTIVATED, &priv->l1_flags)) nt_activation(xpd, 1); break; case ST_NT_ACTIVATED: /* G3 */ @@ -1598,17 +1598,17 @@ addr.unit = orig_xpd->addr.unit; addr.subunit = info->portnum; xpd = xpd_byaddr(xbus, addr.unit, addr.subunit); - if(!xpd) { + if (!xpd) { static int rate_limit; - if((rate_limit++ % 1003) < 5) + if ((rate_limit++ % 1003) < 5) notify_bad_xpd(__FUNCTION__, xbus, addr , orig_xpd->xpdname); return -EPROTO; } spin_lock_irqsave(&xpd->lock, flags); priv = xpd->priv; BUG_ON(!priv); - if(REG_FIELD(info, do_subreg)) { + if (REG_FIELD(info, do_subreg)) { XPD_DBG(REGS, xpd, "RI %02X %02X %02X\n", REG_FIELD(info, regnum), REG_FIELD(info, subreg), REG_FIELD(info, data_low)); } else { @@ -1619,23 +1619,23 @@ XPD_DBG(REGS, xpd, "Got SU_RD_STA=%02X\n", REG_FIELD(info, data_low)); } - if(info->is_multibyte) { + if (info->is_multibyte) { XPD_DBG(REGS, xpd, "Got Multibyte: %d bytes, eoframe: %d\n", info->bytes, info->eoframe); ret = rx_dchan(xpd, info); if (ret < 0) { priv->dchan_rx_drops++; - if(atomic_read(&xpd->open_counter) > 0) + if (atomic_read(&xpd->open_counter) > 0) XPD_NOTICE(xpd, "Multibyte Drop: errno=%d\n", ret); } goto end; } - if(REG_FIELD(info, regnum) == A_SU_RD_STA) { + if (REG_FIELD(info, regnum) == A_SU_RD_STA) { su_new_state(xpd, REG_FIELD(info, data_low)); } /* Update /proc info only if reply relate to the last slic read request */ - if( + if ( REG_FIELD(&xpd->requested_reply, regnum) == REG_FIELD(info, regnum) && REG_FIELD(&xpd->requested_reply, do_subreg) == REG_FIELD(info, do_subreg) && REG_FIELD(&xpd->requested_reply, subreg) == REG_FIELD(info, subreg)) { @@ -1699,13 +1699,13 @@ struct BRI_priv_data *priv; DBG(PROC, "\n"); - if(!xpd) + if (!xpd) return -ENODEV; spin_lock_irqsave(&xpd->lock, flags); priv = xpd->priv; BUG_ON(!priv); len += sprintf(page + len, "%05d Layer 1: ", priv->poll_counter); - if(priv->reg30_good) { + if (priv->reg30_good) { len += sprintf(page + len, "%-5s ", (priv->layer1_up) ? "UP" : "DOWN"); len += sprintf(page + len, "%c%d %-15s -- fr_sync=%d t2_exp=%d info0=%d g2_g3=%d\n", IS_NT(xpd)?'G':'F', @@ -1717,7 +1717,7 @@ priv->state_register.bits.v_g2_g3); } else len += sprintf(page + len, "Unkown\n"); - if(IS_NT(xpd)) { + if (IS_NT(xpd)) { len += sprintf(page + len, "T1 Timer: %d\n", priv->t1); } else { len += sprintf(page + len, "T3 Timer: %d\n", priv->t3); @@ -1727,7 +1727,7 @@ len += sprintf(page + len, "reg30_good=%d\n", priv->reg30_good); len += sprintf(page + len, "D-Channel: TX=[%5d] RX=[%5d] BAD=[%5d] ", priv->dchan_tx_counter, priv->dchan_rx_counter, priv->dchan_rx_drops); - if(priv->dchan_alive) { + if (priv->dchan_alive) { len += sprintf(page + len, "(alive %d K-ticks)\n", priv->dchan_alive_ticks/1000); } else { @@ -1776,7 +1776,7 @@ xpd = dev_to_xpd(dev); /* Is it our device? */ - if(xpd->type != XPD_TYPE_BRI) { + if (xpd->type != XPD_TYPE_BRI) { XPD_ERR(xpd, "drop suggestion for %s (%d)\n", dev_name(dev), xpd->type); return -EINVAL; @@ -1810,10 +1810,10 @@ { int ret; - if((ret = xpd_driver_register(&bri_driver.driver)) < 0) + if ((ret = xpd_driver_register(&bri_driver.driver)) < 0) return ret; ret = driver_create_file(&bri_driver.driver, &driver_attr_dchan_hardhdlc); - if(ret < 0) + if (ret < 0) return ret; INFO("revision %s\n", XPP_VERSION); #if defined(CONFIG_DAHDI_BRI_DCHANS) Index: drivers/dahdi/xpp/card_fxo.c =================================================================== --- drivers/dahdi/xpp/card_fxo.c (revision 7493) +++ drivers/dahdi/xpp/card_fxo.c (working copy) @@ -160,8 +160,8 @@ #define LED_COUNTER(priv,pos,color) ((priv)->led_counter[color][pos]) #define IS_BLINKING(priv,pos,color) (LED_COUNTER(priv,pos,color) > 0) #define MARK_BLINK(priv,pos,color,t) ((priv)->led_counter[color][pos] = (t)) -#define MARK_OFF(priv,pos,color) do { BIT_CLR((priv)->ledcontrol[color],(pos)); MARK_BLINK((priv),(pos),(color),0); } while(0) -#define MARK_ON(priv,pos,color) do { BIT_SET((priv)->ledcontrol[color],(pos)); MARK_BLINK((priv),(pos),(color),0); } while(0) +#define MARK_OFF(priv,pos,color) do { BIT_CLR((priv)->ledcontrol[color],(pos)); MARK_BLINK((priv),(pos),(color),0); } while (0) +#define MARK_ON(priv,pos,color) do { BIT_SET((priv)->ledcontrol[color],(pos)); MARK_BLINK((priv),(pos),(color),0); } while (0) #define LED_BLINK_RING (1000/8) /* in ticks */ @@ -169,7 +169,7 @@ static const char *power2str(enum power_state pw) { - switch(pw) { + switch (pw) { case POWER_UNKNOWN: return "UNKOWN"; case POWER_OFF: return "OFF"; case POWER_ON: return "ON"; @@ -213,12 +213,12 @@ xbus = xpd->xbus; priv = xpd->priv; which = which % NUM_LEDS; - if(IS_SET(xpd->digital_outputs, chan) || IS_SET(xpd->digital_inputs, chan)) + if (IS_SET(xpd->digital_outputs, chan) || IS_SET(xpd->digital_inputs, chan)) goto out; - if(chan == PORT_BROADCAST) { + if (chan == PORT_BROADCAST) { priv->ledstate[which] = (on) ? ~0 : 0; } else { - if(on) { + if (on) { BIT_SET(priv->ledstate[which], chan); } else { BIT_CLR(priv->ledstate[which], chan); @@ -247,27 +247,27 @@ spin_lock_irqsave(&xpd->lock, flags); priv = xpd->priv; timer_count = xpd->timer_count; - for(color = 0; color < ARRAY_SIZE(colors); color++) { + for (color = 0; color < ARRAY_SIZE(colors); color++) { for_each_line(xpd, i) { - if(IS_SET(xpd->digital_outputs, i) || IS_SET(xpd->digital_inputs, i)) + if (IS_SET(xpd->digital_outputs, i) || IS_SET(xpd->digital_inputs, i)) continue; - if((xpd->blink_mode & BIT(i)) || IS_BLINKING(priv, i, color)) { // Blinking + if ((xpd->blink_mode & BIT(i)) || IS_BLINKING(priv, i, color)) { // Blinking int mod_value = LED_COUNTER(priv, i, color); - if(!mod_value) + if (!mod_value) mod_value = DEFAULT_LED_PERIOD; /* safety value */ // led state is toggled - if((timer_count % mod_value) == 0) { + if ((timer_count % mod_value) == 0) { LINE_DBG(LEDS, xpd, i, "ledstate=%s\n", (IS_SET(priv->ledstate[color], i))?"ON":"OFF"); - if(!IS_SET(priv->ledstate[color], i)) { + if (!IS_SET(priv->ledstate[color], i)) { do_led(xpd, i, color, 1); } else { do_led(xpd, i, color, 0); } } - } else if(IS_SET(priv->ledcontrol[color], i) && !IS_SET(priv->ledstate[color], i)) { + } else if (IS_SET(priv->ledcontrol[color], i) && !IS_SET(priv->ledstate[color], i)) { do_led(xpd, i, color, 1); - } else if(!IS_SET(priv->ledcontrol[color], i) && IS_SET(priv->ledstate[color], i)) { + } else if (!IS_SET(priv->ledcontrol[color], i) && IS_SET(priv->ledstate[color], i)) { do_led(xpd, i, color, 0); } } @@ -278,7 +278,7 @@ static void update_dahdi_ring(xpd_t *xpd, int pos, bool on) { BUG_ON(!xpd); - if(caller_id_style == CID_STYLE_BELL) + if (caller_id_style == CID_STYLE_BELL) oht_pcm(xpd, pos, !on); /* * We should not spinlock before calling dahdi_hooksig() as @@ -300,20 +300,20 @@ * due to voltage fluctuations. */ reset_battery_readings(xpd, pos); - if(on && !xpd->ringing[pos]) { + if (on && !xpd->ringing[pos]) { LINE_DBG(SIGNAL, xpd, pos, "START\n"); xpd->ringing[pos] = 1; priv->cidtimer[pos] = xpd->timer_count; MARK_BLINK(priv, pos, LED_GREEN, LED_BLINK_RING); - if(update_dahdi) + if (update_dahdi) update_dahdi_ring(xpd, pos, on); - } else if(!on && xpd->ringing[pos]) { + } else if (!on && xpd->ringing[pos]) { LINE_DBG(SIGNAL, xpd, pos, "STOP\n"); xpd->ringing[pos] = 0; priv->cidtimer[pos] = xpd->timer_count; - if(IS_BLINKING(priv, pos, LED_GREEN)) + if (IS_BLINKING(priv, pos, LED_GREEN)) MARK_BLINK(priv, pos, LED_GREEN, 0); - if(update_dahdi) + if (update_dahdi) update_dahdi_ring(xpd, pos, on); } } @@ -331,23 +331,23 @@ xbus = xpd->xbus; priv = xpd->priv; BUG_ON(!priv); - if(priv->battery[pos] != BATTERY_ON && to_offhook) { + if (priv->battery[pos] != BATTERY_ON && to_offhook) { LINE_NOTICE(xpd, pos, "Cannot take offhook while battery is off!\n"); return -EINVAL; } spin_lock_irqsave(&xpd->lock, flags); mark_ring(xpd, pos, 0, 0); // No more rings value = REG_DAA_CONTROL1_ONHM; /* Bit 3 is for CID */ - if(to_offhook) + if (to_offhook) value |= REG_DAA_CONTROL1_OH; LINE_DBG(SIGNAL, xpd, pos, "SETHOOK: value=0x%02X %s\n", value, (to_offhook)?"OFFHOOK":"ONHOOK"); - if(to_offhook) + if (to_offhook) MARK_ON(priv, pos, LED_GREEN); else MARK_OFF(priv, pos, LED_GREEN); ret = DAA_DIRECT_REQUEST(xbus, xpd, pos, DAA_WRITE, REG_DAA_CONTROL1, value); mark_offhook(xpd, pos, to_offhook); - if(caller_id_style != CID_STYLE_ETSI_DTMF) + if (caller_id_style != CID_STYLE_ETSI_DTMF) oht_pcm(xpd, pos, 0); #ifdef WITH_METERING priv->metering_count[pos] = 0; @@ -355,7 +355,7 @@ DAA_DIRECT_REQUEST(xbus, xpd, pos, DAA_WRITE, DAA_REG_METERING, 0x2D); #endif reset_battery_readings(xpd, pos); /* unstable during hook changes */ - if(to_offhook) { + if (to_offhook) { priv->power_denial_safezone[pos] = power_denial_safezone; } else { priv->power_denial_length[pos] = 0; @@ -377,14 +377,14 @@ XPD_DBG(PROC, xpd, "\n"); #ifdef CONFIG_PROC_FS #ifdef WITH_METERING - if(priv->meteringfile) { + if (priv->meteringfile) { XPD_DBG(PROC, xpd, "Removing xpd metering tone file\n"); priv->meteringfile->data = NULL; remove_proc_entry(PROC_METERING_FNAME, xpd->proc_xpd_dir); priv->meteringfile = NULL; } #endif - if(priv->fxo_info) { + if (priv->fxo_info) { XPD_DBG(PROC, xpd, "Removing xpd FXO_INFO file\n"); remove_proc_entry(PROC_FXO_INFO_FNAME, xpd->proc_xpd_dir); priv->fxo_info = NULL; @@ -401,7 +401,7 @@ #ifdef CONFIG_PROC_FS XPD_DBG(PROC, xpd, "Creating FXO_INFO file\n"); priv->fxo_info = create_proc_read_entry(PROC_FXO_INFO_FNAME, 0444, xpd->proc_xpd_dir, proc_fxo_info_read, xpd); - if(!priv->fxo_info) { + if (!priv->fxo_info) { XPD_ERR(xpd, "Failed to create proc file '%s'\n", PROC_FXO_INFO_FNAME); goto err; } @@ -410,7 +410,7 @@ XPD_DBG(PROC, xpd, "Creating Metering tone file\n"); priv->meteringfile = create_proc_read_entry(PROC_METERING_FNAME, 0444, xpd->proc_xpd_dir, proc_xpd_metering_read, xpd); - if(!priv->meteringfile) { + if (!priv->meteringfile) { XPD_ERR(xpd, "Failed to create proc file '%s'\n", PROC_METERING_FNAME); goto err; } @@ -428,22 +428,22 @@ xpd_t *xpd = NULL; int channels; - if(to_phone) { + if (to_phone) { XBUS_NOTICE(xbus, "XPD=%d%d: try to instanciate FXO with reverse direction\n", unit, subunit); return NULL; } - if(subtype == 2) + if (subtype == 2) channels = min(2, subunit_ports); else channels = min(8, subunit_ports); xpd = xpd_alloc(xbus, unit, subunit, subtype, subunits, sizeof(struct FXO_priv_data), proto_table, channels); - if(!xpd) + if (!xpd) return NULL; xpd->direction = TO_PSTN; xpd->type_name = "FXO"; - if(fxo_proc_create(xbus, xpd) < 0) + if (fxo_proc_create(xbus, xpd) < 0) goto err; return xpd; err: @@ -465,7 +465,7 @@ priv->polarity_debounce[i] = 0; priv->battery[i] = BATTERY_UNKNOWN; /* will be updated on next battery sample */ priv->power[i] = POWER_UNKNOWN; /* will be updated on next battery sample */ - if(caller_id_style == CID_STYLE_ETSI_DTMF) + if (caller_id_style == CID_STYLE_ETSI_DTMF) oht_pcm(xpd, i, 1); } XPD_DBG(GENERAL, xpd, "done\n"); @@ -564,7 +564,7 @@ LINE_DBG(SIGNAL, xpd, pos, "%s\n", txsig2str(txsig)); BUG_ON(xpd->direction != TO_PSTN); /* XXX Enable hooksig for FXO XXX */ - switch(txsig) { + switch (txsig) { case DAHDI_TXSIG_START: case DAHDI_TXSIG_OFFHOOK: ret = do_sethook(xpd, pos, 1); @@ -586,8 +586,8 @@ BUG_ON(!xpd); priv = xpd->priv; - if(SPAN_REGISTERED(xpd)) { - switch(priv->battery[chan]) { + if (SPAN_REGISTERED(xpd)) { + switch (priv->battery[chan]) { case BATTERY_UNKNOWN: /* no-op */ break; @@ -640,13 +640,13 @@ priv = xpd->priv; for_each_line(xpd, i) { - if(atomic_read(&priv->ring_debounce[i]) > 0) { + if (atomic_read(&priv->ring_debounce[i]) > 0) { /* Maybe start ring */ - if(atomic_dec_and_test(&priv->ring_debounce[i])) + if (atomic_dec_and_test(&priv->ring_debounce[i])) mark_ring(xpd, i, 1, 1); } else if (atomic_read(&priv->ring_debounce[i]) < 0) { /* Maybe stop ring */ - if(atomic_inc_and_test(&priv->ring_debounce[i])) + if (atomic_inc_and_test(&priv->ring_debounce[i])) mark_ring(xpd, i, 0, 1); } } @@ -657,16 +657,16 @@ struct FXO_priv_data *priv; int i; - if(!power_denial_safezone) + if (!power_denial_safezone) return; /* Ignore power denials */ priv = xpd->priv; for_each_line(xpd, i) { - if(xpd->ringing[i] || !IS_OFFHOOK(xpd, i)) { + if (xpd->ringing[i] || !IS_OFFHOOK(xpd, i)) { priv->power_denial_delay[i] = 0; continue; } - if(priv->power_denial_safezone[i] > 0) { - if(--priv->power_denial_safezone[i] == 0) { + if (priv->power_denial_safezone[i] > 0) { + if (--priv->power_denial_safezone[i] == 0) { /* * Poll current, previous answers are meaningless */ @@ -674,9 +674,9 @@ } continue; } - if(priv->power_denial_length[i] > 0) { + if (priv->power_denial_length[i] > 0) { priv->power_denial_length[i]--; - if(priv->power_denial_length[i] <= 0) { + if (priv->power_denial_length[i] <= 0) { /* * But maybe the FXS started to ring (and the firmware haven't * detected it yet). This would cause false power denials. @@ -719,17 +719,17 @@ int portno; unsigned int timer_count; - if(!SPAN_REGISTERED(xpd)) + if (!SPAN_REGISTERED(xpd)) return; priv = xpd->priv; BUG_ON(!priv); timer_count = xpd->timer_count; for_each_line(xpd, portno) { /* Skip offhook and ringing ports */ - if(IS_OFFHOOK(xpd, portno) || xpd->ringing[portno]) + if (IS_OFFHOOK(xpd, portno) || xpd->ringing[portno]) continue; - if(IS_SET(priv->cidfound, portno)) { - if(timer_count > priv->cidtimer[portno] + 4000) { + if (IS_SET(priv->cidfound, portno)) { + if (timer_count > priv->cidtimer[portno] + 4000) { /* reset flags if it's been a while */ priv->cidtimer[portno] = timer_count; BIT_CLR(priv->cidfound, portno); @@ -737,14 +737,14 @@ } continue; } - if(timer_count > priv->cidtimer[portno] + 400) { + if (timer_count > priv->cidtimer[portno] + 400) { struct dahdi_chan *chan = XPD_CHAN(xpd, portno); int sample; int i; - for(i = 0; i < DAHDI_CHUNKSIZE; i++) { + for (i = 0; i < DAHDI_CHUNKSIZE; i++) { sample = DAHDI_XLAW(chan->readchunk[i], chan); - if(sample > 16000 || sample < -16000) { + if (sample > 16000 || sample < -16000) { priv->cidtimer[portno] = timer_count; BIT_SET(priv->cidfound, portno); LINE_DBG(SIGNAL, xpd, portno, "Found DTMF CLIP (%d)\n", i); @@ -763,16 +763,16 @@ BUG_ON(!xpd); priv = xpd->priv; BUG_ON(!priv); - if(poll_battery_interval != 0 && (priv->poll_counter % poll_battery_interval) == 0) + if (poll_battery_interval != 0 && (priv->poll_counter % poll_battery_interval) == 0) poll_battery(xbus, xpd); #ifdef WITH_METERING - if(poll_metering_interval != 0 && (priv->poll_counter % poll_metering_interval) == 0) + if (poll_metering_interval != 0 && (priv->poll_counter % poll_metering_interval) == 0) poll_metering(xbus, xpd); #endif handle_fxo_leds(xpd); handle_fxo_ring(xpd); handle_fxo_power_denial(xpd); - if(caller_id_style == CID_STYLE_ETSI_DTMF && likely(xpd->card_present)) + if (caller_id_style == CID_STYLE_ETSI_DTMF && likely(xpd->card_present)) check_etsi_dtmf(xpd); priv->poll_counter++; return 0; @@ -792,7 +792,7 @@ unsigned char echotune_data[ARRAY_SIZE(echotune_regs)]; BUG_ON(!xpd); - if(!XBUS_IS(xpd->xbus, READY)) + if (!XBUS_IS(xpd->xbus, READY)) return -ENODEV; switch (cmd) { case WCTDM_SET_ECHOTUNE: @@ -854,7 +854,7 @@ int i; struct FXO_priv_data *priv; - if(!xpd) { + if (!xpd) { notify_bad_xpd(__FUNCTION__, xbus, XPACKET_ADDR(pack), cmd->name); return -EPROTO; } @@ -865,8 +865,8 @@ for_each_line(xpd, i) { int debounce; - if(IS_SET(sig_toggles, i)) { - if(priv->battery[i] == BATTERY_OFF) { + if (IS_SET(sig_toggles, i)) { + if (priv->battery[i] == BATTERY_OFF) { /* * With poll_battery_interval==0 we cannot have BATTERY_OFF * so we won't get here @@ -876,7 +876,7 @@ } /* First report false ring alarms */ debounce = atomic_read(&priv->ring_debounce[i]); - if(debounce) + if (debounce) LINE_NOTICE(xpd, i, "debounced false ring (only %d ticks)\n", debounce); /* * Now set a new ring alarm. @@ -900,18 +900,18 @@ priv = xpd->priv; BUG_ON(!priv); priv->battery_voltage[portno] = volts; - if(xpd->ringing[portno]) + if (xpd->ringing[portno]) goto ignore_reading; /* ring voltage create false alarms */ - if(abs(volts) < BAT_THRESHOLD) { + if (abs(volts) < BAT_THRESHOLD) { /* * Check for battery voltage fluctuations */ - if(priv->battery[portno] != BATTERY_OFF) { + if (priv->battery[portno] != BATTERY_OFF) { int milliseconds; milliseconds = priv->nobattery_debounce[portno]++ * poll_battery_interval; - if(milliseconds > BAT_DEBOUNCE) { + if (milliseconds > BAT_DEBOUNCE) { LINE_DBG(SIGNAL, xpd, portno, "BATTERY OFF voltage=%d\n", volts); priv->battery[portno] = BATTERY_OFF; dahdi_report_battery(xpd, portno); @@ -929,7 +929,7 @@ } } else { priv->nobattery_debounce[portno] = 0; - if(priv->battery[portno] != BATTERY_ON) { + if (priv->battery[portno] != BATTERY_ON) { LINE_DBG(SIGNAL, xpd, portno, "BATTERY ON voltage=%d\n", volts); priv->battery[portno] = BATTERY_ON; dahdi_report_battery(xpd, portno); @@ -939,25 +939,25 @@ /* * Mark FXO ports without battery! */ - if(priv->battery[portno] != BATTERY_ON) + if (priv->battery[portno] != BATTERY_ON) MARK_ON(priv, portno, LED_RED); else MARK_OFF(priv, portno, LED_RED); #endif - if(priv->battery[portno] != BATTERY_ON) { + if (priv->battery[portno] != BATTERY_ON) { priv->polarity[portno] = POL_UNKNOWN; /* What's the polarity ? */ return; } /* * Handle reverse polarity */ - if(volts == 0) + if (volts == 0) pol = POL_UNKNOWN; - else if(volts < 0) + else if (volts < 0) pol = POL_NEGATIVE; else pol = POL_POSITIVE; - if(priv->polarity[portno] == pol) { + if (priv->polarity[portno] == pol) { /* * Same polarity, reset debounce counter */ @@ -971,12 +971,12 @@ msec = priv->polarity_debounce[portno]++ * poll_battery_interval; if (msec >= POLREV_THRESHOLD) { priv->polarity_debounce[portno] = 0; - if(pol != POL_UNKNOWN && priv->polarity[portno] != POL_UNKNOWN) { + if (pol != POL_UNKNOWN && priv->polarity[portno] != POL_UNKNOWN) { char *polname = NULL; - if(pol == POL_POSITIVE) + if (pol == POL_POSITIVE) polname = "Positive"; - else if(pol == POL_NEGATIVE) + else if (pol == POL_NEGATIVE) polname = "Negative"; else BUG(); @@ -988,9 +988,9 @@ * 2. In some countries used to report caller-id during onhook * but before first ring. */ - if(caller_id_style == CID_STYLE_ETSI_FSK) + if (caller_id_style == CID_STYLE_ETSI_FSK) oht_pcm(xpd, portno, 1); /* will be cleared on ring/offhook */ - if(SPAN_REGISTERED(xpd)) { + if (SPAN_REGISTERED(xpd)) { LINE_DBG(SIGNAL, xpd, portno, "Send DAHDI_EVENT_POLARITY: %s\n", polname); dahdi_qevent_lock(XPD_CHAN(xpd, portno), DAHDI_EVENT_POLARITY); @@ -1017,23 +1017,23 @@ * During ringing, current is not stable. * During onhook there should not be current anyway. */ - if(xpd->ringing[portno] || !IS_OFFHOOK(xpd, portno)) + if (xpd->ringing[portno] || !IS_OFFHOOK(xpd, portno)) goto ignore_it; /* * Power denial with no battery voltage is meaningless */ - if(priv->battery[portno] != BATTERY_ON) + if (priv->battery[portno] != BATTERY_ON) goto ignore_it; /* Safe zone after offhook */ - if(priv->power_denial_safezone[portno] > 0) + if (priv->power_denial_safezone[portno] > 0) goto ignore_it; - if(data_low < POWER_DENIAL_CURRENT) { - if(priv->power[portno] == POWER_ON) { + if (data_low < POWER_DENIAL_CURRENT) { + if (priv->power[portno] == POWER_ON) { power_change(xpd, portno, POWER_OFF); priv->power_denial_length[portno] = power_denial_minlen; } } else { - if(priv->power[portno] != POWER_ON) { + if (priv->power[portno] != POWER_ON) { power_change(xpd, portno, POWER_ON); priv->power_denial_length[portno] = 0; /* We are now OFFHOOK */ @@ -1060,13 +1060,13 @@ LINE_DBG(SIGNAL, xpd, portno, "METERING: %s [dL=0x%X] (%d)\n", (metering_tone) ? "ON" : "OFF", data_low, priv->metering_count[portno]); - if(metering_tone && !old_metering_tone) { + if (metering_tone && !old_metering_tone) { /* Rising edge */ priv->metering_count[portno]++; BIT_SET(priv->metering_tone_state, portno); - } else if(!metering_tone && old_metering_tone) + } else if (!metering_tone && old_metering_tone) BIT_CLR(priv->metering_tone_state, portno); - if(metering_tone) { + if (metering_tone) { /* Clear the BTD bit */ data_low &= ~BTD_BIT; DAA_DIRECT_REQUEST(xpd->xbus, xpd, portno, DAA_WRITE, DAA_REG_METERING, data_low); @@ -1082,7 +1082,7 @@ priv = xpd->priv; BUG_ON(!priv); portno = info->portnum; - switch(REG_FIELD(info, regnum)) { + switch (REG_FIELD(info, regnum)) { case DAA_REG_VBAT: update_battery_voltage(xpd, REG_FIELD(info, data_low), portno); break; @@ -1101,7 +1101,7 @@ REG_FIELD(info, data_low), REG_FIELD(info, data_high)); /* Update /proc info only if reply relate to the last slic read request */ - if( + if ( REG_FIELD(&xpd->requested_reply, regnum) == REG_FIELD(info, regnum) && REG_FIELD(&xpd->requested_reply, do_subreg) == REG_FIELD(info, do_subreg) && REG_FIELD(&xpd->requested_reply, subreg) == REG_FIELD(info, subreg)) { @@ -1165,27 +1165,27 @@ struct FXO_priv_data *priv; int i; - if(!xpd) + if (!xpd) return -ENODEV; spin_lock_irqsave(&xpd->lock, flags); priv = xpd->priv; BUG_ON(!priv); len += sprintf(page + len, "\t%-17s: ", "Channel"); for_each_line(xpd, i) { - if(!IS_SET(xpd->digital_outputs, i) && !IS_SET(xpd->digital_inputs, i)) + if (!IS_SET(xpd->digital_outputs, i) && !IS_SET(xpd->digital_inputs, i)) len += sprintf(page + len, "%4d ", i % 10); } len += sprintf(page + len, "\nLeds:"); len += sprintf(page + len, "\n\t%-17s: ", "state"); for_each_line(xpd, i) { - if(!IS_SET(xpd->digital_outputs, i) && !IS_SET(xpd->digital_inputs, i)) + if (!IS_SET(xpd->digital_outputs, i) && !IS_SET(xpd->digital_inputs, i)) len += sprintf(page + len, " %d%d ", IS_SET(priv->ledstate[LED_GREEN], i), IS_SET(priv->ledstate[LED_RED], i)); } len += sprintf(page + len, "\n\t%-17s: ", "blinking"); for_each_line(xpd, i) { - if(!IS_SET(xpd->digital_outputs, i) && !IS_SET(xpd->digital_inputs, i)) + if (!IS_SET(xpd->digital_outputs, i) && !IS_SET(xpd->digital_inputs, i)) len += sprintf(page + len, " %d%d ", IS_BLINKING(priv,i,LED_GREEN), IS_BLINKING(priv,i,LED_RED)); @@ -1204,9 +1204,9 @@ for_each_line(xpd, i) { char *bat; - if(priv->battery[i] == BATTERY_ON) + if (priv->battery[i] == BATTERY_ON) bat = "+"; - else if(priv->battery[i] == BATTERY_OFF) + else if (priv->battery[i] == BATTERY_OFF) bat = "-"; else bat = "."; @@ -1221,9 +1221,9 @@ for_each_line(xpd, i) { char *polname; - if(priv->polarity[i] == POL_POSITIVE) + if (priv->polarity[i] == POL_POSITIVE) polname = "+"; - else if(priv->polarity[i] == POL_NEGATIVE) + else if (priv->polarity[i] == POL_NEGATIVE) polname = "-"; else polname = "."; @@ -1238,9 +1238,9 @@ for_each_line(xpd, i) { char *curr; - if(priv->power[i] == POWER_ON) + if (priv->power[i] == POWER_ON) curr = "+"; - else if(priv->power[i] == POWER_OFF) + else if (priv->power[i] == POWER_OFF) curr = "-"; else curr = "."; @@ -1283,7 +1283,7 @@ struct FXO_priv_data *priv; int i; - if(!xpd) + if (!xpd) return -ENODEV; priv = xpd->priv; BUG_ON(!priv); @@ -1319,7 +1319,7 @@ BUG_ON(!dev); xpd = dev_to_xpd(dev); - if(!xpd) + if (!xpd) return -ENODEV; priv = xpd->priv; BUG_ON(!priv); @@ -1327,9 +1327,9 @@ for_each_line(xpd, i) { char bat; - if(priv->battery[i] == BATTERY_ON) + if (priv->battery[i] == BATTERY_ON) bat = '+'; - else if(priv->battery[i] == BATTERY_OFF) + else if (priv->battery[i] == BATTERY_OFF) bat = '-'; else bat = '.'; @@ -1350,14 +1350,14 @@ xpd = dev_to_xpd(dev); /* Is it our device? */ - if(xpd->type != XPD_TYPE_FXO) { + if (xpd->type != XPD_TYPE_FXO) { XPD_ERR(xpd, "drop suggestion for %s (%d)\n", dev_name(dev), xpd->type); return -EINVAL; } XPD_DBG(DEVICES, xpd, "SYSFS\n"); ret = device_create_file(dev, &dev_attr_fxo_battery); - if(ret) { + if (ret) { XPD_ERR(xpd, "%s: device_create_file(fxo_battery) failed: %d\n", __FUNCTION__, ret); goto fail_fxo_battery; } @@ -1392,11 +1392,11 @@ { int ret; - if(ring_debounce <= 0) { + if (ring_debounce <= 0) { ERR("ring_debounce=%d. Must be positive number of ticks\n", ring_debounce); return -EINVAL; } - if((ret = xpd_driver_register(&fxo_driver.driver)) < 0) + if ((ret = xpd_driver_register(&fxo_driver.driver)) < 0) return ret; INFO("revision %s\n", XPP_VERSION); #ifdef WITH_METERING Index: drivers/dahdi/xpp/card_fxs.c =================================================================== --- drivers/dahdi/xpp/card_fxs.c (revision 7493) +++ drivers/dahdi/xpp/card_fxs.c (working copy) @@ -149,8 +149,8 @@ #define LED_COUNTER(priv,pos,color) ((priv)->led_counter[color][pos]) #define IS_BLINKING(priv,pos,color) (LED_COUNTER(priv,pos,color) > 0) #define MARK_BLINK(priv,pos,color,t) ((priv)->led_counter[color][pos] = (t)) -#define MARK_OFF(priv,pos,color) do { BIT_CLR((priv)->ledcontrol[color],(pos)); MARK_BLINK((priv),(pos),(color),0); } while(0) -#define MARK_ON(priv,pos,color) do { BIT_SET((priv)->ledcontrol[color],(pos)); MARK_BLINK((priv),(pos),(color),0); } while(0) +#define MARK_OFF(priv,pos,color) do { BIT_CLR((priv)->ledcontrol[color],(pos)); MARK_BLINK((priv),(pos),(color),0); } while (0) +#define MARK_ON(priv,pos,color) do { BIT_SET((priv)->ledcontrol[color],(pos)); MARK_BLINK((priv),(pos),(color),0); } while (0) #define LED_BLINK_RING (1000/8) /* in ticks */ @@ -181,7 +181,7 @@ priv = xpd->priv; BUG_ON(!xpd); - if(vmwineon && on) { + if (vmwineon && on) { LINE_DBG(SIGNAL, xpd, pos, "START\n"); BIT_SET(priv->search_fsk_pattern, pos); } else { @@ -234,12 +234,12 @@ xbus = xpd->xbus; priv = xpd->priv; which = which % NUM_LEDS; - if(IS_SET(xpd->digital_outputs, chan) || IS_SET(xpd->digital_inputs, chan)) + if (IS_SET(xpd->digital_outputs, chan) || IS_SET(xpd->digital_inputs, chan)) goto out; - if(chan == PORT_BROADCAST) { + if (chan == PORT_BROADCAST) { priv->ledstate[which] = (on) ? ~0 : 0; } else { - if(on) { + if (on) { BIT_SET(priv->ledstate[which], chan); } else { BIT_CLR(priv->ledstate[which], chan); @@ -248,7 +248,7 @@ LINE_DBG(LEDS, xpd, chan, "LED: which=%d -- %s\n", which, (on) ? "on" : "off"); value = BIT(2) | BIT(3); value |= ((BIT(5) | BIT(6) | BIT(7)) & ~led_register_mask[which]); - if(on) + if (on) value |= led_register_vals[which]; ret = SLIC_DIRECT_REQUEST(xbus, xpd, chan, SLIC_WRITE, REG_DIGITAL_IOCTRL, value); @@ -267,27 +267,27 @@ BUG_ON(!xpd); priv = xpd->priv; timer_count = xpd->timer_count; - for(color = 0; color < ARRAY_SIZE(colors); color++) { + for (color = 0; color < ARRAY_SIZE(colors); color++) { for_each_line(xpd, i) { - if(IS_SET(xpd->digital_outputs | xpd->digital_inputs, i)) + if (IS_SET(xpd->digital_outputs | xpd->digital_inputs, i)) continue; - if((xpd->blink_mode & BIT(i)) || IS_BLINKING(priv, i, color)) { // Blinking + if ((xpd->blink_mode & BIT(i)) || IS_BLINKING(priv, i, color)) { // Blinking int mod_value = LED_COUNTER(priv, i, color); - if(!mod_value) + if (!mod_value) mod_value = DEFAULT_LED_PERIOD; /* safety value */ // led state is toggled - if((timer_count % mod_value) == 0) { + if ((timer_count % mod_value) == 0) { LINE_DBG(LEDS, xpd, i, "ledstate=%s\n", (IS_SET(priv->ledstate[color], i))?"ON":"OFF"); - if(!IS_SET(priv->ledstate[color], i)) { + if (!IS_SET(priv->ledstate[color], i)) { do_led(xpd, i, color, 1); } else { do_led(xpd, i, color, 0); } } - } else if(IS_SET(priv->ledcontrol[color] & ~priv->ledstate[color], i)) { + } else if (IS_SET(priv->ledcontrol[color] & ~priv->ledstate[color], i)) { do_led(xpd, i, color, 1); - } else if(IS_SET(~priv->ledcontrol[color] & priv->ledstate[color], i)) { + } else if (IS_SET(~priv->ledcontrol[color] & priv->ledstate[color], i)) { do_led(xpd, i, color, 0); } @@ -302,7 +302,7 @@ priv = xpd->priv; for_each_line(xpd, i) { - if(IS_OFFHOOK(xpd, i)) + if (IS_OFFHOOK(xpd, i)) MARK_ON(priv, i, LED_GREEN); else MARK_OFF(priv, i, LED_GREEN); @@ -329,14 +329,14 @@ priv = xpd->priv; #ifdef CONFIG_PROC_FS #ifdef WITH_METERING - if(priv->meteringfile) { + if (priv->meteringfile) { XPD_DBG(PROC, xpd, "Removing xpd metering tone file\n"); priv->meteringfile->data = NULL; remove_proc_entry(PROC_METERING_FNAME, xpd->proc_xpd_dir); priv->meteringfile = NULL; } #endif - if(priv->fxs_info) { + if (priv->fxs_info) { XPD_DBG(PROC, xpd, "Removing xpd FXS_INFO file\n"); remove_proc_entry(PROC_FXS_INFO_FNAME, xpd->proc_xpd_dir); priv->fxs_info = NULL; @@ -354,7 +354,7 @@ #ifdef CONFIG_PROC_FS XPD_DBG(PROC, xpd, "Creating FXS_INFO file\n"); priv->fxs_info = create_proc_read_entry(PROC_FXS_INFO_FNAME, 0444, xpd->proc_xpd_dir, proc_fxs_info_read, xpd); - if(!priv->fxs_info) { + if (!priv->fxs_info) { XPD_ERR(xpd, "Failed to create proc file '%s'\n", PROC_FXS_INFO_FNAME); goto err; } @@ -362,7 +362,7 @@ #ifdef WITH_METERING XPD_DBG(PROC, xpd, "Creating Metering tone file\n"); priv->meteringfile = create_proc_entry(PROC_METERING_FNAME, 0200, xpd->proc_xpd_dir); - if(!priv->meteringfile) { + if (!priv->meteringfile) { XPD_ERR(xpd, "Failed to create proc file '%s'\n", PROC_METERING_FNAME); goto err; } @@ -386,30 +386,30 @@ struct FXS_priv_data *priv; int i; - if(!to_phone) { + if (!to_phone) { XBUS_NOTICE(xbus, "XPD=%d%d: try to instanciate FXS with reverse direction\n", unit, subunit); return NULL; } - if(subtype == 2) + if (subtype == 2) regular_channels = min(6, subunit_ports); else regular_channels = min(8, subunit_ports); channels = regular_channels; - if(unit == 0) + if (unit == 0) channels += 6; /* 2 DIGITAL OUTPUTS, 4 DIGITAL INPUTS */ xpd = xpd_alloc(xbus, unit, subunit, subtype, subunits, sizeof(struct FXS_priv_data), proto_table, channels); - if(!xpd) + if (!xpd) return NULL; - if(unit == 0) { + if (unit == 0) { XBUS_DBG(GENERAL, xbus, "First XPD detected. Initialize digital outputs/inputs\n"); xpd->digital_outputs = BITMASK(LINES_DIGI_OUT) << regular_channels; xpd->digital_inputs = BITMASK(LINES_DIGI_INP) << (regular_channels + LINES_DIGI_OUT); } xpd->direction = TO_PHONE; xpd->type_name = "FXS"; - if(fxs_proc_create(xbus, xpd) < 0) + if (fxs_proc_create(xbus, xpd) < 0) goto err; priv = xpd->priv; for_each_line(xpd, i) { @@ -434,7 +434,7 @@ */ /* Software controled ringing (for CID) */ ret = SLIC_DIRECT_REQUEST(xbus, xpd, PORT_BROADCAST, SLIC_WRITE, 0x22, 0x00); /* Ringing Oscilator Control */ - if(ret < 0) + if (ret < 0) goto err; for_each_line(xpd, i) { linefeed_control(xbus, xpd, i, FXS_LINE_POL_ACTIVE); @@ -460,7 +460,7 @@ * So we do this after the LEDs */ for_each_line(xpd, i) { - if(IS_SET(xpd->digital_outputs | xpd->digital_inputs, i)) + if (IS_SET(xpd->digital_outputs | xpd->digital_inputs, i)) continue; SLIC_DIRECT_REQUEST(xbus, xpd, i, SLIC_READ, REG_LOOPCLOSURE, 0); } @@ -500,10 +500,10 @@ struct dahdi_chan *cur_chan = XPD_CHAN(xpd, i); XPD_DBG(GENERAL, xpd, "setting FXS channel %d\n", i); - if(IS_SET(xpd->digital_outputs, i)) { + if (IS_SET(xpd->digital_outputs, i)) { snprintf(cur_chan->name, MAX_CHANNAME, "XPP_OUT/%02d/%1d%1d/%d", xbus->num, xpd->addr.unit, xpd->addr.subunit, i); - } else if(IS_SET(xpd->digital_inputs, i)) { + } else if (IS_SET(xpd->digital_inputs, i)) { snprintf(cur_chan->name, MAX_CHANNAME, "XPP_IN/%02d/%1d%1d/%d", xbus->num, xpd->addr.unit, xpd->addr.subunit, i); } else { @@ -550,7 +550,7 @@ static void __do_mute_dtmf(xpd_t *xpd, int pos, bool muteit) { LINE_DBG(SIGNAL, xpd, pos, "%s\n", (muteit) ? "MUTE" : "UNMUTE"); - if(muteit) + if (muteit) BIT_SET(xpd->mute_dtmf, pos); else BIT_CLR(xpd->mute_dtmf, pos); @@ -622,7 +622,7 @@ which = which % ARRAY_SIZE(relay_channels); value = BIT(2) | BIT(3); value |= ((BIT(5) | BIT(6) | BIT(7)) & ~led_register_mask[OUTPUT_RELAY]); - if(on) + if (on) value |= led_register_vals[OUTPUT_RELAY]; return SLIC_DIRECT_REQUEST(xpd->xbus, xpd, relay_channels[which], SLIC_WRITE, REG_DIGITAL_IOCTRL, value); @@ -643,10 +643,10 @@ set_vm_led_mode(xbus, xpd, chan, 0); do_chan_power(xbus, xpd, chan, on); // Power up (for ring) ret = linefeed_control(xbus, xpd, chan, value); - if(on) { + if (on) { MARK_BLINK(priv, chan, LED_GREEN, LED_BLINK_RING); } else { - if(IS_BLINKING(priv, chan, LED_GREEN)) + if (IS_BLINKING(priv, chan, LED_GREEN)) MARK_BLINK(priv, chan, LED_GREEN, 0); } return ret; @@ -667,9 +667,9 @@ LINE_DBG(SIGNAL, xpd, pos, "Ignoring signal sent to digital input line\n"); return 0; } - if(SPAN_REGISTERED(xpd)) + if (SPAN_REGISTERED(xpd)) chan = XPD_CHAN(xpd, pos); - switch(txsig) { + switch (txsig) { case DAHDI_TXSIG_ONHOOK: spin_lock_irqsave(&xpd->lock, flags); xpd->ringing[pos] = 0; @@ -679,7 +679,7 @@ BIT_CLR(priv->want_dtmf_mute, pos); __do_mute_dtmf(xpd, pos, 0); spin_unlock_irqrestore(&xpd->lock, flags); - if(IS_SET(xpd->digital_outputs, pos)) { + if (IS_SET(xpd->digital_outputs, pos)) { LINE_DBG(SIGNAL, xpd, pos, "%s -> digital output OFF\n", txsig2str(txsig)); ret = relay_out(xpd, pos, 0); return ret; @@ -690,15 +690,15 @@ */ LINE_DBG(SIGNAL, xpd, pos, "KEWL STOP\n"); linefeed_control(xbus, xpd, pos, FXS_LINE_POL_ACTIVE); - if(IS_OFFHOOK(xpd, pos)) + if (IS_OFFHOOK(xpd, pos)) MARK_ON(priv, pos, LED_GREEN); } ret = send_ring(xpd, pos, 0); // RING off if (!IS_OFFHOOK(xpd, pos)) start_stop_vm_led(xbus, xpd, pos); txhook = priv->lasttxhook[pos]; - if(chan) { - switch(chan->sig) { + if (chan) { + switch (chan->sig) { case DAHDI_SIG_EM: case DAHDI_SIG_FXOKS: case DAHDI_SIG_FXOLS: @@ -712,18 +712,18 @@ ret = linefeed_control(xbus, xpd, pos, txhook); break; case DAHDI_TXSIG_OFFHOOK: - if(IS_SET(xpd->digital_outputs, pos)) { + if (IS_SET(xpd->digital_outputs, pos)) { LINE_NOTICE(xpd, pos, "%s -> Is digital output. Ignored\n", txsig2str(txsig)); return -EINVAL; } txhook = priv->lasttxhook[pos]; - if(xpd->ringing[pos]) { + if (xpd->ringing[pos]) { oht_pcm(xpd, pos, 1); txhook = FXS_LINE_OHTRANS; } xpd->ringing[pos] = 0; - if(chan) { - switch(chan->sig) { + if (chan) { + switch (chan->sig) { case DAHDI_SIG_EM: txhook = FXS_LINE_POL_ACTIVE; break; @@ -738,7 +738,7 @@ xpd->ringing[pos] = 1; oht_pcm(xpd, pos, 0); vmwi_search(xpd, pos, 0); - if(IS_SET(xpd->digital_outputs, pos)) { + if (IS_SET(xpd->digital_outputs, pos)) { LINE_DBG(SIGNAL, xpd, pos, "%s -> digital output ON\n", txsig2str(txsig)); ret = relay_out(xpd, pos, 1); return ret; @@ -746,7 +746,7 @@ ret = send_ring(xpd, pos, 1); // RING on break; case DAHDI_TXSIG_KEWL: - if(IS_SET(xpd->digital_outputs, pos)) { + if (IS_SET(xpd->digital_outputs, pos)) { LINE_DBG(SIGNAL, xpd, pos, "%s -> Is digital output. Ignored\n", txsig2str(txsig)); return -EINVAL; } @@ -777,7 +777,7 @@ BUG_ON(!priv); xbus = xpd->xbus; BUG_ON(!xbus); - if(!XBUS_IS(xbus, READY)) + if (!XBUS_IS(xbus, READY)) return -ENODEV; if (pos < 0 || pos >= xpd->channels) { XPD_NOTICE(xpd, "Bad channel number %d in %s(), cmd=%u\n", @@ -793,14 +793,14 @@ if (IS_SET(xpd->digital_inputs | xpd->digital_outputs, pos)) return 0; /* Nothing to do */ oht_pcm(xpd, pos, 1); /* Get ready of VMWI FSK tones */ - if(priv->lasttxhook[pos] == FXS_LINE_POL_ACTIVE) { + if (priv->lasttxhook[pos] == FXS_LINE_POL_ACTIVE) { priv->ohttimer[pos] = val; priv->idletxhookstate[pos] = FXS_LINE_POL_OHTRANS; vmwi_search(xpd, pos, 1); CALL_XMETHOD(card_pcm_recompute, xbus, xpd, priv->search_fsk_pattern); LINE_DBG(SIGNAL, xpd, pos, "Start OHT_TIMER. wanted_pcm_mask=0x%X\n", xpd->wanted_pcm_mask); } - if(vmwineon && !IS_OFFHOOK(xpd, pos)) + if (vmwineon && !IS_OFFHOOK(xpd, pos)) start_stop_vm_led(xbus, xpd, pos); return 0; case DAHDI_TONEDETECT: @@ -810,9 +810,9 @@ (val & DAHDI_TONEDETECT_ON) ? "ON" : "OFF", (val & DAHDI_TONEDETECT_MUTE) ? "MUTE" : "NO-MUTE", (dtmf_detection ? "YES" : "NO")); - if(!dtmf_detection) { + if (!dtmf_detection) { spin_lock_irqsave(&xpd->lock, flags); - if(IS_SET(priv->want_dtmf_events, pos)) { + if (IS_SET(priv->want_dtmf_events, pos)) { /* Detection mode changed: Disable DTMF interrupts */ SLIC_DIRECT_REQUEST(xbus, xpd, pos, SLIC_WRITE, 0x17, 0); } @@ -828,8 +828,8 @@ * dtmf events. Check the requested state. */ spin_lock_irqsave(&xpd->lock, flags); - if(val & DAHDI_TONEDETECT_ON) { - if(!IS_SET(priv->want_dtmf_events, pos)) { + if (val & DAHDI_TONEDETECT_ON) { + if (!IS_SET(priv->want_dtmf_events, pos)) { /* Detection mode changed: Enable DTMF interrupts */ LINE_DBG(SIGNAL, xpd, pos, "DAHDI_TONEDETECT: Enable Hardware DTMF\n"); @@ -837,7 +837,7 @@ } BIT_SET(priv->want_dtmf_events, pos); } else { - if(IS_SET(priv->want_dtmf_events, pos)) { + if (IS_SET(priv->want_dtmf_events, pos)) { /* Detection mode changed: Disable DTMF interrupts */ LINE_DBG(SIGNAL, xpd, pos, "DAHDI_TONEDETECT: Disable Hardware DTMF\n"); @@ -845,7 +845,7 @@ } BIT_CLR(priv->want_dtmf_events, pos); } - if(val & DAHDI_TONEDETECT_MUTE) { + if (val & DAHDI_TONEDETECT_MUTE) { BIT_SET(priv->want_dtmf_mute, pos); } else { BIT_CLR(priv->want_dtmf_mute, pos); @@ -873,10 +873,10 @@ case DAHDI_VMWI: /* message-waiting led control */ if (get_user(val, (int __user *)arg)) return -EFAULT; - if(!vmwi_ioctl) { + if (!vmwi_ioctl) { static bool notified = 0; - if(!notified++) + if (!notified++) LINE_NOTICE(xpd, pos, "Got DAHDI_VMWI notification but vmwi_ioctl parameter is off. Ignoring.\n"); return 0; @@ -902,7 +902,7 @@ BUG_ON(!xpd); priv = xpd->priv; - if(IS_OFFHOOK(xpd, chan)) + if (IS_OFFHOOK(xpd, chan)) LINE_NOTICE(xpd, chan, "Already offhook during open. OK.\n"); else LINE_DBG(SIGNAL, xpd, chan, "is onhook\n"); @@ -943,7 +943,7 @@ int i; BUG_ON(xpd->xbus_idx != 0); // Only unit #0 has digital inputs - for(i = 0; i < ARRAY_SIZE(input_channels); i++) { + for (i = 0; i < ARRAY_SIZE(input_channels); i++) { byte pos = input_channels[i]; SLIC_DIRECT_REQUEST(xpd->xbus, xpd, pos, SLIC_READ, 0x06, 0); @@ -990,8 +990,8 @@ { int i; - for(i = 0; i < len; i++) - if(a[i] != b[i]) + for (i = 0; i < len; i++) + if (a[i] != b[i]) return 0; return 1; } @@ -1023,32 +1023,32 @@ struct dahdi_chan *chan = XPD_CHAN(xpd, i); byte *writechunk = chan->writechunk; - if(IS_SET(ignore_mask, i)) + if (IS_SET(ignore_mask, i)) continue; #if 0 - if(writechunk[0] != 0x7F && writechunk[0] != 0) { + if (writechunk[0] != 0x7F && writechunk[0] != 0) { int j; LINE_DBG(GENERAL, xpd, pos, "MSG:"); - for(j = 0; j < DAHDI_CHUNKSIZE; j++) { - if(debug) + for (j = 0; j < DAHDI_CHUNKSIZE; j++) { + if (debug) printk(" %02X", writechunk[j]); } - if(debug) + if (debug) printk("\n"); } #endif - if(unlikely(mem_equal(writechunk, FSK_COMMON_PATTERN, DAHDI_CHUNKSIZE))) { + if (unlikely(mem_equal(writechunk, FSK_COMMON_PATTERN, DAHDI_CHUNKSIZE))) { LINE_DBG(SIGNAL, xpd, i, "Found common FSK pattern. Start looking for ON/OFF patterns.\n"); BIT_SET(priv->found_fsk_pattern, i); - } else if(unlikely(IS_SET(priv->found_fsk_pattern, i))) { + } else if (unlikely(IS_SET(priv->found_fsk_pattern, i))) { BIT_CLR(priv->found_fsk_pattern, i); oht_pcm(xpd, i, 0); - if(unlikely(mem_equal(writechunk, FSK_ON_PATTERN, DAHDI_CHUNKSIZE))) { + if (unlikely(mem_equal(writechunk, FSK_ON_PATTERN, DAHDI_CHUNKSIZE))) { LINE_DBG(SIGNAL, xpd, i, "MSG WAITING ON\n"); BIT_SET(xpd->msg_waiting, i); start_stop_vm_led(xbus, xpd, i); - } else if(unlikely(mem_equal(writechunk, FSK_OFF_PATTERN, DAHDI_CHUNKSIZE))) { + } else if (unlikely(mem_equal(writechunk, FSK_OFF_PATTERN, DAHDI_CHUNKSIZE))) { LINE_DBG(SIGNAL, xpd, i, "MSG WAITING OFF\n"); BIT_CLR(xpd->msg_waiting, i); start_stop_vm_led(xbus, xpd, i); @@ -1056,7 +1056,7 @@ int j; LINE_NOTICE(xpd, i, "MSG WAITING Unexpected:"); - for(j = 0; j < DAHDI_CHUNKSIZE; j++) { + for (j = 0; j < DAHDI_CHUNKSIZE; j++) { printk(" %02X", writechunk[j]); } printk("\n"); @@ -1073,8 +1073,8 @@ priv = xpd->priv; BUG_ON(!priv); #ifdef POLL_DIGITAL_INPUTS - if(poll_digital_inputs && xpd->xbus_idx == 0) { - if((xpd->timer_count % poll_digital_inputs) == 0) + if (poll_digital_inputs && xpd->xbus_idx == 0) { + if ((xpd->timer_count % poll_digital_inputs) == 0) poll_inputs(xpd); } #endif @@ -1087,20 +1087,20 @@ * so we marked it in the priv->update_offhook_state mask and * now we take care of notification to dahdi and Asterisk */ - if(priv->update_offhook_state) { + if (priv->update_offhook_state) { enum dahdi_rxsig rxsig; int i; for_each_line(xpd, i) { - if(!IS_SET(priv->update_offhook_state, i)) + if (!IS_SET(priv->update_offhook_state, i)) continue; rxsig = IS_OFFHOOK(xpd, i) ? DAHDI_RXSIG_OFFHOOK : DAHDI_RXSIG_ONHOOK; notify_rxsig(xpd, i, rxsig); /* Notify after open() */ BIT_CLR(priv->update_offhook_state, i); } } - if(SPAN_REGISTERED(xpd)) { - if(vmwineon && !vmwi_ioctl && priv->search_fsk_pattern) + if (SPAN_REGISTERED(xpd)) { + if (vmwineon && !vmwi_ioctl && priv->search_fsk_pattern) detect_vmwi(xpd); /* Detect via FSK modulation */ } return 0; @@ -1133,9 +1133,9 @@ priv = xpd->priv; XPD_DBG(SIGNAL, xpd, "offhook=0x%X change_mask=0x%X\n", offhook, change_mask); for_each_line(xpd, i) { - if(IS_SET(xpd->digital_outputs, i) || IS_SET(xpd->digital_inputs, i)) + if (IS_SET(xpd->digital_outputs, i) || IS_SET(xpd->digital_inputs, i)) continue; - if(IS_SET(change_mask, i)) { + if (IS_SET(change_mask, i)) { xpd->ringing[i] = 0; /* No more ringing... */ #ifdef WITH_METERING metering_gen(xpd, i, 0); /* Stop metering... */ @@ -1146,7 +1146,7 @@ */ BIT_CLR(priv->prev_key_down, i); priv->prev_key_time[i].tv_sec = priv->prev_key_time[i].tv_usec = 0L; - if(IS_SET(offhook, i)) { + if (IS_SET(offhook, i)) { LINE_DBG(SIGNAL, xpd, i, "OFFHOOK\n"); MARK_ON(priv, i, LED_GREEN); hookstate_changed(xpd, i, 1); @@ -1176,7 +1176,7 @@ #if 0 Is this needed? for_each_line(xpd, i) { - if(IS_SET(sig_toggles, i)) + if (IS_SET(sig_toggles, i)) do_chan_power(xpd->xbus, xpd, BIT(i), 0); // Power down (prevent overheating!!!) } #endif @@ -1194,19 +1194,19 @@ xpp_line_t lines = BIT(info->portnum); /* Map SLIC number into line number */ - for(i = 0; i < ARRAY_SIZE(input_channels); i++) { + for (i = 0; i < ARRAY_SIZE(input_channels); i++) { int channo = input_channels[i]; int newchanno; - if(IS_SET(lines, channo)) { + if (IS_SET(lines, channo)) { newchanno = xpd->channels - LINES_DIGI_INP + i; BIT_CLR(lines, channo); BIT_SET(lines, newchanno); xpd->ringing[newchanno] = 0; // Stop ringing. No leds for digital inputs. - if(offhook && !IS_OFFHOOK(xpd, newchanno)) { // OFFHOOK + if (offhook && !IS_OFFHOOK(xpd, newchanno)) { // OFFHOOK LINE_DBG(SIGNAL, xpd, newchanno, "OFFHOOK\n"); hookstate_changed(xpd, newchanno, 1); - } else if(!offhook && IS_OFFHOOK(xpd, newchanno)) { // ONHOOK + } else if (!offhook && IS_OFFHOOK(xpd, newchanno)) { // ONHOOK LINE_DBG(SIGNAL, xpd, newchanno, "ONHOOK\n"); hookstate_changed(xpd, newchanno, 0); } @@ -1232,14 +1232,14 @@ struct timeval now; int msec = 0; - if(!dtmf_detection) + if (!dtmf_detection) return; - if(!SPAN_REGISTERED(xpd)) + if (!SPAN_REGISTERED(xpd)) return; priv = xpd->priv; val &= 0xF; - if(val <= 0) { - if(key_down) + if (val <= 0) { + if (key_down) XPD_NOTICE(xpd, "Bad DTMF value %d. Ignored\n", val); return; } @@ -1247,15 +1247,15 @@ digit = dtmf_digits[val]; want_mute = IS_SET(priv->want_dtmf_mute, portnum); want_event = IS_SET(priv->want_dtmf_events, portnum); - if(!IS_SET(priv->prev_key_down, portnum) && !key_down) { + if (!IS_SET(priv->prev_key_down, portnum) && !key_down) { LINE_NOTICE(xpd, portnum, "DTMF: duplicate UP (%c)\n", digit); } - if(key_down) + if (key_down) BIT_SET(priv->prev_key_down, portnum); else BIT_CLR(priv->prev_key_down, portnum); do_gettimeofday(&now); - if(priv->prev_key_time[portnum].tv_sec != 0) + if (priv->prev_key_time[portnum].tv_sec != 0) msec = usec_diff(&now, &priv->prev_key_time[portnum]) / 1000; priv->prev_key_time[portnum] = now; LINE_DBG(SIGNAL, xpd, portnum, @@ -1270,11 +1270,11 @@ * we are sure about the logic in Asterisk native bridging. * Meanwhile, simply mute it on button press. */ - if(key_down && want_mute) + if (key_down && want_mute) __do_mute_dtmf(xpd, portnum, 1); else __do_mute_dtmf(xpd, portnum, 0); - if(want_event) { + if (want_event) { int event = (key_down) ? DAHDI_EVENT_DTMFDOWN : DAHDI_EVENT_DTMFUP; dahdi_qevent_lock(XPD_CHAN(xpd, portnum), event | digit); @@ -1296,7 +1296,7 @@ XPD_DBG(REGS, xpd, "%s reg_num=0x%X, dataL=0x%X dataH=0x%X\n", (indirect)?"I":"D", regnum, REG_FIELD(info, data_low), REG_FIELD(info, data_high)); - if(!indirect && regnum == REG_DTMF_DECODE) { + if (!indirect && regnum == REG_DTMF_DECODE) { byte val = REG_FIELD(info, data_low); process_dtmf(xpd, info->portnum, val); @@ -1305,11 +1305,11 @@ /* * Process digital inputs polling results */ - else if(xpd->xbus_idx == 0 && !indirect && regnum == REG_DIGITAL_IOCTRL) { + else if (xpd->xbus_idx == 0 && !indirect && regnum == REG_DIGITAL_IOCTRL) { process_digital_inputs(xpd, info); } #endif - else if(!indirect && regnum == REG_LOOPCLOSURE) { /* OFFHOOK ? */ + else if (!indirect && regnum == REG_LOOPCLOSURE) { /* OFFHOOK ? */ byte val = REG_FIELD(info, data_low); xpp_line_t mask = BIT(info->portnum); xpp_line_t offhook; @@ -1318,7 +1318,7 @@ * Validate reply. Non-existing/disabled ports * will reply with 0xFF. Ignore these. */ - if((val & REG_LOOPCLOSURE_ZERO) == 0) { + if ((val & REG_LOOPCLOSURE_ZERO) == 0) { offhook = (val & REG_LOOPCLOSURE_LCR) ? mask : 0; LINE_DBG(SIGNAL, xpd, info->portnum, "REG_LOOPCLOSURE: dataL=0x%X (offhook=0x%X mask=0x%X\n", @@ -1333,7 +1333,7 @@ #endif } /* Update /proc info only if reply relate to the last slic read request */ - if( + if ( REG_FIELD(&xpd->requested_reply, regnum) == REG_FIELD(info, regnum) && REG_FIELD(&xpd->requested_reply, do_subreg) == REG_FIELD(info, do_subreg) && REG_FIELD(&xpd->requested_reply, subreg) == REG_FIELD(info, subreg)) { @@ -1399,7 +1399,7 @@ int i; int led; - if(!xpd) + if (!xpd) return -ENODEV; spin_lock_irqsave(&xpd->lock, flags); priv = xpd->priv; @@ -1413,9 +1413,9 @@ for_each_line(xpd, i) { char pref; - if(IS_SET(xpd->digital_outputs, i)) + if (IS_SET(xpd->digital_outputs, i)) pref = 'O'; - else if(IS_SET(xpd->digital_inputs, i)) + else if (IS_SET(xpd->digital_inputs, i)) pref = 'I'; else pref = ' '; @@ -1428,21 +1428,21 @@ ); } len += sprintf(page + len, "\n"); - for(led = 0; led < NUM_LEDS; led++) { + for (led = 0; led < NUM_LEDS; led++) { len += sprintf(page + len, "LED #%d", led); len += sprintf(page + len, "\n\t%-17s: ", "ledstate"); for_each_line(xpd, i) { - if(!IS_SET(xpd->digital_outputs, i) && !IS_SET(xpd->digital_inputs, i)) + if (!IS_SET(xpd->digital_outputs, i) && !IS_SET(xpd->digital_inputs, i)) len += sprintf(page + len, "%d ", IS_SET(priv->ledstate[led], i)); } len += sprintf(page + len, "\n\t%-17s: ", "ledcontrol"); for_each_line(xpd, i) { - if(!IS_SET(xpd->digital_outputs, i) && !IS_SET(xpd->digital_inputs, i)) + if (!IS_SET(xpd->digital_outputs, i) && !IS_SET(xpd->digital_inputs, i)) len += sprintf(page + len, "%d ", IS_SET(priv->ledcontrol[led], i)); } len += sprintf(page + len, "\n\t%-17s: ", "led_counter"); for_each_line(xpd, i) { - if(!IS_SET(xpd->digital_outputs, i) && !IS_SET(xpd->digital_inputs, i)) + if (!IS_SET(xpd->digital_outputs, i) && !IS_SET(xpd->digital_inputs, i)) len += sprintf(page + len, "%d ", LED_COUNTER(priv,i,led)); } len += sprintf(page + len, "\n"); @@ -1468,26 +1468,26 @@ int num; int ret; - if(!xpd) + if (!xpd) return -ENODEV; - if(count >= MAX_PROC_WRITE - 1) { + if (count >= MAX_PROC_WRITE - 1) { XPD_ERR(xpd, "Metering string too long (%lu)\n", count); return -EINVAL; } - if(copy_from_user(&buf, buffer, count)) + if (copy_from_user(&buf, buffer, count)) return -EFAULT; buf[count] = '\0'; ret = sscanf(buf, "%d", &num); - if(ret != 1) { + if (ret != 1) { XPD_ERR(xpd, "Metering value should be number. Got '%s'\n", buf); return -EINVAL; } chan = num; - if(chan != PORT_BROADCAST && chan > xpd->channels) { + if (chan != PORT_BROADCAST && chan > xpd->channels) { XPD_ERR(xpd, "Metering tone: bad channel number %d\n", chan); return -EINVAL; } - if((ret = metering_gen(xpd, chan, 1)) < 0) { + if ((ret = metering_gen(xpd, chan, 1)) < 0) { XPD_ERR(xpd, "Failed sending metering tone\n"); return ret; } @@ -1501,7 +1501,7 @@ xpd = dev_to_xpd(dev); /* Is it our device? */ - if(xpd->type != XPD_TYPE_FXS) { + if (xpd->type != XPD_TYPE_FXS) { XPD_ERR(xpd, "drop suggestion for %s (%d)\n", dev_name(dev), xpd->type); return -EINVAL; @@ -1535,7 +1535,7 @@ { int ret; - if((ret = xpd_driver_register(&fxs_driver.driver)) < 0) + if ((ret = xpd_driver_register(&fxs_driver.driver)) < 0) return ret; INFO("revision %s\n", XPP_VERSION); Index: drivers/dahdi/xpp/card_global.c =================================================================== --- drivers/dahdi/xpp/card_global.c (revision 7493) +++ drivers/dahdi/xpp/card_global.c (working copy) @@ -50,7 +50,7 @@ bool do_datah; char datah_str[50]; - if(!xpd) + if (!xpd) return -ENODEV; XPD_NOTICE(xpd, "%s: DEPRECATED: %s[%d] read from /proc interface instead of /sys\n", __FUNCTION__, current->comm, current->tgid); @@ -60,12 +60,12 @@ len += sprintf(page + len, "# Consult firmware docs first\n"); len += sprintf(page + len, "#\n"); do_datah = REG_FIELD(info, do_datah) ? 1 : 0; - if(do_datah) { + if (do_datah) { snprintf(datah_str, ARRAY_SIZE(datah_str), "\t%02X", REG_FIELD(info, data_high)); } else datah_str[0] = '\0'; - if(REG_FIELD(info, do_subreg)) { + if (REG_FIELD(info, do_subreg)) { len += sprintf(page + len, "#CH\tOP\tReg.\tSub\tDL%s\n", (do_datah) ? "\tDH" : ""); len += sprintf(page + len, "%2d\tRS\t%02X\t%02X\t%02X%s\n", @@ -99,7 +99,7 @@ unsigned val; val = simple_strtoul(buf, &endp, 16); - if(*endp != '\0' || val > 0xFF) + if (*endp != '\0' || val > 0xFF) return -EBADR; return (byte)val; } @@ -121,7 +121,7 @@ int ret = -EBADR; num_args = 2; /* port + operation */ - if(argc < num_args) { + if (argc < num_args) { XPD_ERR(xpd, "Not enough arguments (%d)\n", argc); XPD_ERR(xpd, "Any Command is composed of at least %d words (got only %d)\n", @@ -130,24 +130,24 @@ } /* Process the arguments */ argno = 0; - if(strcmp(argv[argno], "*") == 0) { + if (strcmp(argv[argno], "*") == 0) { portno = PORT_BROADCAST; //XPD_DBG(REGS, xpd, "Port broadcast\n"); } else { portno = parse_hexbyte(argv[argno]); - if(portno < 0 || portno >= 8) { + if (portno < 0 || portno >= 8) { XPD_ERR(xpd, "Illegal port number '%s'\n", argv[argno]); goto out; } //XPD_DBG(REGS, xpd, "Port is %d\n", portno); } argno++; - if(strlen(argv[argno]) != 2) { + if (strlen(argv[argno]) != 2) { XPD_ERR(xpd, "Wrong operation codes '%s'\n", argv[argno]); goto out; } op = argv[argno][0]; - switch(op) { + switch (op) { case 'W': writing = 1; num_args++; /* data low */ @@ -162,7 +162,7 @@ goto out; } addr_mode = argv[argno][1]; - switch(addr_mode) { + switch (addr_mode) { case 'I': XPD_NOTICE(xpd, "'I' is deprecated in register commands. Use 'S' instead.\n"); /* fall through */ @@ -178,7 +178,7 @@ break; case 'M': case 'm': - if(op != 'W') { + if (op != 'W') { XPD_ERR(xpd, "Can use Multibyte (%c) only with op 'W'\n", addr_mode); goto out; @@ -190,19 +190,19 @@ XPD_ERR(xpd, "Unkown addressing type '%c'\n", addr_mode); goto out; } - if(argv[argno][2] != '\0') { + if (argv[argno][2] != '\0') { XPD_ERR(xpd, "Bad operation field '%s'\n", argv[argno]); goto out; } - if(argc < num_args) { + if (argc < num_args) { XPD_ERR(xpd, "Command \"%s\" is composed of at least %d words (got only %d)\n", argv[argno], num_args, argc); goto out; } argno++; - if(addr_mode == 'M' || addr_mode == 'm') { - if(argno < argc) { + if (addr_mode == 'M' || addr_mode == 'm') { + if (argno < argc) { XPD_ERR(xpd, "Magic-Multibyte(%c) with %d extra arguments\n", addr_mode, argc - argno); @@ -214,24 +214,24 @@ } /* Normal (non-Magic) register commands */ do_datah = 0; - if(argno >= argc) { + if (argno >= argc) { XPD_ERR(xpd, "Missing register number\n"); goto out; } regnum = parse_hexbyte(argv[argno]); - if(regnum < 0) { + if (regnum < 0) { XPD_ERR(xpd, "Illegal register number '%s'\n", argv[argno]); goto out; } //XPD_DBG(REGS, xpd, "Register is %X\n", regnum); argno++; - if(do_subreg) { - if(argno >= argc) { + if (do_subreg) { + if (argno >= argc) { XPD_ERR(xpd, "Missing subregister number\n"); goto out; } subreg = parse_hexbyte(argv[argno]); - if(subreg < 0) { + if (subreg < 0) { XPD_ERR(xpd, "Illegal subregister number '%s'\n", argv[argno]); goto out; } @@ -239,13 +239,13 @@ argno++; } else subreg = 0; - if(writing) { - if(argno >= argc) { + if (writing) { + if (argno >= argc) { XPD_ERR(xpd, "Missing data low number\n"); goto out; } data_low = parse_hexbyte(argv[argno]); - if(data_low < 0) { + if (data_low < 0) { XPD_ERR(xpd, "Illegal data_low number '%s'\n", argv[argno]); goto out; } @@ -253,14 +253,14 @@ argno++; } else data_low = 0; - if(argno < argc) { + if (argno < argc) { do_datah = 1; - if(!argv[argno]) { + if (!argv[argno]) { XPD_ERR(xpd, "Missing data high number\n"); goto out; } data_high = parse_hexbyte(argv[argno]); - if(data_high < 0) { + if (data_high < 0) { XPD_ERR(xpd, "Illegal data_high number '%s'\n", argv[argno]); goto out; } @@ -268,7 +268,7 @@ argno++; } else data_high = 0; - if(argno < argc) { + if (argno < argc) { XPD_ERR(xpd, "Command contains an extra %d argument\n", argc - argno); @@ -307,22 +307,22 @@ BUG_ON(!xpd); xbus = xpd->xbus; - if(!XBUS_FLAGS(xbus, CONNECTED)) { + if (!XBUS_FLAGS(xbus, CONNECTED)) { XBUS_DBG(GENERAL, xbus, "Dropped packet. Disconnected.\n"); return -EBUSY; } strlcpy(buf, cmdline, MAX_PROC_WRITE); /* Save a copy */ - if(buf[0] == '#' || buf[0] == ';') + if (buf[0] == '#' || buf[0] == ';') XPD_DBG(REGS, xpd, "Note: '%s'\n", buf); - if((p = strchr(buf, '#')) != NULL) /* Truncate comments */ + if ((p = strchr(buf, '#')) != NULL) /* Truncate comments */ *p = '\0'; - if((p = strchr(buf, ';')) != NULL) /* Truncate comments */ + if ((p = strchr(buf, ';')) != NULL) /* Truncate comments */ *p = '\0'; - for(p = buf; *p && (*p == ' ' || *p == '\t'); p++) /* Trim leading whitespace */ + for (p = buf; *p && (*p == ' ' || *p == '\t'); p++) /* Trim leading whitespace */ ; str = p; - for(i = 0; (p = strsep(&str, " \t")) != NULL && i < MAX_ARGS; ) { - if(*p != '\0') { + for (i = 0; (p = strsep(&str, " \t")) != NULL && i < MAX_ARGS; ) { + if (*p != '\0') { argv[i] = p; // XPD_DBG(REGS, xpd, "ARG %d = '%s'\n", i, p); i++; @@ -330,11 +330,11 @@ } argv[i] = NULL; argc = i; - if(p) { + if (p) { XPD_ERR(xpd, "Too many words (%d) to process. Last was '%s'\n", i, p); goto out; } - if(argc) + if (argc) ret = execute_chip_command(xpd, argc, argv); else ret = 0; /* empty command - no op */ @@ -351,30 +351,30 @@ int i; int ret; - if(!xpd) + if (!xpd) return -ENODEV; XPD_NOTICE(xpd, "%s: DEPRECATED: %s[%d] wrote to /proc interface instead of /sys\n", __FUNCTION__, current->comm, current->tgid); - for(i = 0; i < count; /* noop */) { - for(p = buf; p < buf + MAX_PROC_WRITE; p++) { /* read a line */ - if(i >= count) + for (i = 0; i < count; /* noop */) { + for (p = buf; p < buf + MAX_PROC_WRITE; p++) { /* read a line */ + if (i >= count) break; - if(get_user(*p, buffer + i)) + if (get_user(*p, buffer + i)) return -EFAULT; i++; - if(*p == '\n' || *p == '\r') /* whatever */ + if (*p == '\n' || *p == '\r') /* whatever */ break; } - if(p >= buf + MAX_PROC_WRITE) + if (p >= buf + MAX_PROC_WRITE) return -E2BIG; *p = '\0'; ret = parse_chip_command(xpd, buf); - if(ret < 0) { + if (ret < 0) { XPD_NOTICE(xpd, "Failed writing command: '%s'\n", buf); return ret; } /* Don't flood command_queue */ - if(xframe_queue_count(&xpd->xbus->command_queue) > 5) + if (xframe_queue_count(&xpd->xbus->command_queue) > 5) msleep(6); } return count; @@ -384,7 +384,7 @@ { BUG_ON(!xpd); #ifdef CONFIG_PROC_FS - if(xpd->proc_xpd_chipregs) { + if (xpd->proc_xpd_chipregs) { XBUS_DBG(PROC, xbus, "UNIT %d: Removing %s\n", xpd->addr.unit, CHIP_REGISTERS); xpd->proc_xpd_chipregs->data = NULL; remove_proc_entry(CHIP_REGISTERS, xpd->proc_xpd_dir); @@ -398,7 +398,7 @@ #ifdef CONFIG_PROC_FS XBUS_DBG(PROC, xbus, "UNIT %d: Creating %s\n", xpd->addr.unit, CHIP_REGISTERS); xpd->proc_xpd_chipregs = create_proc_entry(CHIP_REGISTERS, 0644, xpd->proc_xpd_dir); - if(!xpd->proc_xpd_chipregs) { + if (!xpd->proc_xpd_chipregs) { XPD_ERR(xpd, "Failed to create proc file '%s'\n", CHIP_REGISTERS); goto err; } @@ -427,7 +427,7 @@ xframe_t *xframe; xpacket_t *pack; - if(!xbus) { + if (!xbus) { DBG(DEVICES, "NO XBUS\n"); return -EINVAL; } @@ -435,7 +435,7 @@ RPACKET_FIELD(pack, GLOBAL, AB_REQUEST, rev) = XPP_PROTOCOL_VERSION; RPACKET_FIELD(pack, GLOBAL, AB_REQUEST, reserved) = 0; XBUS_DBG(DEVICES, xbus, "Protocol Version %d\n", XPP_PROTOCOL_VERSION); - if(xbus_setstate(xbus, XBUS_STATE_SENT_REQUEST)) + if (xbus_setstate(xbus, XBUS_STATE_SENT_REQUEST)) ret = send_cmd_frame(xbus, xframe); return ret; } @@ -449,7 +449,7 @@ xpacket_t *pack; reg_cmd_t *reg_cmd; - if(!xbus) { + if (!xbus) { DBG(REGS, "NO XBUS\n"); return -EINVAL; } @@ -461,7 +461,7 @@ reg_cmd = &RPACKET_FIELD(pack, GLOBAL, REGISTER_REQUEST, reg_cmd); reg_cmd->bytes = sizeof(*reg_cmd) - 1; // do not count the 'bytes' field reg_cmd->is_multibyte = 0; - if(portno == PORT_BROADCAST) { + if (portno == PORT_BROADCAST) { reg_cmd->portnum = 0; REG_FIELD(reg_cmd, all_ports_broadcast) = 1; } else { @@ -477,14 +477,14 @@ REG_FIELD(reg_cmd, do_datah) = do_datah; REG_FIELD(reg_cmd, data_low) = data_low; REG_FIELD(reg_cmd, data_high) = data_high; - if(should_reply) + if (should_reply) xpd->requested_reply = *reg_cmd; - if(debug & DBG_REGS) { + if (debug & DBG_REGS) { dump_reg_cmd("REG_REQ", 1, xbus, xpd->addr.unit, reg_cmd->portnum, reg_cmd); dump_packet("REG_REQ", pack, 1); } - if(!xframe->usec_towait) { /* default processing time of SPI */ - if(subreg) + if (!xframe->usec_towait) { /* default processing time of SPI */ + if (subreg) xframe->usec_towait = 2000; else xframe->usec_towait = 1000; @@ -508,7 +508,7 @@ * eoftx==1: Start sending us D-channel packets. * eoftx==0: Stop sending us D-channel packets. */ - if(len > MULTIBYTE_MAX_LEN) { + if (len > MULTIBYTE_MAX_LEN) { PORT_ERR(xbus, unit, portno, "%s: len=%d is too long. dropping.\n", __FUNCTION__, len); return -EINVAL; } @@ -518,15 +518,15 @@ reg_cmd->is_multibyte = 1; reg_cmd->portnum = portno; reg_cmd->eoframe = eoftx; - if(len > 0) { + if (len > 0) { memcpy(REG_XDATA(reg_cmd), (byte *)buf, len); } else { PORT_DBG(REGS, xbus, unit, portno, "Magic Packet (eoftx=%d)\n", eoftx); } - if(debug & DBG_REGS) + if (debug & DBG_REGS) dump_xframe(__FUNCTION__, xbus, xframe, debug); ret = send_cmd_frame(xbus, xframe); - if(ret < 0) + if (ret < 0) PORT_ERR(xbus, unit, portno, "%s: failed sending xframe\n", __FUNCTION__); return ret; } @@ -541,7 +541,7 @@ const char *mode_name; BUG_ON(!xbus); - if((mode_name = sync_mode_name(mode)) == NULL) { + if ((mode_name = sync_mode_name(mode)) == NULL) { XBUS_ERR(xbus, "SYNC_SOURCE: bad sync_mode=0x%X\n", mode); return -EINVAL; } @@ -587,41 +587,41 @@ units = RPACKET_FIELD(pack, GLOBAL, AB_DESCRIPTION, unit_descriptor); count_units = XPACKET_LEN(pack) - ((byte *)units - (byte *)pack); count_units /= sizeof(*units); - if(rev != XPP_PROTOCOL_VERSION) { + if (rev != XPP_PROTOCOL_VERSION) { XBUS_NOTICE(xbus, "Bad protocol version %d (should be %d)\n", rev, XPP_PROTOCOL_VERSION); ret = -EPROTO; goto proto_err; } - if(count_units > NUM_UNITS) { + if (count_units > NUM_UNITS) { XBUS_NOTICE(xbus, "Too many units %d (should be %d)\n", count_units, NUM_UNITS); ret = -EPROTO; goto proto_err; } - if(count_units <= 0) { + if (count_units <= 0) { XBUS_NOTICE(xbus, "Empty astribank? (%d units)\n", count_units); ret = -EPROTO; goto proto_err; } - if(!xbus_setstate(xbus, XBUS_STATE_RECVD_DESC)) { + if (!xbus_setstate(xbus, XBUS_STATE_RECVD_DESC)) { ret = -EPROTO; goto proto_err; } XBUS_INFO(xbus, "DESCRIPTOR: %d cards, protocol revision %d\n", count_units, rev); xbus->revision = rev; - if(!worker) { + if (!worker) { XBUS_ERR(xbus, "missing worker\n"); ret = -ENODEV; goto err; } - for(i = 0; i < count_units; i++) { + for (i = 0; i < count_units; i++) { struct unit_descriptor *this_unit = &units[i]; struct card_desc_struct *card_desc; unsigned long flags; - if((card_desc = KZALLOC(sizeof(struct card_desc_struct), GFP_ATOMIC)) == NULL) { + if ((card_desc = KZALLOC(sizeof(struct card_desc_struct), GFP_ATOMIC)) == NULL) { XBUS_ERR(xbus, "Card description allocation failed.\n"); ret = -ENOMEM; goto err; @@ -650,7 +650,7 @@ list_add_tail(&card_desc->card_list, &worker->card_list); spin_unlock_irqrestore(&worker->worker_lock, flags); } - if(!xbus_process_worker(xbus)) + if (!xbus_process_worker(xbus)) return -ENODEV; return 0; proto_err: @@ -663,14 +663,14 @@ { reg_cmd_t *reg = &RPACKET_FIELD(pack, GLOBAL, REGISTER_REPLY, regcmd); - if(!xpd) { + if (!xpd) { static int rate_limit; - if((rate_limit++ % 1003) < 5) + if ((rate_limit++ % 1003) < 5) notify_bad_xpd(__FUNCTION__, xbus, XPACKET_ADDR(pack), ""); return -EPROTO; } - if(debug & DBG_REGS) { + if (debug & DBG_REGS) { dump_reg_cmd("REG_REPLY", 0, xbus, xpd->addr.unit, reg->portnum, reg); dump_packet("REG_REPLY", pack, 1); } @@ -684,7 +684,7 @@ const char *mode_name; BUG_ON(!xbus); - if((mode_name = sync_mode_name(mode)) == NULL) { + if ((mode_name = sync_mode_name(mode)) == NULL) { XBUS_ERR(xbus, "SYNC_REPLY: bad sync_mode=0x%X\n", mode); return -EINVAL; } @@ -704,11 +704,11 @@ byte errorbits; BUG_ON(!xbus); - if((rate_limit++ % 5003) > 200) + if ((rate_limit++ % 5003) > 200) return 0; category_code = RPACKET_FIELD(pack, GLOBAL, ERROR_CODE, category_code); errorbits = RPACKET_FIELD(pack, GLOBAL, ERROR_CODE, errorbits); - if(!xpd) { + if (!xpd) { snprintf(tmp_name, TMP_NAME_LEN, "%s(%1d%1d)", xbus->busname, XPACKET_ADDR_UNIT(pack), XPACKET_ADDR_SUBUNIT(pack)); } else { @@ -790,19 +790,19 @@ BUG_ON(!xpd); xbus = xpd->xbus; - if(!initdir || !initdir[0]) { + if (!initdir || !initdir[0]) { XPD_NOTICE(xpd, "Missing initdir parameter\n"); return -EINVAL; } - if(!xpd_setstate(xpd, XPD_STATE_INIT_REGS)) { + if (!xpd_setstate(xpd, XPD_STATE_INIT_REGS)) { ret = -EINVAL; goto err; } direction_mask = 0; - for(i = 0; i < xpd->subunits; i++) { + for (i = 0; i < xpd->subunits; i++) { xpd_t *su = xpd_byaddr(xbus, xpd->addr.unit, i); - if(!su) { + if (!su) { XPD_ERR(xpd, "Have %d subunits, but not subunit #%d\n", xpd->subunits, i); @@ -819,13 +819,13 @@ snprintf(revstr, MAX_ENV_STR, "XBUS_REVISION=%d", xbus->revision); snprintf(connectorstr, MAX_ENV_STR, "XBUS_CONNECTOR=%s", xbus->connector); snprintf(xbuslabel, MAX_ENV_STR, "XBUS_LABEL=%s", xbus->label); - if(snprintf(init_card, MAX_PATH_STR, "%s/init_card_%d_%d", + if (snprintf(init_card, MAX_PATH_STR, "%s/init_card_%d_%d", initdir, xpd->type, xbus->revision) > MAX_PATH_STR) { XPD_NOTICE(xpd, "Cannot initialize. pathname is longer than %d characters.\n", MAX_PATH_STR); ret = -E2BIG; goto err; } - if(!XBUS_IS(xbus, RECVD_DESC)) { + if (!XBUS_IS(xbus, RECVD_DESC)) { XBUS_ERR(xbus, "Skipped register initialization. In state %s.\n", xbus_statename(XBUS_STATE(xbus))); ret = -ENODEV; @@ -837,15 +837,15 @@ /* * Carefully report results */ - if(ret == 0) + if (ret == 0) XPD_DBG(DEVICES, xpd, "'%s' finished OK\n", init_card); - else if(ret < 0) { + else if (ret < 0) { XPD_ERR(xpd, "Failed running '%s' (errno %d)\n", init_card, ret); } else { byte exitval = ((unsigned)ret >> 8) & 0xFF; byte sigval = ret & 0xFF; - if(!exitval) { + if (!exitval) { XPD_ERR(xpd, "'%s' killed by signal %d\n", init_card, sigval); } else { XPD_ERR(xpd, "'%s' aborted with exitval %d\n", init_card, exitval); Index: drivers/dahdi/xpp/card_pri.c =================================================================== --- drivers/dahdi/xpp/card_pri.c (revision 7493) +++ drivers/dahdi/xpp/card_pri.c (working copy) @@ -58,11 +58,11 @@ static bool is_sigtype_dchan(int sigtype) { - if((sigtype & DAHDI_SIG_HDLCRAW) == DAHDI_SIG_HDLCRAW) + if ((sigtype & DAHDI_SIG_HDLCRAW) == DAHDI_SIG_HDLCRAW) return 1; - if((sigtype & DAHDI_SIG_HDLCFCS) == DAHDI_SIG_HDLCFCS) + if ((sigtype & DAHDI_SIG_HDLCFCS) == DAHDI_SIG_HDLCFCS) return 1; - if((sigtype & DAHDI_SIG_HARDHDLC) == DAHDI_SIG_HARDHDLC) + if ((sigtype & DAHDI_SIG_HARDHDLC) == DAHDI_SIG_HARDHDLC) return 1; return 0; } @@ -326,7 +326,7 @@ #define NO_DCHAN (0) #define DCHAN(p) ((p)->chanconfig_dchan) #define VALID_DCHAN(p) (DCHAN(p) != NO_DCHAN) -#define SET_DCHAN(p,d) do { DCHAN(p) = (d); } while(0); +#define SET_DCHAN(p,d) do { DCHAN(p) = (d); } while (0); byte cas_rs_e[NUM_CAS_RS]; byte cas_ts_e[NUM_CAS_RS]; @@ -429,7 +429,7 @@ priv = xpd->priv; XPD_DBG(PROC, xpd, "\n"); #ifdef CONFIG_PROC_FS - if(priv->pri_info) { + if (priv->pri_info) { XPD_DBG(PROC, xpd, "Removing xpd PRI_INFO file\n"); remove_proc_entry(PROC_PRI_INFO_FNAME, xpd->proc_xpd_dir); } @@ -448,7 +448,7 @@ #ifdef CONFIG_PROC_FS XPD_DBG(PROC, xpd, "Creating PRI_INFO file\n"); priv->pri_info = create_proc_entry(PROC_PRI_INFO_FNAME, 0644, xpd->proc_xpd_dir); - if(!priv->pri_info) { + if (!priv->pri_info) { XPD_ERR(xpd, "Failed to create proc '%s'\n", PROC_PRI_INFO_FNAME); goto err; } @@ -470,7 +470,7 @@ BUG_ON(!xpd); priv = xpd->priv; - if( + if ( priv->pri_protocol != PRI_PROTO_E1 && priv->pri_protocol != PRI_PROTO_T1 && priv->pri_protocol != PRI_PROTO_J1) @@ -487,8 +487,8 @@ unsigned long flags; priv = xpd->priv; - if(priv->is_cas) { - if(priv->pri_protocol == PRI_PROTO_E1) { + if (priv->is_cas) { + if (priv->pri_protocol == PRI_PROTO_E1) { /* CAS: Don't send PCM to D-Channel */ channels--; mask &= ~BIT(PRI_DCHAN_IDX(priv)); @@ -515,13 +515,13 @@ BUG_ON(!xpd); priv = xpd->priv; - if(SPAN_REGISTERED(xpd)) { + if (SPAN_REGISTERED(xpd)) { XPD_NOTICE(xpd, "Registered as span %d. Cannot do setup pri protocol (%s)\n", xpd->span.spanno, __FUNCTION__); return -EBUSY; } - if(priv->pri_protocol != PRI_PROTO_0) { - if(priv->pri_protocol == set_proto) { + if (priv->pri_protocol != PRI_PROTO_0) { + if (priv->pri_protocol == set_proto) { XPD_NOTICE(xpd, "Already in protocol %s. Ignored\n", pri_protocol_name(set_proto)); return 0; } else { @@ -530,7 +530,7 @@ pri_protocol_name(set_proto)); } } - switch(set_proto) { + switch (set_proto) { case PRI_PROTO_E1: deflaw = DAHDI_LAW_ALAW; dchan_num = 16; @@ -574,7 +574,7 @@ * give reliable results. */ ret = pri_lineconfig(xpd, default_lineconfig); - if(ret) { + if (ret) { XPD_NOTICE(xpd, "Failed setting PRI default line config\n"); return ret; } @@ -588,24 +588,24 @@ int best_spanno = 0; int i; - if(!SPAN_REGISTERED(xpd)) + if (!SPAN_REGISTERED(xpd)) return; - for(i = 0; i < MAX_SLAVES; i++) { + for (i = 0; i < MAX_SLAVES; i++) { subxpd = xpd_byaddr(xpd->xbus, xpd->addr.unit, i); - if(!subxpd) + if (!subxpd) continue; priv = subxpd->priv; - if(priv->clock_source && priv->alarms == 0) { - if(best_spanno) + if (priv->clock_source && priv->alarms == 0) { + if (best_spanno) XPD_ERR(xpd, "Duplicate XPD's with clock_source=1\n"); best_spanno = subxpd->span.spanno; } } - for(i = 0; i < MAX_SLAVES; i++) { + for (i = 0; i < MAX_SLAVES; i++) { subxpd = xpd_byaddr(xpd->xbus, xpd->addr.unit, i); - if(!subxpd) + if (!subxpd) continue; - if(subxpd->span.syncsrc == best_spanno) + if (subxpd->span.syncsrc == best_spanno) XPD_DBG(SYNC, xpd, "Setting SyncSource to span %d\n", best_spanno); else XPD_DBG(SYNC, xpd, "Slaving to span %d\n", best_spanno); @@ -630,27 +630,27 @@ xbus = xpd->xbus; /* Find subunit with best timing priority */ - for(i = 0; i < MAX_SLAVES; i++) { + for (i = 0; i < MAX_SLAVES; i++) { struct PRI_priv_data *priv; xpd_t *subxpd; subxpd = xpd_byaddr(xbus, xpd->addr.unit, i); - if(!subxpd) + if (!subxpd) continue; priv = subxpd->priv; - if(priv->alarms != 0) + if (priv->alarms != 0) continue; - if(subxpd->timing_priority > 0 && subxpd->timing_priority < best_subunit_prio) { + if (subxpd->timing_priority > 0 && subxpd->timing_priority < best_subunit_prio) { best_xpd = subxpd; best_subunit = i; best_subunit_prio = subxpd->timing_priority; } } /* Now set it */ - if(best_xpd && ((struct PRI_priv_data *)(best_xpd->priv))->clock_source == 0) { + if (best_xpd && ((struct PRI_priv_data *)(best_xpd->priv))->clock_source == 0) { byte reg_pc_init[] = { VAL_PC_GPI, VAL_PC_GPI, VAL_PC_GPI }; - for(i = 0; i < ARRAY_SIZE(reg_pc_init); i++) { + for (i = 0; i < ARRAY_SIZE(reg_pc_init); i++) { byte reg_pc = reg_pc_init[i]; reg_pc |= (best_subunit & (1 << i)) ? VAL_PC_GPOH : VAL_PC_GPOL; @@ -661,12 +661,12 @@ ((struct PRI_priv_data *)(best_xpd->priv))->clock_source = 1; } /* clear old clock sources */ - for(i = 0; i < MAX_SLAVES; i++) { + for (i = 0; i < MAX_SLAVES; i++) { struct PRI_priv_data *priv; xpd_t *subxpd; subxpd = xpd_byaddr(xbus, xpd->addr.unit, i); - if(subxpd && subxpd != best_xpd) { + if (subxpd && subxpd != best_xpd) { XPD_DBG(SYNC, subxpd, "Clearing clock source\n"); priv = subxpd->priv; priv->clock_source = 0; @@ -688,7 +688,7 @@ is_master_mode = xpd->timing_priority == 0; localloop = priv->local_loopback; lim0 |= (localloop) ? REG_LIM0_LL : 0; - if(is_master_mode) + if (is_master_mode) lim0 |= REG_LIM0_MAS; else lim0 &= ~REG_LIM0_MAS; @@ -723,7 +723,7 @@ BUG_ON(!xpd); priv = xpd->priv; - if(SPAN_REGISTERED(xpd)) { + if (SPAN_REGISTERED(xpd)) { XPD_NOTICE(xpd, "Registered as span %d. Cannot do %s\n", xpd->span.spanno, __FUNCTION__); return -EBUSY; @@ -770,7 +770,7 @@ for_each_line(xpd, i) { struct dahdi_chan *chan = XPD_CHAN(xpd, i); - if(chan->flags & DAHDI_FLAG_CLEAR) + if (chan->flags & DAHDI_FLAG_CLEAR) BIT_CLR(new_rbslines, i); else BIT_SET(new_rbslines, i); @@ -779,7 +779,7 @@ modified_lines = priv->rbslines ^ new_rbslines; XPD_DBG(DEVICES, xpd, "RBSLINES-%d(%s): 0x%X\n", channo, pri_protocol_name(priv->pri_protocol), new_rbslines); - if((priv->pri_protocol == PRI_PROTO_T1) || (priv->pri_protocol == PRI_PROTO_J1)) { + if ((priv->pri_protocol == PRI_PROTO_T1) || (priv->pri_protocol == PRI_PROTO_J1)) { byte clear_lines = 0; /* Mark clear lines */ bool reg_changed = 0; @@ -787,13 +787,13 @@ int bytenum = i / 8; int bitnum = i % 8; - if(!IS_SET(new_rbslines, i)) { + if (!IS_SET(new_rbslines, i)) { BIT_SET(clear_lines, (7 - bitnum)); } - if(IS_SET(modified_lines, i)) + if (IS_SET(modified_lines, i)) reg_changed = 1; - if(bitnum == 7) { - if(channo == 0 || reg_changed) { + if (bitnum == 7) { + if (channo == 0 || reg_changed) { bytenum += REG_CCB1_T; XPD_DBG(DEVICES, xpd, "RBS(%s): modified=0x%X rbslines=0x%X reg=0x%X clear_lines=0x%X\n", pri_protocol_name(priv->pri_protocol), @@ -814,7 +814,7 @@ priv = xpd->priv; XPD_INFO(xpd, "Setting TDM to %s\n", (want_cas) ? "CAS" : "PRI"); - if(want_cas) { + if (want_cas) { priv->is_cas = 1; priv->dchan_alive = 0; } else { @@ -850,11 +850,11 @@ */ bad_bits = lineconfig & pri_linecompat(priv->pri_protocol); bad_bits = bad_bits ^ lineconfig; - for(i = 0; i < ARRAY_SIZE(valid_spanconfigs); i++) { + for (i = 0; i < ARRAY_SIZE(valid_spanconfigs); i++) { unsigned int flags = valid_spanconfigs[i].flags; - if(bad_bits & BIT(i)) { - if(flags) { + if (bad_bits & BIT(i)) { + if (flags) { XPD_ERR(xpd, "Bad config item '%s' for %s. Ignore\n", valid_spanconfigs[i].name, @@ -867,26 +867,26 @@ pri_protocol_name(priv->pri_protocol)); } } - if(flags && flags != BIT(i)) { + if (flags && flags != BIT(i)) { ERR("%s: BUG: i=%d flags=0x%X\n", __FUNCTION__, i, flags); // BUG(); } } - if(bad_bits) + if (bad_bits) goto bad_lineconfig; - if(priv->pri_protocol == PRI_PROTO_E1) { + if (priv->pri_protocol == PRI_PROTO_E1) { fmr1 |= REG_FMR1_AFR; fmr2 = REG_FMR2_E_AXRA | REG_FMR2_E_ALMF; /* 0x03 */ fmr4 = 0x9F; /* E1.XSW: All spare bits = 1*/ xsp |= REG_XSP_E_EBP | REG_XSP_E_AXS | REG_XSP_E_XSIF; - } else if(priv->pri_protocol == PRI_PROTO_T1) { + } else if (priv->pri_protocol == PRI_PROTO_T1) { fmr1 |= REG_FMR1_PMOD | REG_FMR1_T_CRC; fmr2 = REG_FMR2_T_SSP | REG_FMR2_T_AXRA; /* 0x22 */ fmr4 = 0x0C; xsp &= ~REG_FMR5_T_XTM; force_cas = 1; /* T1 - Chip always in CAS mode */ - } else if(priv->pri_protocol == PRI_PROTO_J1) { + } else if (priv->pri_protocol == PRI_PROTO_J1) { fmr1 |= REG_FMR1_PMOD; fmr4 = 0x1C; xsp &= ~REG_FMR5_T_XTM; @@ -894,7 +894,7 @@ XPD_ERR(xpd, "J1 unsupported yet\n"); return -ENOSYS; } - if(priv->local_loopback) + if (priv->local_loopback) fmr2 |= REG_FMR2_E_PLB; /* framing first */ if (lineconfig & DAHDI_CONFIG_B8ZS) { @@ -915,7 +915,7 @@ * configure the Rx side to B8ZS coding" * For both cases this is the same bit in FMR0 */ - if(priv->pri_protocol == PRI_PROTO_J1) + if (priv->pri_protocol == PRI_PROTO_J1) XPD_NOTICE(xpd, "J1 is not supported yet\n"); else fmr0 |= REG_FMR0_E_RC0; @@ -969,19 +969,19 @@ write_subunit(xpd, REG_FMR0, fmr0); XPD_DBG(GENERAL, xpd, "%s: fmr4(0x%02X) = 0x%02X\n", __FUNCTION__, REG_FMR4, fmr4); write_subunit(xpd, REG_FMR4, fmr4); - if(fmr3) { + if (fmr3) { XPD_DBG(GENERAL, xpd, "%s: fmr3(0x%02X) = 0x%02X\n", __FUNCTION__, REG_FMR3, fmr3); write_subunit(xpd, REG_FMR3, fmr3); } XPD_DBG(GENERAL, xpd, "%s: cmdr(0x%02X) = 0x%02X\n", __FUNCTION__, REG_CMDR_E, cmdr); write_subunit(xpd, REG_CMDR_E, cmdr); #ifdef JAPANEZE_SUPPORT - if(rc0) { + if (rc0) { XPD_DBG(GENERAL, xpd, "%s: rc0(0x%02X) = 0x%02X\n", __FUNCTION__, REG_RC0, rc0); write_subunit(xpd, REG_RC0, rc0); } #endif - if(force_cas) { + if (force_cas) { xsp |= REG_XSP_E_CASEN; /* Same as REG_FMR5_T_EIBR for T1 */ } XPD_DBG(GENERAL, xpd, "%s: xsp(0x%02X) = 0x%02X\n", __FUNCTION__, REG_XSP_E, xsp); @@ -1004,7 +1004,7 @@ BUG_ON(!xpd); priv = xpd->priv; - if(lc->span != xpd->span.spanno) { + if (lc->span != xpd->span.spanno) { XPD_ERR(xpd, "I am span %d but got spanconfig for span %d\n", xpd->span.spanno, lc->span); return -EINVAL; @@ -1016,7 +1016,7 @@ XPD_DBG(GENERAL, xpd, "[%s] lbo=%d lineconfig=0x%X sync=%d\n", (priv->clock_source)?"MASTER":"SLAVE", lc->lbo, lc->lineconfig, lc->sync); ret = pri_lineconfig(xpd, lc->lineconfig); - if(!ret) { + if (!ret) { span->lineconfig = lc->lineconfig; xpd->timing_priority = lc->sync; set_master_mode("spanconfig", xpd); @@ -1044,8 +1044,8 @@ * FIXME: actually use this to prevent duplicate DChan definitions * and prevent DChan definitions with CAS. */ - if(is_sigtype_dchan(sigtype)) { - if(VALID_DCHAN(priv) && DCHAN(priv) != chan->channo) { + if (is_sigtype_dchan(sigtype)) { + if (VALID_DCHAN(priv) && DCHAN(priv) != chan->channo) { ERR("channel %d (%s) marked DChan but also channel %d.\n", chan->channo, chan->name, DCHAN(priv)); return -EINVAL; @@ -1053,19 +1053,19 @@ XPD_DBG(GENERAL, xpd, "channel %d (%s) marked as DChan\n", chan->channo, chan->name); SET_DCHAN(priv, chan->channo); /* In T1, we don't know before-hand */ - if(priv->pri_protocol != PRI_PROTO_E1 && priv->is_cas != 0) + if (priv->pri_protocol != PRI_PROTO_E1 && priv->is_cas != 0) set_mode_cas(xpd, 0); } } else { - if(chan->channo == 1) { + if (chan->channo == 1) { XPD_DBG(GENERAL, xpd, "channel %d (%s) marked a not DChan\n", chan->channo, chan->name); SET_DCHAN(priv, NO_DCHAN); } /* In T1, we don't know before-hand */ - if(priv->pri_protocol != PRI_PROTO_E1 && priv->is_cas != 1) + if (priv->pri_protocol != PRI_PROTO_E1 && priv->is_cas != 1) set_mode_cas(xpd, 1); } - if(xpd->span.flags & DAHDI_FLAG_RUNNING) { + if (xpd->span.flags & DAHDI_FLAG_RUNNING) { XPD_DBG(DEVICES, xpd, "Span is RUNNING. Updating rbslines.\n"); set_rbslines(xpd, chan->channo); } @@ -1082,20 +1082,20 @@ struct PRI_priv_data *priv; int channels = min(31, CHANNELS_PERXPD); /* worst case */ - if(subunit_ports != 1) { + if (subunit_ports != 1) { XBUS_ERR(xbus, "Bad subunit_ports=%d\n", subunit_ports); return NULL; } XBUS_DBG(GENERAL, xbus, "\n"); xpd = xpd_alloc(xbus, unit, subunit, subtype, subunits, sizeof(struct PRI_priv_data), proto_table, channels); - if(!xpd) + if (!xpd) return NULL; priv = xpd->priv; priv->pri_protocol = PRI_PROTO_0; /* Default, changes in set_pri_proto() */ priv->deflaw = DAHDI_LAW_DEFAULT; /* Default, changes in set_pri_proto() */ xpd->type_name = type_name(priv->pri_protocol); #ifdef OLD_PROC - if(pri_proc_create(xbus, xpd) < 0) { + if (pri_proc_create(xbus, xpd) < 0) { xpd_free(xpd); return NULL; } @@ -1114,13 +1114,13 @@ xpd->type = XPD_TYPE_PRI; proto_table = &PROTO_TABLE(PRI); priv = xpd->priv; - if(priv->pri_protocol == PRI_PROTO_0) { + if (priv->pri_protocol == PRI_PROTO_0) { /* * init_card_* script didn't set pri protocol * Let's have a default E1 */ ret = set_pri_proto(xpd, PRI_PROTO_E1); - if(ret < 0) + if (ret < 0) goto err; } SET_DCHAN(priv, NO_DCHAN); @@ -1128,7 +1128,7 @@ * initialization script should have set correct * operating modes. */ - if(!valid_pri_modes(xpd)) { + if (!valid_pri_modes(xpd)) { XPD_NOTICE(xpd, "PRI protocol not set\n"); goto err; } @@ -1137,7 +1137,7 @@ XPD_DBG(DEVICES, xpd, "%s\n", xpd->type_name); xpd->timing_priority = 1; /* High priority SLAVE */ set_master_mode(__FUNCTION__, xpd); - for(ret = 0; ret < NUM_LEDS; ret++) { + for (ret = 0; ret < NUM_LEDS; ret++) { DO_LED(xpd, ret, PRI_LED_ON); msleep(20); DO_LED(xpd, ret, PRI_LED_OFF); @@ -1180,7 +1180,7 @@ pri_protocol_name(priv->pri_protocol), xpd->channels, priv->deflaw); - if(!on) { + if (!on) { /* Nothing to do yet */ return 0; } @@ -1199,12 +1199,12 @@ cur_chan->chanpos = i + 1; cur_chan->pvt = xpd; cur_chan->sigcap = PRI_SIGCAP; - if(is_dchan && !priv->is_cas) { /* D-CHAN */ + if (is_dchan && !priv->is_cas) { /* D-CHAN */ //FIXME: cur_chan->flags |= DAHDI_FLAG_PRIDCHAN; cur_chan->flags &= ~DAHDI_FLAG_HDLC; } } - if(!priv->is_cas) + if (!priv->is_cas) clear_bit(DAHDI_FLAGBIT_RBS, &xpd->span.flags); xpd->offhook_state = xpd->wanted_pcm_mask; xpd->span.spanconfig = pri_spanconfig; @@ -1236,20 +1236,20 @@ BUG_ON(!xpd); priv = xpd->priv; BUG_ON(!priv); - if(priv->is_cas) { + if (priv->is_cas) { return; } - if(priv->dchan_alive == up) + if (priv->dchan_alive == up) return; - if(!priv->layer1_up) /* No layer1, kill dchan */ + if (!priv->layer1_up) /* No layer1, kill dchan */ up = 0; - if(up) { + if (up) { XPD_DBG(SIGNAL, xpd, "STATE CHANGE: D-Channel RUNNING\n"); priv->dchan_alive = 1; } else { int d = PRI_DCHAN_IDX(priv); - if(SPAN_REGISTERED(xpd) && d >= 0 && d < xpd->channels) { + if (SPAN_REGISTERED(xpd) && d >= 0 && d < xpd->channels) { byte *pcm; pcm = (byte *)XPD_CHAN(xpd, d)->readchunk; @@ -1283,7 +1283,7 @@ BUG_ON(!xpd); priv = xpd->priv; BUG_ON(!priv); - if(xpd->timing_priority == 0) { + if (xpd->timing_priority == 0) { which_led = TOP_RED_LED; other_led = BOTTOM_GREEN_LED; } else { @@ -1292,10 +1292,10 @@ } ledstate = priv->ledstate[which_led]; timer_count = xpd->timer_count; - if(xpd->blink_mode) { - if((timer_count % DEFAULT_LED_PERIOD) == 0) { + if (xpd->blink_mode) { + if ((timer_count % DEFAULT_LED_PERIOD) == 0) { // led state is toggled - if(ledstate == PRI_LED_OFF) { + if (ledstate == PRI_LED_OFF) { DO_LED(xpd, which_led, PRI_LED_ON); DO_LED(xpd, other_led, PRI_LED_ON); } else { @@ -1305,11 +1305,11 @@ } return; } - if(priv->ledstate[other_led] != PRI_LED_OFF) + if (priv->ledstate[other_led] != PRI_LED_OFF) DO_LED(xpd, other_led, PRI_LED_OFF); - if(priv->dchan_alive) { + if (priv->dchan_alive) { mod = timer_count % 1000; - switch(mod) { + switch (mod) { case 0: DO_LED(xpd, which_led, PRI_LED_ON); break; @@ -1317,9 +1317,9 @@ DO_LED(xpd, which_led, PRI_LED_OFF); break; } - } else if(priv->layer1_up) { + } else if (priv->layer1_up) { mod = timer_count % 1000; - switch(mod) { + switch (mod) { case 0: case 100: DO_LED(xpd, which_led, PRI_LED_ON); @@ -1330,7 +1330,7 @@ break; } } else { - if(priv->ledstate[which_led] != PRI_LED_ON) + if (priv->ledstate[which_led] != PRI_LED_ON) DO_LED(xpd, which_led, PRI_LED_ON); } } @@ -1342,18 +1342,18 @@ BUG_ON(!xpd); priv = xpd->priv; BUG_ON(!priv); - if(!priv->initialized || !xbus->self_ticking) + if (!priv->initialized || !xbus->self_ticking) return 0; /* * Poll layer1 status (cascade subunits) */ - if(poll_interval != 0 && + if (poll_interval != 0 && ((xpd->timer_count % poll_interval) == 0)) { priv->poll_noreplies++; query_subunit(xpd, REG_FRS0); //query_subunit(xpd, REG_FRS1); } - if(priv->dchan_tx_counter >= 1 && priv->dchan_rx_counter > 1) { + if (priv->dchan_tx_counter >= 1 && priv->dchan_rx_counter > 1) { dchan_state(xpd, 1); priv->dchan_alive_ticks++; } @@ -1364,7 +1364,7 @@ static int PRI_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long arg) { BUG_ON(!xpd); - if(!XBUS_IS(xpd->xbus, READY)) + if (!XBUS_IS(xpd->xbus, READY)) return -ENODEV; switch (cmd) { case DAHDI_TONEDETECT: @@ -1401,7 +1401,7 @@ BUG_ON(!xpd); priv = xpd->priv; BUG_ON(!priv); - if(!XBUS_IS(xpd->xbus, READY)) { + if (!XBUS_IS(xpd->xbus, READY)) { XPD_DBG(GENERAL, xpd, "Startup called by dahdi. No Hardware. Ignored\n"); return -ENODEV; } @@ -1423,7 +1423,7 @@ BUG_ON(!xpd); priv = xpd->priv; BUG_ON(!priv); - if(!XBUS_IS(xpd->xbus, READY)) { + if (!XBUS_IS(xpd->xbus, READY)) { XPD_DBG(GENERAL, xpd, "Shutdown called by dahdi. No Hardware. Ignored\n"); return -ENODEV; } @@ -1446,14 +1446,14 @@ priv = xpd->priv; BUG_ON(!priv); BUG_ON(priv->pri_protocol != PRI_PROTO_E1); - if(pos == 15) + if (pos == 15) return 0; /* Don't write dchan in CAS */ - if(pos < 0 || pos > 31) { + if (pos < 0 || pos > 31) { XPD_NOTICE(xpd, "%s: pos=%d out of range. Ignore\n", __FUNCTION__, pos); return 0; } spin_lock_irqsave(&xpd->lock, flags); - if(pos >= 16) { + if (pos >= 16) { /* Low nibble */ reg_pos = pos - 16; val = (priv->cas_ts_e[reg_pos] & 0xF0) | (bits & 0x0F); @@ -1485,7 +1485,7 @@ priv = xpd->priv; BUG_ON(!priv); BUG_ON(priv->pri_protocol != PRI_PROTO_T1); - if(pos < 0 || pos >= xpd->channels) { + if (pos < 0 || pos >= xpd->channels) { XPD_ERR(xpd, "%s: Bad pos=%d\n", __FUNCTION__, pos); return 0; } @@ -1498,7 +1498,7 @@ tx_bits >>= 2; tx_bits &= BITMASK(width); tx_bits <<= (chan_per_reg - offset - 1) * width; - if((priv->cas_ts_e[rsnum] & mask) == tx_bits) { + if ((priv->cas_ts_e[rsnum] & mask) == tx_bits) { #if 0 LINE_DBG(SIGNAL, xpd, pos, "RBS: TX: RS%02d(0x%02X, 0x%02X): REPEAT 0x%02X\n", rsnum+1, mask, tx_bits, bits); @@ -1532,10 +1532,10 @@ pos = chan->chanpos - 1; priv = xpd->priv; BUG_ON(!priv); - if(!priv->layer1_up) { + if (!priv->layer1_up) { XPD_DBG(SIGNAL, xpd, "RBS: TX: No layer1. Ignore.\n"); } - if(!priv->is_cas) { + if (!priv->is_cas) { XPD_NOTICE(xpd, "RBS: TX: not in CAS mode. Ignore.\n"); return 0; } @@ -1545,11 +1545,11 @@ sig2str(chan->sig), bits); return 0; } - if(priv->pri_protocol == PRI_PROTO_E1) { - if(encode_rbsbits_e1(xpd, pos, bits) < 0) + if (priv->pri_protocol == PRI_PROTO_E1) { + if (encode_rbsbits_e1(xpd, pos, bits) < 0) return -EINVAL; - } else if(priv->pri_protocol == PRI_PROTO_T1) { - if(encode_rbsbits_t1(xpd, pos, bits) < 0) + } else if (priv->pri_protocol == PRI_PROTO_T1) { + if (encode_rbsbits_t1(xpd, pos, bits) < 0) return -EINVAL; } else { XPD_NOTICE(xpd, "%s: protocol %s is not supported yet with CAS\n", @@ -1592,33 +1592,33 @@ for_each_line(xpd, i) { struct dahdi_chan *chan = XPD_CHAN(xpd, i); - if(priv->pri_protocol == PRI_PROTO_E1) { + if (priv->pri_protocol == PRI_PROTO_E1) { /* In E1 - Only 0'th channel is unused */ - if(i == 0) { + if (i == 0) { physical_chan++; } - } else if(priv->pri_protocol == PRI_PROTO_T1) { + } else if (priv->pri_protocol == PRI_PROTO_T1) { /* In T1 - Every 4'th channel is unused */ - if((i % 3) == 0) { + if ((i % 3) == 0) { physical_chan++; } } - if(IS_SET(wanted_lines, i)) { + if (IS_SET(wanted_lines, i)) { physical_mask |= BIT(physical_chan); - if(SPAN_REGISTERED(xpd)) { + if (SPAN_REGISTERED(xpd)) { #ifdef DEBUG_PCMTX int channo = XPD_CHAN(xpd, i)->channo; - if(pcmtx >= 0 && pcmtx_chan == channo) + if (pcmtx >= 0 && pcmtx_chan == channo) memset((u_char *)pcm, pcmtx, DAHDI_CHUNKSIZE); else #endif memcpy((u_char *)pcm, chan->writechunk, DAHDI_CHUNKSIZE); - if(i == PRI_DCHAN_IDX(priv)) { - if(priv->dchan_tx_sample != chan->writechunk[0]) { + if (i == PRI_DCHAN_IDX(priv)) { + if (priv->dchan_tx_sample != chan->writechunk[0]) { priv->dchan_tx_sample = chan->writechunk[0]; priv->dchan_tx_counter++; - } else if(chan->writechunk[0] == 0xFF) + } else if (chan->writechunk[0] == 0xFF) dchan_state(xpd, 0); else chan->writechunk[0] = 0xFF; /* Clobber for next tick */ @@ -1653,7 +1653,7 @@ int i; int logical_chan; - if(!SPAN_REGISTERED(xpd)) + if (!SPAN_REGISTERED(xpd)) return; priv = xpd->priv; BUG_ON(!priv); @@ -1664,28 +1664,28 @@ for (i = 0; i < CHANNELS_PERXPD; i++) { volatile u_char *r; - if(priv->pri_protocol == PRI_PROTO_E1) { + if (priv->pri_protocol == PRI_PROTO_E1) { /* In E1 - Only 0'th channel is unused */ - if(i == 0) + if (i == 0) continue; - } else if(priv->pri_protocol == PRI_PROTO_T1) { + } else if (priv->pri_protocol == PRI_PROTO_T1) { /* In T1 - Every 4'th channel is unused */ - if((i % 4) == 0) + if ((i % 4) == 0) continue; } - if(logical_chan == PRI_DCHAN_IDX(priv) && !priv->is_cas) { - if(priv->dchan_rx_sample != pcm[0]) { - if(debug & DBG_PCM) { + if (logical_chan == PRI_DCHAN_IDX(priv) && !priv->is_cas) { + if (priv->dchan_rx_sample != pcm[0]) { + if (debug & DBG_PCM) { XPD_INFO(xpd, "RX-D-Chan: prev=0x%X now=0x%X\n", priv->dchan_rx_sample, pcm[0]); dump_packet("RX-D-Chan", pack, 1); } priv->dchan_rx_sample = pcm[0]; priv->dchan_rx_counter++; - } else if(pcm[0] == 0xFF) + } else if (pcm[0] == 0xFF) dchan_state(xpd, 0); } - if(IS_SET(physical_mask, i)) { + if (IS_SET(physical_mask, i)) { r = XPD_CHAN(xpd, logical_chan)->readchunk; // memset((u_char *)r, 0x5A, DAHDI_CHUNKSIZE); // DEBUG memcpy((u_char *)r, pcm, DAHDI_CHUNKSIZE); @@ -1741,11 +1741,11 @@ priv = xpd->priv; BUG_ON(!priv); priv->poll_noreplies = 0; - if(data_low & REG_FRS0_LOS) + if (data_low & REG_FRS0_LOS) alarms |= DAHDI_ALARM_RED; - if(data_low & REG_FRS0_AIS) + if (data_low & REG_FRS0_AIS) alarms |= DAHDI_ALARM_BLUE; - if(data_low & REG_FRS0_RRA) + if (data_low & REG_FRS0_RRA) alarms |= DAHDI_ALARM_YELLOW; layer1_up_prev = priv->layer1_up; priv->layer1_up = alarms == 0; @@ -1755,11 +1755,11 @@ * associated. However, layer1 is still not working if they are set. * FIXME: These behave differently in E1/T1, so ignore them for while. */ - if(data_low & (REG_FRS0_LMFA | REG_FRS0_E1_NMF)) + if (data_low & (REG_FRS0_LMFA | REG_FRS0_E1_NMF)) priv->layer1_up = 0; #endif priv->alarms = alarms; - if(!priv->layer1_up) { + if (!priv->layer1_up) { dchan_state(xpd, 0); } else if (priv->is_cas && !layer1_up_prev) { int i; @@ -1767,11 +1767,11 @@ NUM_CAS_RS: NUM_CAS_RS_T; XPD_DBG(SIGNAL , xpd, "Returning From Alarm Refreshing Rx register data \n"); - for(i = 0; i < num_cas_rs; i++) + for (i = 0; i < num_cas_rs; i++) query_subunit(xpd, REG_RS1_E + i); } - if(SPAN_REGISTERED(xpd) && xpd->span.alarms != alarms) { + if (SPAN_REGISTERED(xpd) && xpd->span.alarms != alarms) { char str1[MAX_PROC_WRITE]; char str2[MAX_PROC_WRITE]; @@ -1801,25 +1801,25 @@ BUG_ON(!priv->is_cas); BUG_ON(priv->pri_protocol != PRI_PROTO_E1); XPD_DBG(SIGNAL, xpd, "RBS: RX: data_low=0x%02X\n", data_low); - if(pos < 0 || pos >= NUM_CAS_RS) { + if (pos < 0 || pos >= NUM_CAS_RS) { XPD_ERR(xpd, "%s: got bad pos=%d [0-%d]\n", __FUNCTION__, pos, NUM_CAS_RS); return -EINVAL; } - if(chan1 < 0 || chan1 > xpd->channels) { + if (chan1 < 0 || chan1 > xpd->channels) { XPD_NOTICE(xpd, "%s: %s CAS: Bad chan1 number (%d)\n", __FUNCTION__, pri_protocol_name(priv->pri_protocol), chan1); return -EINVAL; } - if(chan2 < 0 || chan2 > xpd->channels) { + if (chan2 < 0 || chan2 > xpd->channels) { XPD_NOTICE(xpd, "%s: %s CAS: Bad chan2 number (%d)\n", __FUNCTION__, pri_protocol_name(priv->pri_protocol), chan2); return -EINVAL; } - if(priv->cas_rs_e[pos] != data_low) { + if (priv->cas_rs_e[pos] != data_low) { int old1 = (priv->cas_rs_e[pos] >> 4) & 0xF; int old2 = priv->cas_rs_e[pos] & 0xF; int new1 = (data_low >> 4) & 0xF; @@ -1827,10 +1827,10 @@ XPD_DBG(SIGNAL, xpd, "RBS: RX: RS%02d (channel %2d, channel %2d): 0x%02X -> 0x%02X\n", rsnum, chan1+1, chan2+1, priv->cas_rs_e[pos], data_low); - if(SPAN_REGISTERED(xpd)) { - if(old1 != new1) + if (SPAN_REGISTERED(xpd)) { + if (old1 != new1) dahdi_rbsbits(XPD_CHAN(xpd, chan1), new1); - if(old2 != new2) + if (old2 != new2) dahdi_rbsbits(XPD_CHAN(xpd, chan2), new2); } priv->dchan_rx_counter++; @@ -1856,15 +1856,15 @@ BUG_ON(!priv->is_cas); BUG_ON(priv->pri_protocol != PRI_PROTO_T1); rsnum = regnum - REG_RS1_E; - if(rsnum < 0 || rsnum >= 12) { + if (rsnum < 0 || rsnum >= 12) { XPD_ERR(xpd, "Bad rsnum=%d\n", rsnum); return 0; } - if(!priv->is_esf) + if (!priv->is_esf) rsnum = rsnum % 6; /* 2 identical banks of 6 registers */ chan_per_reg = CHAN_PER_REGS(priv); width = 8 / chan_per_reg; - if(priv->cas_rs_e[rsnum] == data_low) { + if (priv->cas_rs_e[rsnum] == data_low) { #if 0 XPD_DBG(SIGNAL, xpd, "RBS: RX: RS%02d: REPEAT 0x%02X\n", rsnum+1, data_low); @@ -1876,7 +1876,7 @@ (priv->is_esf) ? "esf" : "d4", chan_per_reg, rsnum+1, data_low); - for(i = 0; i < chan_per_reg; i++) { + for (i = 0; i < chan_per_reg; i++) { uint rxsig = (data_low >> (i * width)) & BITMASK(width); int pos; struct dahdi_chan *chan; @@ -1884,16 +1884,16 @@ if (!priv->is_esf) rxsig <<= 2; pos = rsnum * chan_per_reg + chan_per_reg - i - 1; - if(pos < 0 || pos >= xpd->channels) { + if (pos < 0 || pos >= xpd->channels) { XPD_ERR(xpd, "%s: Bad pos=%d\n", __FUNCTION__, pos); continue; } chan = XPD_CHAN(xpd, pos); - if(!chan) { + if (!chan) { XPD_ERR(xpd, "%s: Null channel in pos=%d\n", __FUNCTION__, pos); continue; } - if(chan->rxsig != rxsig) { + if (chan->rxsig != rxsig) { LINE_DBG(SIGNAL, xpd, pos, "i=%d rxsig=0x%02X\n", i, rxsig); dahdi_rbsbits(chan, rxsig); } @@ -1907,43 +1907,43 @@ struct PRI_priv_data *priv; priv = xpd->priv; - if(!priv->is_cas) { + if (!priv->is_cas) { static int rate_limit; - if((rate_limit++ % 10003) == 0) + if ((rate_limit++ % 10003) == 0) XPD_NOTICE(xpd, "RBS: RX: not in CAS mode. Ignore.\n"); return; } - if(!priv->layer1_up) { + if (!priv->layer1_up) { static int rate_limit; - if((rate_limit++ % 10003) == 0) + if ((rate_limit++ % 10003) == 0) XPD_DBG(SIGNAL, xpd, "RBS: RX: No layer1.\n"); } - if(!SPAN_REGISTERED(xpd)) { + if (!SPAN_REGISTERED(xpd)) { static int rate_limit; - if((rate_limit++ % 10003) == 0) + if ((rate_limit++ % 10003) == 0) XPD_DBG(SIGNAL, xpd, "RBS: RX: Span not registered. Ignore.\n"); return; } - if(priv->pri_protocol == PRI_PROTO_E1) { - if(regnum < REG_RS2_E) { + if (priv->pri_protocol == PRI_PROTO_E1) { + if (regnum < REG_RS2_E) { XPD_NOTICE(xpd, "%s: received register 0x%X in protocol %s. Ignore\n", __FUNCTION__, regnum, pri_protocol_name(priv->pri_protocol)); return; } - if(decode_cas_e1(xpd, regnum, data_low) < 0) + if (decode_cas_e1(xpd, regnum, data_low) < 0) return; - } else if(priv->pri_protocol == PRI_PROTO_T1) { - if(regnum > REG_RS12_E) { + } else if (priv->pri_protocol == PRI_PROTO_T1) { + if (regnum > REG_RS12_E) { XPD_NOTICE(xpd, "%s: received register 0x%X in protocol %s. Ignore\n", __FUNCTION__, regnum, pri_protocol_name(priv->pri_protocol)); return; } - if(decode_cas_t1(xpd, regnum, data_low) < 0) + if (decode_cas_t1(xpd, regnum, data_low) < 0) return; } else { XPD_NOTICE(xpd, "%s: protocol %s is not supported yet with CAS\n", @@ -1968,32 +1968,32 @@ regnum = REG_FIELD(info, regnum); data_low = REG_FIELD(info, data_low); xpd = xpd_byaddr(xbus, addr.unit, addr.subunit); - if(!xpd) { + if (!xpd) { static int rate_limit; - if((rate_limit++ % 1003) < 5) + if ((rate_limit++ % 1003) < 5) notify_bad_xpd(__FUNCTION__, xbus, addr , orig_xpd->xpdname); return -EPROTO; } spin_lock_irqsave(&xpd->lock, flags); priv = xpd->priv; BUG_ON(!priv); - if(info->is_multibyte) { + if (info->is_multibyte) { XPD_NOTICE(xpd, "Got Multibyte: %d bytes, eoframe: %d\n", info->bytes, info->eoframe); goto end; } - if(regnum == REG_FRS0 && !REG_FIELD(info, do_subreg)) + if (regnum == REG_FRS0 && !REG_FIELD(info, do_subreg)) layer1_state(xpd, data_low); - else if(regnum == REG_FRS1 && !REG_FIELD(info, do_subreg)) + else if (regnum == REG_FRS1 && !REG_FIELD(info, do_subreg)) priv->reg_frs1 = data_low; - if(priv->is_cas && !REG_FIELD(info, do_subreg)) { - if(regnum >= REG_RS1_E && regnum <= REG_RS16_E) { + if (priv->is_cas && !REG_FIELD(info, do_subreg)) { + if (regnum >= REG_RS1_E && regnum <= REG_RS16_E) { process_cas_dchan(xpd, regnum, data_low); } } /* Update /proc info only if reply relate to the last slic read request */ - if( + if ( REG_FIELD(&xpd->requested_reply, regnum) == REG_FIELD(info, regnum) && REG_FIELD(&xpd->requested_reply, do_subreg) == REG_FIELD(info, do_subreg) && REG_FIELD(&xpd->requested_reply, subreg) == REG_FIELD(info, subreg)) { @@ -2061,16 +2061,16 @@ bool got_t1 = 0; bool got_j1 = 0; - if(!xpd) + if (!xpd) return -ENODEV; XPD_NOTICE(xpd, "%s: DEPRECATED: %s[%d] write to /proc interface instead of /sys\n", __FUNCTION__, current->comm, current->tgid); priv = xpd->priv; - if(count >= MAX_PROC_WRITE) { /* leave room for null */ + if (count >= MAX_PROC_WRITE) { /* leave room for null */ XPD_ERR(xpd, "write too long (%ld)\n", count); return -E2BIG; } - if(copy_from_user(buf, buffer, count)) { + if (copy_from_user(buf, buffer, count)) { XPD_ERR(xpd, "Failed reading user data\n"); return -EFAULT; } @@ -2080,39 +2080,39 @@ * First parse. Act only of *everything* is good. */ p = buf; - while((tok = strsep(&p, " \t\v\n")) != NULL) { - if(*tok == '\0') + while ((tok = strsep(&p, " \t\v\n")) != NULL) { + if (*tok == '\0') continue; XPD_DBG(PROC, xpd, "Got token='%s'\n", tok); - if(strnicmp(tok, "LOCALLOOP", 8) == 0) + if (strnicmp(tok, "LOCALLOOP", 8) == 0) got_localloop = 1; - else if(strnicmp(tok, "NOLOCALLOOP", 8) == 0) + else if (strnicmp(tok, "NOLOCALLOOP", 8) == 0) got_nolocalloop = 1; - else if(strnicmp(tok, "E1", 2) == 0) + else if (strnicmp(tok, "E1", 2) == 0) got_e1 = 1; - else if(strnicmp(tok, "T1", 2) == 0) + else if (strnicmp(tok, "T1", 2) == 0) got_t1 = 1; - else if(strnicmp(tok, "J1", 2) == 0) { + else if (strnicmp(tok, "J1", 2) == 0) { got_j1 = 1; } else { XPD_NOTICE(xpd, "PRI-SETUP: unknown keyword: '%s'\n", tok); return -EINVAL; } } - if(got_e1) + if (got_e1) ret = set_pri_proto(xpd, PRI_PROTO_E1); - else if(got_t1) + else if (got_t1) ret = set_pri_proto(xpd, PRI_PROTO_T1); - else if(got_j1) + else if (got_j1) ret = set_pri_proto(xpd, PRI_PROTO_J1); - if(priv->pri_protocol == PRI_PROTO_0) { + if (priv->pri_protocol == PRI_PROTO_0) { XPD_ERR(xpd, "Must set PRI protocol (E1/T1/J1) before setting other parameters\n"); return -EINVAL; } - if(got_localloop) + if (got_localloop) ret = set_localloop(xpd, 1); - if(got_nolocalloop) + if (got_nolocalloop) ret = set_localloop(xpd, 0); return (ret) ? ret : count; } @@ -2127,7 +2127,7 @@ int i; DBG(PROC, "\n"); - if(!xpd) + if (!xpd) return -ENODEV; XPD_NOTICE(xpd, "%s: DEPRECATED: %s[%d] read from /proc interface instead of /sys\n", __FUNCTION__, current->comm, current->tgid); @@ -2140,7 +2140,7 @@ (priv->local_loopback) ? " LOCALLOOP" : "", priv->deflaw, priv->dchan_num); len += sprintf(page + len, "%05d Layer1: ", priv->layer1_replies); - if(priv->poll_noreplies > 1) + if (priv->poll_noreplies > 1) len += sprintf(page + len, "No Replies [%d]\n", priv->poll_noreplies); else { @@ -2149,24 +2149,24 @@ len += sprintf(page + len, "Framer Status: FRS0=0x%02X, FRS1=0x%02X ALARMS:", priv->reg_frs0, priv->reg_frs1); - if(priv->reg_frs0 & REG_FRS0_LOS) + if (priv->reg_frs0 & REG_FRS0_LOS) len += sprintf(page + len, " RED"); - if(priv->reg_frs0 & REG_FRS0_AIS) + if (priv->reg_frs0 & REG_FRS0_AIS) len += sprintf(page + len, " BLUE"); - if(priv->reg_frs0 & REG_FRS0_RRA) + if (priv->reg_frs0 & REG_FRS0_RRA) len += sprintf(page + len, " YELLOW"); len += sprintf(page + len, "\n"); } - if(priv->is_cas) { + if (priv->is_cas) { len += sprintf(page + len, "CAS: replies=%d\n", priv->cas_replies); len += sprintf(page + len, " CAS-TS: "); - for(i = 0; i < NUM_CAS_RS; i++) { + for (i = 0; i < NUM_CAS_RS; i++) { len += sprintf(page + len, " %02X", priv->cas_ts_e[i]); } len += sprintf(page + len, "\n"); len += sprintf(page + len, " CAS-RS: "); - for(i = 0; i < NUM_CAS_RS; i++) { + for (i = 0; i < NUM_CAS_RS; i++) { len += sprintf(page + len, " %02X", priv->cas_rs_e[i]); } len += sprintf(page + len, "\n"); @@ -2174,13 +2174,13 @@ len += sprintf(page + len, "D-Channel: TX=[%5d] (0x%02X) RX=[%5d] (0x%02X) ", priv->dchan_tx_counter, priv->dchan_tx_sample, priv->dchan_rx_counter, priv->dchan_rx_sample); - if(priv->dchan_alive) { + if (priv->dchan_alive) { len += sprintf(page + len, "(alive %d K-ticks)\n", priv->dchan_alive_ticks/1000); } else { len += sprintf(page + len, "(dead)\n"); } - for(i = 0; i < NUM_LEDS; i++) + for (i = 0; i < NUM_LEDS; i++) len += sprintf(page + len, "LED #%d: %d\n", i, priv->ledstate[i]); spin_unlock_irqrestore(&xpd->lock, flags); if (len <= off+count) @@ -2205,7 +2205,7 @@ BUG_ON(!dev); xpd = dev_to_xpd(dev); - if(!xpd) + if (!xpd) return -ENODEV; priv = xpd->priv; BUG_ON(!priv); @@ -2225,19 +2225,19 @@ BUG_ON(!dev); xpd = dev_to_xpd(dev); XPD_DBG(GENERAL, xpd, "%s\n", buf); - if(!xpd) + if (!xpd) return -ENODEV; - if((i = strcspn(buf, " \r\n")) != 2) { + if ((i = strcspn(buf, " \r\n")) != 2) { XPD_NOTICE(xpd, "Protocol name '%s' has %d characters (should be 2). Ignored.\n", buf, i); return -EINVAL; } - if(strnicmp(buf, "E1", 2) == 0) + if (strnicmp(buf, "E1", 2) == 0) new_protocol = PRI_PROTO_E1; - else if(strnicmp(buf, "T1", 2) == 0) + else if (strnicmp(buf, "T1", 2) == 0) new_protocol = PRI_PROTO_T1; - else if(strnicmp(buf, "J1", 2) == 0) + else if (strnicmp(buf, "J1", 2) == 0) new_protocol = PRI_PROTO_J1; else { XPD_NOTICE(xpd, @@ -2260,7 +2260,7 @@ BUG_ON(!dev); xpd = dev_to_xpd(dev); - if(!xpd) + if (!xpd) return -ENODEV; priv = xpd->priv; BUG_ON(!priv); @@ -2281,17 +2281,17 @@ BUG_ON(!dev); xpd = dev_to_xpd(dev); XPD_DBG(GENERAL, xpd, "%s\n", buf); - if(!xpd) + if (!xpd) return -ENODEV; - if((i = strcspn(buf, " \r\n")) != 1) { + if ((i = strcspn(buf, " \r\n")) != 1) { XPD_NOTICE(xpd, "Value '%s' has %d characters (should be 1). Ignored.\n", buf, i); return -EINVAL; } - if(strchr("1Yy", buf[0]) != NULL) + if (strchr("1Yy", buf[0]) != NULL) ll = 1; - else if(strchr("0Nn", buf[0]) != NULL) + else if (strchr("0Nn", buf[0]) != NULL) ll = 0; else { XPD_NOTICE(xpd, @@ -2314,12 +2314,12 @@ BUG_ON(!dev); xpd = dev_to_xpd(dev); - if(!xpd) + if (!xpd) return -ENODEV; priv = xpd->priv; BUG_ON(!priv); spin_lock_irqsave(&xpd->lock, flags); - if(priv->poll_noreplies > 1) + if (priv->poll_noreplies > 1) len += sprintf(buf + len, "Unknown[%d]", priv->poll_noreplies); else len += sprintf(buf + len, "%-10s", ((priv->layer1_up) ? "UP" : "DOWN")); @@ -2347,18 +2347,18 @@ BUG_ON(!dev); xpd = dev_to_xpd(dev); - if(!xpd) + if (!xpd) return -ENODEV; priv = xpd->priv; BUG_ON(!priv); spin_lock_irqsave(&xpd->lock, flags); - if(priv->poll_noreplies > 1) + if (priv->poll_noreplies > 1) len += sprintf(buf + len, "Unknown[%d]", priv->poll_noreplies); else { int i; - for(i = 0; i < ARRAY_SIZE(alarm_types); i++) { - if(priv->reg_frs0 & alarm_types[i].bits) + for (i = 0; i < ARRAY_SIZE(alarm_types); i++) { + if (priv->reg_frs0 & alarm_types[i].bits) len += sprintf(buf + len, "%s ", alarm_types[i].name); } } @@ -2378,23 +2378,23 @@ BUG_ON(!dev); xpd = dev_to_xpd(dev); - if(!xpd) + if (!xpd) return -ENODEV; priv = xpd->priv; BUG_ON(!priv); spin_lock_irqsave(&xpd->lock, flags); - if(priv->is_cas) { + if (priv->is_cas) { int i; len += sprintf(buf + len, "CAS: replies=%d\n", priv->cas_replies); len += sprintf(buf + len, " CAS-TS: "); - for(i = 0; i < NUM_CAS_RS; i++) { + for (i = 0; i < NUM_CAS_RS; i++) { len += sprintf(buf + len, " %02X", priv->cas_ts_e[i]); } len += sprintf(buf + len, "\n"); len += sprintf(buf + len, " CAS-RS: "); - for(i = 0; i < NUM_CAS_RS; i++) { + for (i = 0; i < NUM_CAS_RS; i++) { len += sprintf(buf + len, " %02X", priv->cas_rs_e[i]); } len += sprintf(buf + len, "\n"); @@ -2414,7 +2414,7 @@ BUG_ON(!dev); xpd = dev_to_xpd(dev); - if(!xpd) + if (!xpd) return -ENODEV; priv = xpd->priv; BUG_ON(!priv); @@ -2422,7 +2422,7 @@ len += sprintf(buf + len, "D-Channel: TX=[%5d] (0x%02X) RX=[%5d] (0x%02X) ", priv->dchan_tx_counter, priv->dchan_tx_sample, priv->dchan_rx_counter, priv->dchan_rx_sample); - if(priv->dchan_alive) { + if (priv->dchan_alive) { len += sprintf(buf + len, "(alive %d K-ticks)\n", priv->dchan_alive_ticks/1000); } else { @@ -2443,7 +2443,7 @@ BUG_ON(!dev); xpd = dev_to_xpd(dev); - if(!xpd) + if (!xpd) return -ENODEV; priv = xpd->priv; BUG_ON(!priv); @@ -2463,44 +2463,44 @@ xpd = dev_to_xpd(dev); /* Is it our device? */ - if(xpd->type != XPD_TYPE_PRI) { + if (xpd->type != XPD_TYPE_PRI) { XPD_ERR(xpd, "drop suggestion for %s (%d)\n", dev_name(dev), xpd->type); return -EINVAL; } XPD_DBG(DEVICES, xpd, "SYSFS\n"); ret = device_create_file(dev, &dev_attr_pri_protocol); - if(ret) { + if (ret) { XPD_ERR(xpd, "%s: device_create_file(pri_protocol) failed: %d\n", __FUNCTION__, ret); goto fail_pri_protocol; } ret = device_create_file(dev, &dev_attr_pri_localloop); - if(ret) { + if (ret) { XPD_ERR(xpd, "%s: device_create_file(pri_localloop) failed: %d\n", __FUNCTION__, ret); goto fail_pri_localloop; } ret = device_create_file(dev, &dev_attr_pri_layer1); - if(ret) { + if (ret) { XPD_ERR(xpd, "%s: device_create_file(pri_layer1) failed: %d\n", __FUNCTION__, ret); goto fail_pri_layer1; } ret = device_create_file(dev, &dev_attr_pri_alarms); - if(ret) { + if (ret) { XPD_ERR(xpd, "%s: device_create_file(pri_alarms) failed: %d\n", __FUNCTION__, ret); goto fail_pri_alarms; } ret = device_create_file(dev, &dev_attr_pri_cas); - if(ret) { + if (ret) { XPD_ERR(xpd, "%s: device_create_file(pri_cas) failed: %d\n", __FUNCTION__, ret); goto fail_pri_cas; } ret = device_create_file(dev, &dev_attr_pri_dchan); - if(ret) { + if (ret) { XPD_ERR(xpd, "%s: device_create_file(pri_dchan) failed: %d\n", __FUNCTION__, ret); goto fail_pri_dchan; } ret = device_create_file(dev, &dev_attr_pri_clocking); - if(ret) { + if (ret) { XPD_ERR(xpd, "%s: device_create_file(pri_clocking) failed: %d\n", __FUNCTION__, ret); goto fail_pri_clocking; } @@ -2553,7 +2553,7 @@ { int ret; - if((ret = xpd_driver_register(&pri_driver.driver)) < 0) + if ((ret = xpd_driver_register(&pri_driver.driver)) < 0) return ret; INFO("revision %s\n", XPP_VERSION); xproto_register(&PROTO_TABLE(PRI)); Index: drivers/dahdi/xpp/dahdi_debug.c =================================================================== --- drivers/dahdi/xpp/dahdi_debug.c (revision 7493) +++ drivers/dahdi/xpp/dahdi_debug.c (working copy) @@ -58,8 +58,8 @@ { int i; - for(i = 0; i < ARRAY_SIZE(poll_names); i++) { - if(poll & poll_names[i].value) + for (i = 0; i < ARRAY_SIZE(poll_names); i++) { + if (poll & poll_names[i].value) DBG(GENERAL, "%s: %s\n", msg, poll_names[i].name); } } @@ -71,19 +71,19 @@ int i; int n; - if(!alarm) { + if (!alarm) { snprintf(buf, buflen, "NONE"); return; } memset(buf, 0, buflen); - for(i = 0; i < 8; i++) { - if(left && (alarm & BIT(i))) { + for (i = 0; i < 8; i++) { + if (left && (alarm & BIT(i))) { n = snprintf(p, left, "%s,", alarmbit2str(i)); p += n; left -= n; } } - if(p > buf) /* kill last comma */ + if (p > buf) /* kill last comma */ *(p - 1) = '\0'; } Index: drivers/dahdi/xpp/dahdi_debug.h =================================================================== --- drivers/dahdi/xpp/dahdi_debug.h (revision 7493) +++ drivers/dahdi/xpp/dahdi_debug.h (working copy) @@ -94,7 +94,7 @@ static inline char *rxsig2str(enum dahdi_rxsig sig) { - switch(sig) { + switch (sig) { case DAHDI_RXSIG_ONHOOK: return "ONHOOK"; case DAHDI_RXSIG_OFFHOOK: return "OFFHOOK"; case DAHDI_RXSIG_START: return "START"; @@ -106,7 +106,7 @@ static inline char *txsig2str(enum dahdi_txsig sig) { - switch(sig) { + switch (sig) { case DAHDI_TXSIG_ONHOOK: return "TXSIG_ONHOOK"; case DAHDI_TXSIG_OFFHOOK: return "TXSIG_OFFHOOK"; case DAHDI_TXSIG_START: return "TXSIG_START"; @@ -118,7 +118,7 @@ static inline char *event2str(int event) { - switch(event) { + switch (event) { case DAHDI_EVENT_NONE: return "NONE"; case DAHDI_EVENT_ONHOOK: return "ONHOOK"; case DAHDI_EVENT_RINGOFFHOOK: return "RINGOFFHOOK"; @@ -143,7 +143,7 @@ static inline char *hookstate2str(int hookstate) { - switch(hookstate) { + switch (hookstate) { case DAHDI_ONHOOK: return "DAHDI_ONHOOK"; case DAHDI_START: return "DAHDI_START"; case DAHDI_OFFHOOK: return "DAHDI_OFFHOOK"; @@ -185,7 +185,7 @@ static inline char *alarmbit2str(int alarmbit) { /* from dahdi/kernel.h */ - switch(1 << alarmbit) { + switch (1 << alarmbit) { case DAHDI_ALARM_NONE: return "NONE"; case DAHDI_ALARM_RECOVER: return "RECOVER"; case DAHDI_ALARM_LOOPBACK: return "LOOPBACK"; Index: drivers/dahdi/xpp/mmapdrv.c =================================================================== --- drivers/dahdi/xpp/mmapdrv.c (revision 7493) +++ drivers/dahdi/xpp/mmapdrv.c (working copy) @@ -115,7 +115,7 @@ xbus = xbus_num(global_xbus->num); BUG_ON(!xbus); - if(!XBUS_GET(xbus)) { + if (!XBUS_GET(xbus)) { if (printk_ratelimit()) XBUS_ERR(xbus, "Dropping packet. Is shutting down.\n"); goto out; @@ -129,7 +129,7 @@ NOTICE("Got %d bytes\n", rxcnt); goto out; } - if(rxcnt >= XFRAME_DATASIZE) { + if (rxcnt >= XFRAME_DATASIZE) { if (printk_ratelimit()) ERR("Bad rxcnt=%d\n", rxcnt); goto out; @@ -520,7 +520,7 @@ NULL, #endif NULL); - if(!xframe_cache) { + if (!xframe_cache) { ret = -ENOMEM; goto fail_cache; } Index: drivers/dahdi/xpp/parport_debug.c =================================================================== --- drivers/dahdi/xpp/parport_debug.c (revision 7493) +++ drivers/dahdi/xpp/parport_debug.c (working copy) @@ -41,8 +41,8 @@ unsigned char mask; unsigned char value; - if(!debug_sync_parport) { - if(printk_ratelimit()) { + if (!debug_sync_parport) { + if (printk_ratelimit()) { printk(KERN_NOTICE "%s: no debug parallel port\n", THIS_MODULE->name); } @@ -52,7 +52,7 @@ mask = 1 << bitnum; spin_lock_irqsave(&lock, flags); value = last_value & ~mask; - if(parport_toggles[bitnum] % 2) /* square wave */ + if (parport_toggles[bitnum] % 2) /* square wave */ value |= mask; last_value = value; parport_toggles[bitnum]++; @@ -64,7 +64,7 @@ static void parport_attach(struct parport *port) { printk(KERN_INFO "%s: Using %s for debugging\n", THIS_MODULE->name, port->name); - if(debug_sync_parport) { + if (debug_sync_parport) { printk(KERN_ERR "%s: Using %s, ignore new attachment %s\n", THIS_MODULE->name, debug_sync_parport->name, port->name); return; @@ -76,7 +76,7 @@ static void parport_detach(struct parport *port) { printk(KERN_INFO "%s: Releasing %s\n", THIS_MODULE->name, port->name); - if(debug_sync_parport != port) { + if (debug_sync_parport != port) { printk(KERN_ERR "%s: Using %s, ignore new detachment %s\n", THIS_MODULE->name, debug_sync_parport->name, port->name); return; Index: drivers/dahdi/xpp/xbus-core.c =================================================================== --- drivers/dahdi/xpp/xbus-core.c (revision 7493) +++ drivers/dahdi/xpp/xbus-core.c (working copy) @@ -83,7 +83,7 @@ const char *xbus_statename(enum xbus_state st) { - switch(st) { + switch (st) { case XBUS_STATE_START: return "START"; case XBUS_STATE_IDLE: return "IDLE"; case XBUS_STATE_SENT_REQUEST: return "SENT_REQUEST"; @@ -109,7 +109,7 @@ { struct xbus_desc *desc; - if(num >= ARRAY_SIZE(xbuses_array)) + if (num >= ARRAY_SIZE(xbuses_array)) return NULL; desc = &xbuses_array[num]; return desc->xbus; @@ -119,7 +119,7 @@ { int i; - for(i = 0; i < ARRAY_SIZE(xbuses_array); i++) + for (i = 0; i < ARRAY_SIZE(xbuses_array); i++) init_xbus(i, NULL); } @@ -127,8 +127,8 @@ { int i; - for(i = 0; i < ARRAY_SIZE(xbuses_array); i++) { - if(xbuses_array[i].xbus != NULL) { + for (i = 0; i < ARRAY_SIZE(xbuses_array); i++) { + if (xbuses_array[i].xbus != NULL) { ERR("%s: xbus #%d is not NULL\n", __FUNCTION__, i); BUG(); } @@ -352,7 +352,7 @@ int i; int debug = DBG_ANY; /* mask global debug */ - for(i = 0; i < len; i++) + for (i = 0; i < len; i++) DBG(ANY, "%s: %3d> %02X\n", msg, i, data[i]); } @@ -366,23 +366,23 @@ bool do_print; unsigned long flags; - if(xframe->xframe_magic != XFRAME_MAGIC) { + if (xframe->xframe_magic != XFRAME_MAGIC) { XBUS_ERR(xbus, "%s: bad xframe_magic %lX\n", __FUNCTION__, xframe->xframe_magic); return; } spin_lock_irqsave(&serialize_dump_xframe, flags); do { - if(pos >= xbus->transport.max_send_size) { - if(printk_ratelimit()) { + if (pos >= xbus->transport.max_send_size) { + if (printk_ratelimit()) { XBUS_NOTICE(xbus, "%s: xframe overflow (%d bytes)\n", msg, frm_len); do_hexdump(msg, xframe->packets, frm_len); } break; } - if(pos > frm_len) { - if(printk_ratelimit()) { + if (pos > frm_len) { + if (printk_ratelimit()) { XBUS_NOTICE(xbus, "%s: packet overflow pos=%d frame_len=%d\n", msg, pos, frm_len); do_hexdump(msg, xframe->packets, frm_len); @@ -390,8 +390,8 @@ break; } pack = (xpacket_t *)&xframe->packets[pos]; - if(XPACKET_LEN(pack) <= 0) { - if(printk_ratelimit()) { + if (XPACKET_LEN(pack) <= 0) { + if (printk_ratelimit()) { XBUS_NOTICE(xbus, "%s: xframe -- bad packet_len=%d pos=%d frame_len=%d\n", msg, XPACKET_LEN(pack), pos, frm_len); do_hexdump(msg, xframe->packets, frm_len); @@ -399,8 +399,8 @@ break; } nextpos = pos + XPACKET_LEN(pack); - if(nextpos > frm_len) { - if(printk_ratelimit()) { + if (nextpos > frm_len) { + if (printk_ratelimit()) { XBUS_NOTICE(xbus, "%s: packet overflow nextpos=%d frame_len=%d\n", msg, nextpos, frm_len); do_hexdump(msg, xframe->packets, frm_len); @@ -408,19 +408,19 @@ break; } do_print = 0; - if(debug == DBG_ANY) + if (debug == DBG_ANY) do_print = 1; - else if(XPACKET_OP(pack) != XPROTO_NAME(GLOBAL,PCM_READ) && + else if (XPACKET_OP(pack) != XPROTO_NAME(GLOBAL,PCM_READ) && XPACKET_OP(pack) != XPROTO_NAME(GLOBAL,PCM_WRITE)) do_print = 1; - else if(debug & DBG_PCM) { + else if (debug & DBG_PCM) { static int rate_limit; - if((rate_limit++ % 1003) == 0) + if ((rate_limit++ % 1003) == 0) do_print = 1; } - if(do_print) { - if(num == 1) { + if (do_print) { + if (num == 1) { XBUS_DBG(ANY, xbus, "%s: frame_len=%d. %s\n", msg, frm_len, (XPACKET_IS_PCM(pack)) @@ -437,9 +437,9 @@ } num++; pos = nextpos; - if(pos >= frm_len) + if (pos >= frm_len) break; - } while(1); + } while (1); spin_unlock_irqrestore(&serialize_dump_xframe, flags); } @@ -455,7 +455,7 @@ int ret = -ENODEV; BUG_ON(!xframe); - if(!XBUS_IS(xbus, READY)) { + if (!XBUS_IS(xbus, READY)) { XBUS_ERR(xbus, "Dropped a pcm frame -- hardware is not ready.\n"); ret = -ENODEV; goto error; @@ -464,7 +464,7 @@ BUG_ON(!ops); ret = ops->xframe_send_pcm(xbus, xframe); transportops_put(xbus); - if(ret) + if (ret) XBUS_COUNTER(xbus, TX_BYTES) += XFRAME_LEN(xframe); return ret; @@ -481,7 +481,7 @@ BUG_ON(!xbus); BUG_ON(!xframe); BUG_ON(xframe->xframe_magic != XFRAME_MAGIC); - if(!XBUS_FLAGS(xbus, CONNECTED)) { + if (!XBUS_FLAGS(xbus, CONNECTED)) { XBUS_ERR(xbus, "Dropped command before sending -- hardware deactivated.\n"); dump_xframe("Dropped", xbus, xframe, DBG_ANY); FREE_SEND_XFRAME(xbus, xframe); @@ -489,11 +489,11 @@ } ops = transportops_get(xbus); BUG_ON(!ops); - if(debug & DBG_COMMANDS) + if (debug & DBG_COMMANDS) dump_xframe("TX-CMD", xbus, xframe, DBG_ANY); ret = ops->xframe_send_cmd(xbus, xframe); transportops_put(xbus); - if(ret == 0) { + if (ret == 0) { XBUS_COUNTER(xbus, TX_CMD)++; XBUS_COUNTER(xbus, TX_BYTES) += XFRAME_LEN(xframe); } @@ -508,25 +508,25 @@ xbus->command_tick_counter++; xbus->usec_nosend -= 1000; /* That's our budget */ - for(packno = 0; packno < 3; packno++) { - if(xbus->usec_nosend > 0) + for (packno = 0; packno < 3; packno++) { + if (xbus->usec_nosend > 0) break; frm = xframe_dequeue(&xbus->command_queue); - if(!frm) { + if (!frm) { wake_up(&xbus->command_queue_empty); break; } BUG_ON(frm->xframe_magic != XFRAME_MAGIC); xbus->usec_nosend += frm->usec_towait; ret = really_send_cmd_frame(xbus, frm); - if(ret < 0) { + if (ret < 0) { XBUS_ERR(xbus, "Failed to send from command_queue (ret=%d)\n", ret); xbus_setstate(xbus, XBUS_STATE_FAIL); } } - if(xbus->usec_nosend < 0) + if (xbus->usec_nosend < 0) xbus->usec_nosend = 0; return ret; } @@ -537,7 +537,7 @@ XBUS_DBG(DEVICES, xbus, "count=%d\n", xbus->command_queue.count); xframe_queue_disable(&xbus->command_queue, 1); - while((frm = xframe_dequeue(&xbus->command_queue)) != NULL) { + while ((frm = xframe_dequeue(&xbus->command_queue)) != NULL) { FREE_SEND_XFRAME(xbus, frm); } } @@ -549,7 +549,7 @@ XBUS_DBG(DEVICES, xbus, "Waiting for command_queue to empty\n"); ret = wait_event_interruptible(xbus->command_queue_empty, xframe_queue_count(&xbus->command_queue) == 0); - if(ret) { + if (ret) { XBUS_ERR(xbus, "waiting for command_queue interrupted!!!\n"); } return ret; @@ -562,15 +562,15 @@ BUG_ON(xframe->xframe_magic != XFRAME_MAGIC); - if(!XBUS_FLAGS(xbus, CONNECTED)) { + if (!XBUS_FLAGS(xbus, CONNECTED)) { XBUS_ERR(xbus, "Dropped command before queueing -- hardware deactivated.\n"); ret = -ENODEV; goto err; } - if(debug & DBG_COMMANDS) + if (debug & DBG_COMMANDS) dump_xframe(__FUNCTION__, xbus, xframe, DBG_ANY); - if(!xframe_enqueue(&xbus->command_queue, xframe)) { - if((rate_limit++ % 1003) == 0) { + if (!xframe_enqueue(&xbus->command_queue, xframe)) { + if ((rate_limit++ % 1003) == 0) { XBUS_ERR(xbus, "Dropped command xframe. Cannot enqueue (%d)\n", rate_limit); @@ -594,10 +594,10 @@ BUG_ON(!xbus); xbus->cpu_rcv_intr[cpu]++; - if(!xframe_enqueue(&xbus->receive_queue, xframe)) { + if (!xframe_enqueue(&xbus->receive_queue, xframe)) { static int rate_limit; - if((rate_limit++ % 1003) == 0) + if ((rate_limit++ % 1003) == 0) XBUS_ERR(xbus, "Failed to enqueue for receive_tasklet (%d)\n", rate_limit); FREE_RECV_XFRAME(xbus, xframe); /* return to receive_pool */ return; @@ -616,7 +616,7 @@ BUG_ON(!xbus); xbus->cpu_rcv_tasklet[cpu]++; - while((xframe = xframe_dequeue(&xbus->receive_queue)) != NULL) { + while ((xframe = xframe_dequeue(&xbus->receive_queue)) != NULL) { xframe_receive(xbus, xframe); } } @@ -624,10 +624,10 @@ void xbus_receive_xframe(xbus_t *xbus, xframe_t *xframe) { BUG_ON(!xbus); - if(rx_tasklet) { + if (rx_tasklet) { xframe_enqueue_recv(xbus, xframe); } else { - if(likely(XBUS_FLAGS(xbus, CONNECTED))) + if (likely(XBUS_FLAGS(xbus, CONNECTED))) xframe_receive(xbus, xframe); else FREE_RECV_XFRAME(xbus, xframe); /* return to receive_pool */ @@ -637,14 +637,14 @@ /*------------------------- Bus Management -------------------------*/ xpd_t *xpd_of(const xbus_t *xbus, int xpd_num) { - if(!VALID_XPD_NUM(xpd_num)) + if (!VALID_XPD_NUM(xpd_num)) return NULL; return xbus->xpds[xpd_num]; } xpd_t *xpd_byaddr(const xbus_t *xbus, uint unit, uint subunit) { - if(unit > MAX_UNIT || subunit > MAX_SUBUNIT) + if (unit > MAX_UNIT || subunit > MAX_SUBUNIT) return NULL; return xbus->xpds[XPD_IDX(unit,subunit)]; } @@ -658,11 +658,11 @@ xpd_num = XPD_IDX(unit,subunit); XBUS_DBG(DEVICES, xbus, "XPD #%d\n", xpd_num); spin_lock_irqsave(&xbus->lock, flags); - if(!VALID_XPD_NUM(xpd_num)) { + if (!VALID_XPD_NUM(xpd_num)) { XBUS_ERR(xbus, "Bad xpd_num = %d\n", xpd_num); BUG(); } - if(xbus->xpds[xpd_num] != NULL) { + if (xbus->xpds[xpd_num] != NULL) { xpd_t *other = xbus->xpds[xpd_num]; XBUS_ERR(xbus, "xpd_num=%d is occupied by %p (%s)\n", @@ -677,7 +677,7 @@ atomic_inc(&xbus->num_xpds); spin_unlock_irqrestore(&xbus->lock, flags); /* Must be done out of atomic context */ - if(xpd_device_register(xbus, xpd) < 0) { + if (xpd_device_register(xbus, xpd) < 0) { XPD_ERR(xpd, "%s: xpd_device_register() failed\n", __FUNCTION__); /* FIXME: What to do? */ } @@ -690,15 +690,15 @@ unsigned long flags; XBUS_DBG(DEVICES, xbus, "XPD #%d\n", xpd_num); - if(!VALID_XPD_NUM(xpd_num)) { + if (!VALID_XPD_NUM(xpd_num)) { XBUS_ERR(xbus, "%s: Bad xpd_num = %d\n", __FUNCTION__, xpd_num); BUG(); } - if(xbus->xpds[xpd_num] == NULL) { + if (xbus->xpds[xpd_num] == NULL) { XBUS_ERR(xbus, "%s: slot xpd_num=%d is empty\n", __FUNCTION__, xpd_num); BUG(); } - if(xbus->xpds[xpd_num] != xpd) { + if (xbus->xpds[xpd_num] != xpd) { xpd_t *other = xbus->xpds[xpd_num]; XBUS_ERR(xbus, "%s: slot xpd_num=%d is occupied by %p (%s)\n", @@ -708,7 +708,7 @@ spin_lock_irqsave(&xbus->lock, flags); xpd->xbus = NULL; xbus->xpds[xpd_num] = NULL; - if(atomic_dec_and_test(&xbus->num_xpds)) + if (atomic_dec_and_test(&xbus->num_xpds)) xbus_setstate(xbus, XBUS_STATE_IDLE); spin_unlock_irqrestore(&xbus->lock, flags); return 0; @@ -731,7 +731,7 @@ int remaining_ports; proto_table = xproto_get(type); - if(!proto_table) { + if (!proto_table) { XBUS_NOTICE(xbus, "CARD %d: missing protocol table for type %d. Ignored.\n", unit, type); @@ -753,13 +753,13 @@ xops = &proto_table->xops; BUG_ON(!xops); xbus->worker->num_units += subunits - 1; - for(i = 0; i < subunits; i++) { + for (i = 0; i < subunits; i++) { int subunit_ports = proto_table->ports_per_subunit; - if(subunit_ports > remaining_ports) + if (subunit_ports > remaining_ports) subunit_ports = remaining_ports; remaining_ports -= proto_table->ports_per_subunit; - if(subunit_ports <= 0) { + if (subunit_ports <= 0) { XBUS_NOTICE(xbus, "Subunit XPD=%d%d without ports (%d of %d)\n", unit, @@ -769,7 +769,7 @@ ret = -ENODEV; goto out; } - if(!XBUS_IS(xbus, RECVD_DESC)) { + if (!XBUS_IS(xbus, RECVD_DESC)) { XBUS_NOTICE(xbus, "Cannot create XPD=%d%d in state %s\n", unit, @@ -783,14 +783,14 @@ i, type, subtype, subunit_ports); - if(!XBUS_IS(xbus, RECVD_DESC)) { + if (!XBUS_IS(xbus, RECVD_DESC)) { XBUS_ERR(xbus, "Aborting creation -- In bad state %s\n", xbus_statename(XBUS_STATE(xbus))); ret = -ENODEV; goto out; } ret = create_xpd(xbus, proto_table, unit, i, type, subtype, subunits, subunit_ports, port_dir); - if(ret < 0) { + if (ret < 0) { XBUS_ERR(xbus, "Creation of XPD=%d%d failed %d\n", unit, i, ret); goto out; @@ -807,10 +807,10 @@ int i; XBUS_INFO(xbus, "[%s] Release XPDS\n", xbus->label); - for(i = 0; i < MAX_XPDS; i++) { + for (i = 0; i < MAX_XPDS; i++) { xpd_t *xpd = xpd_of(xbus, i); - if(xpd) + if (xpd) put_xpd(__FUNCTION__, xpd); /* taken in xbus_xpd_bind() */ } } @@ -819,14 +819,14 @@ { int ret = -ENODEV; - if(CALL_XMETHOD(card_init, xpd->xbus, xpd) < 0) { + if (CALL_XMETHOD(card_init, xpd->xbus, xpd) < 0) { XPD_ERR(xpd, "Card Initialization failed\n"); goto out; } //CALL_XMETHOD(XPD_STATE, xpd->xbus, xpd, 0); /* Turn off all channels */ xpd->card_present = 1; CALL_XMETHOD(XPD_STATE, xpd->xbus, xpd, 1); /* Turn on all channels */ - if(!xpd_setstate(xpd, XPD_STATE_READY)) { + if (!xpd_setstate(xpd, XPD_STATE_READY)) { goto out; } XPD_INFO(xpd, "Initialized: %s\n", xpd->type_name); @@ -848,22 +848,22 @@ do_gettimeofday(&time_start); XBUS_DBG(DEVICES, xbus, "refcount_xbus=%d\n", refcount_xbus(xbus)); - for(unit = 0; unit < MAX_UNIT; unit++) { + for (unit = 0; unit < MAX_UNIT; unit++) { xpd = xpd_byaddr(xbus, unit, 0); - if(!xpd) + if (!xpd) continue; - if(run_initialize_registers(xpd) < 0) { + if (run_initialize_registers(xpd) < 0) { XBUS_ERR(xbus, "Register Initialization of card #%d failed\n", unit); goto err; } - for(subunit = 0; subunit < MAX_SUBUNIT; subunit++) { + for (subunit = 0; subunit < MAX_SUBUNIT; subunit++) { int ret; xpd = xpd_byaddr(xbus, unit, subunit); - if(!xpd) + if (!xpd) continue; xpd = get_xpd(__FUNCTION__, xpd); - if(!xpd) { + if (!xpd) { XBUS_ERR(xbus, "Aborting initialization. XPD-%d%d is gone.\n", unit, subunit); @@ -871,7 +871,7 @@ } ret = xpd_initialize(xpd); put_xpd(__FUNCTION__, xpd); - if(ret < 0) + if (ret < 0) goto err; } } @@ -925,16 +925,16 @@ card_desc->port_dir); spin_lock_irqsave(&xbus->worker->worker_lock, flags); KZFREE(card_desc); - if(ret) + if (ret) break; } spin_unlock_irqrestore(&worker->worker_lock, flags); - if(xbus_initialize(xbus) < 0) { + if (xbus_initialize(xbus) < 0) { XBUS_NOTICE(xbus, "Initialization failed. Leave unused. refcount_xbus=%d\n", refcount_xbus(xbus)); goto failed; } - if(!xbus_setstate(xbus, XBUS_STATE_READY)) { + if (!xbus_setstate(xbus, XBUS_STATE_READY)) { XBUS_NOTICE(xbus, "Illegal transition. Leave unused. refcount_xbus=%d\n", refcount_xbus(xbus)); goto failed; @@ -962,11 +962,11 @@ { struct xbus_workqueue *worker = xbus->worker; - if(!xbus) { + if (!xbus) { ERR("%s: xbus gone -- skip initialization\n", __FUNCTION__); return 0; } - if(down_trylock(&xbus->in_worker)) { + if (down_trylock(&xbus->in_worker)) { ERR("%s: xbus is disconnected -- skip initialization\n", __FUNCTION__); return 0; } @@ -979,7 +979,7 @@ #endif BUG_ON(!xbus); /* Now send it */ - if(!queue_work(worker->wq, &worker->xpds_init_work)) { + if (!queue_work(worker->wq, &worker->xpds_init_work)) { XBUS_ERR(xbus, "Failed to queue xpd initialization work\n"); up(&xbus->in_worker); return 0; @@ -998,7 +998,7 @@ BUG_ON(!worker); DBG(DEVICES, "%s\n", name); - if(!worker->xpds_init_done) { + if (!worker->xpds_init_done) { NOTICE("%s: worker(%s)->xpds_init_done=%d\n", __FUNCTION__, name, worker->xpds_init_done); } @@ -1021,11 +1021,11 @@ { xbus_t *xbus; - if(!worker) + if (!worker) return; worker_reset(worker); xbus = worker->xbus; - if(xbus) { + if (xbus) { XBUS_DBG(DEVICES, xbus, "Waiting for worker to finish...\n"); down(&xbus->in_worker); XBUS_DBG(DEVICES, xbus, "Waiting for worker to finish -- done\n"); @@ -1038,7 +1038,7 @@ } #ifdef CONFIG_PROC_FS #ifdef OLD_PROC - if(xbus->proc_xbus_dir && worker->proc_xbus_waitfor_xpds) { + if (xbus->proc_xbus_dir && worker->proc_xbus_waitfor_xpds) { XBUS_DBG(PROC, xbus, "Removing proc '%s'\n", PROC_XBUS_WAITFOR_XPDS); remove_proc_entry(PROC_XBUS_WAITFOR_XPDS, xbus->proc_xbus_dir); worker->proc_xbus_waitfor_xpds = NULL; @@ -1062,14 +1062,14 @@ struct xbus_workqueue *worker; xbus_t *xbus; - if((xbus = xbus_num(xbusno)) == NULL) + if ((xbus = xbus_num(xbusno)) == NULL) return NULL; get_xbus(__FUNCTION__, xbus); /* return in worker_destroy() */ BUG_ON(xbus->busname[0] == '\0'); /* No name? */ BUG_ON(xbus->worker != NULL); /* Hmmm... nested workers? */ XBUS_DBG(DEVICES, xbus, "\n"); worker = KZALLOC(sizeof(*worker), GFP_KERNEL); - if(!worker) + if (!worker) goto err; /* poll related variables */ spin_lock_init(&worker->worker_lock); @@ -1078,7 +1078,7 @@ worker->xbus = xbus; #ifdef CONFIG_PROC_FS #ifdef OLD_PROC - if(xbus->proc_xbus_dir) { + if (xbus->proc_xbus_dir) { worker->proc_xbus_waitfor_xpds = create_proc_read_entry( PROC_XBUS_WAITFOR_XPDS, 0444, xbus->proc_xbus_dir, @@ -1093,7 +1093,7 @@ #endif #endif worker->wq = create_singlethread_workqueue(xbus->busname); - if(!worker->wq) { + if (!worker->wq) { XBUS_ERR(xbus, "Failed to create worker workqueue.\n"); goto err; } @@ -1111,7 +1111,7 @@ XBUS_DBG(DEVICES, xbus, "%s flag %d\n", (on) ? "Set" : "Clear", flagbit); - if(on) + if (on) set_bit(flagbit, &(xbus->transport.transport_flags)); else clear_bit(flagbit, &(xbus->transport.transport_flags)); @@ -1126,48 +1126,48 @@ int state_flip = 0; spin_lock_irqsave(&xbus->transport.state_lock, flags); - if(newstate == XBUS_STATE(xbus)) { + if (newstate == XBUS_STATE(xbus)) { XBUS_DBG(DEVICES, xbus, "stay at %s\n", xbus_statename(newstate)); goto out; } /* Sanity tests */ - switch(newstate) { + switch (newstate) { case XBUS_STATE_START: goto bad_state; case XBUS_STATE_IDLE: - if(!XBUS_IS(xbus, START) && + if (!XBUS_IS(xbus, START) && !XBUS_IS(xbus, DEACTIVATED)) goto bad_state; break; case XBUS_STATE_SENT_REQUEST: - if(!XBUS_IS(xbus, IDLE) && + if (!XBUS_IS(xbus, IDLE) && !XBUS_IS(xbus, SENT_REQUEST)) goto bad_state; break; case XBUS_STATE_RECVD_DESC: - if(!XBUS_IS(xbus, SENT_REQUEST)) + if (!XBUS_IS(xbus, SENT_REQUEST)) goto bad_state; break; case XBUS_STATE_READY: - if(!XBUS_IS(xbus, RECVD_DESC)) + if (!XBUS_IS(xbus, RECVD_DESC)) goto bad_state; state_flip = 1; /* We are good */ break; case XBUS_STATE_DEACTIVATING: - if(XBUS_IS(xbus, DEACTIVATING)) + if (XBUS_IS(xbus, DEACTIVATING)) goto bad_state; - if(XBUS_IS(xbus, DEACTIVATED)) + if (XBUS_IS(xbus, DEACTIVATED)) goto bad_state; break; case XBUS_STATE_DEACTIVATED: - if(!XBUS_IS(xbus, DEACTIVATING)) + if (!XBUS_IS(xbus, DEACTIVATING)) goto bad_state; break; case XBUS_STATE_FAIL: - if(XBUS_IS(xbus, DEACTIVATING)) + if (XBUS_IS(xbus, DEACTIVATING)) goto bad_state; - if(XBUS_IS(xbus, DEACTIVATED)) + if (XBUS_IS(xbus, DEACTIVATED)) goto bad_state; break; default: @@ -1178,16 +1178,16 @@ XBUS_DBG(DEVICES, xbus, "%s -> %s\n", xbus_statename(XBUS_STATE(xbus)), xbus_statename(newstate)); - if(xbus->transport.xbus_state == XBUS_STATE_READY && newstate != XBUS_STATE_READY) + if (xbus->transport.xbus_state == XBUS_STATE_READY && newstate != XBUS_STATE_READY) state_flip = -1; /* We became bad */ xbus->transport.xbus_state = newstate; ret = 1; out: spin_unlock_irqrestore(&xbus->transport.state_lock, flags); /* Should be sent out of spinlocks */ - if(state_flip > 0) + if (state_flip > 0) astribank_uevent_send(xbus, KOBJ_ONLINE); - else if(state_flip < 0) + else if (state_flip < 0) astribank_uevent_send(xbus, KOBJ_OFFLINE); return ret; bad_state: @@ -1237,7 +1237,7 @@ { BUG_ON(!xbus); XBUS_INFO(xbus, "[%s] Deactivating\n", xbus->label); - if(!xbus_setstate(xbus, XBUS_STATE_DEACTIVATING)) + if (!xbus_setstate(xbus, XBUS_STATE_DEACTIVATING)) return; xbus_request_sync(xbus, SYNC_MODE_NONE); /* no more ticks */ xbus_request_removal(xbus); @@ -1279,15 +1279,15 @@ int i; xbus = KZALLOC(sizeof(xbus_t), GFP_KERNEL); - if(!xbus) { + if (!xbus) { ERR("%s: out of memory\n", __FUNCTION__); return NULL; } spin_lock_irqsave(&xbuses_lock, flags); - for(i = 0; i < MAX_BUSES; i++) - if(xbuses_array[i].xbus == NULL) + for (i = 0; i < MAX_BUSES; i++) + if (xbuses_array[i].xbus == NULL) break; - if(i >= MAX_BUSES) { + if (i >= MAX_BUSES) { ERR("%s: No free slot for new bus. i=%d\n", __FUNCTION__, i); KZFREE(xbus); xbus = NULL; @@ -1307,7 +1307,7 @@ unsigned long flags; uint num; - if(!xbus) + if (!xbus) return; XBUS_DBG(DEVICES, xbus, "Free\n"); spin_lock_irqsave(&xbuses_lock, flags); @@ -1316,8 +1316,8 @@ BUG_ON(xbus != xbuses_array[num].xbus); spin_unlock_irqrestore(&xbuses_lock, flags); #ifdef XPP_DEBUGFS - if(xbus->debugfs_dir) { - if(xbus->debugfs_file) { + if (xbus->debugfs_dir) { + if (xbus->debugfs_file) { XBUS_DBG(GENERAL, xbus, "Removing debugfs file\n"); debugfs_remove(xbus->debugfs_file); } @@ -1326,14 +1326,14 @@ } #endif #ifdef CONFIG_PROC_FS - if(xbus->proc_xbus_dir) { - if(xbus->proc_xbus_summary) { + if (xbus->proc_xbus_dir) { + if (xbus->proc_xbus_summary) { XBUS_DBG(PROC, xbus, "Removing proc '%s'\n", PROC_XBUS_SUMMARY); remove_proc_entry(PROC_XBUS_SUMMARY, xbus->proc_xbus_dir); xbus->proc_xbus_summary = NULL; } #ifdef PROTOCOL_DEBUG - if(xbus->proc_xbus_command) { + if (xbus->proc_xbus_command) { XBUS_DBG(PROC, xbus, "Removing proc '%s'\n", PROC_XBUS_COMMAND); remove_proc_entry(PROC_XBUS_COMMAND, xbus->proc_xbus_dir); xbus->proc_xbus_command = NULL; @@ -1358,7 +1358,7 @@ BUG_ON(!ops); xbus = xbus_alloc(); - if(!xbus) { + if (!xbus) { ERR("%s: Failed allocating new xbus\n", __FUNCTION__); module_put(THIS_MODULE); return NULL; @@ -1377,7 +1377,7 @@ atomic_set(&xbus->num_xpds, 0); xbus->sync_mode = SYNC_MODE_NONE; err = xbus_sysfs_create(xbus); - if(err) { + if (err) { XBUS_ERR(xbus, "SYSFS creation failed: %d\n", err); goto nobus; } @@ -1385,7 +1385,7 @@ #ifdef CONFIG_PROC_FS XBUS_DBG(PROC, xbus, "Creating xbus proc directory\n"); xbus->proc_xbus_dir = proc_mkdir(xbus->busname, xpp_proc_toplevel); - if(!xbus->proc_xbus_dir) { + if (!xbus->proc_xbus_dir) { XBUS_ERR(xbus, "Failed to create proc directory\n"); err = -EIO; goto nobus; @@ -1414,12 +1414,12 @@ #endif #ifdef XPP_DEBUGFS xbus->debugfs_dir = debugfs_create_dir(xbus->busname, debugfs_root); - if(!xbus->debugfs_dir) { + if (!xbus->debugfs_dir) { XBUS_ERR(xbus, "Failed to create debugfs directory\n"); goto nobus; } xbus->debugfs_file = debugfs_create_file("dchannel", S_IFREG|S_IRUGO|S_IWUSR, xbus->debugfs_dir, xbus, &debugfs_operations); - if(!xbus->debugfs_file) { + if (!xbus->debugfs_file) { XBUS_ERR(xbus, "Failed to create dchannel file\n"); goto nobus; } @@ -1435,7 +1435,7 @@ * before /proc/XBUS-??/waitfor_xpds tries to get created. */ xbus->worker = worker_new(xbus->num); - if(!xbus->worker) { + if (!xbus->worker) { ERR("Failed to allocate worker\n"); goto nobus; } @@ -1452,7 +1452,7 @@ int i; XBUS_DBG(GENERAL, xbus, "Reseting counters\n"); - for(i = 0; i < XBUS_COUNTER_MAX; i++) { + for (i = 0; i < XBUS_COUNTER_MAX; i++) { xbus->counters[i] = 0; } } @@ -1486,7 +1486,7 @@ int i = (int)((unsigned long)data); xbus = xbus_num(i); - if(!xbus) + if (!xbus) goto out; xbus = get_xbus(__FUNCTION__, xbus); /* until end of xbus_read_proc */ spin_lock_irqsave(&xbus->lock, flags); @@ -1503,7 +1503,7 @@ len += xbus_fill_proc_queue(page + len, &xbus->command_queue); len += xbus_fill_proc_queue(page + len, &xbus->receive_queue); len += xbus_fill_proc_queue(page + len, &xbus->pcm_tospan); - if(rx_tasklet) { + if (rx_tasklet) { len += sprintf(page + len, "\ncpu_rcv_intr: "); for_each_online_cpu(i) len += sprintf(page + len, "%5d ", xbus->cpu_rcv_intr[i]); @@ -1532,7 +1532,7 @@ len += sprintf(page + len, "\tPCM RX: min=%ld max=%ld\n", xbus->min_rx_sync, xbus->max_rx_sync); len += sprintf(page + len, "COUNTERS:\n"); - for(i = 0; i < XBUS_COUNTER_MAX; i++) { + for (i = 0; i < XBUS_COUNTER_MAX; i++) { len += sprintf(page + len, "\t%-15s = %d\n", xbus_counters[i].name, xbus->counters[i]); } @@ -1556,12 +1556,12 @@ { struct xbus_workqueue *worker; - if(XBUS_IS(xbus, FAIL)) + if (XBUS_IS(xbus, FAIL)) return 1; /* Nothing to wait for */ - if(!XBUS_IS(xbus, RECVD_DESC)) + if (!XBUS_IS(xbus, RECVD_DESC)) return 1; /* We are not in the initialization phase */ worker = xbus->worker; - if(worker->xpds_init_done) + if (worker->xpds_init_done) return 1; /* All good */ /* Keep waiting */ return 0; @@ -1579,7 +1579,7 @@ * So by now it exists and initialized. */ xbus = get_xbus(__FUNCTION__, xbus); /* until end of waitfor_xpds_show() */ - if(!xbus) + if (!xbus) return -ENODEV; worker = xbus->worker; BUG_ON(!worker); @@ -1591,11 +1591,11 @@ worker->wait_for_xpd_initialization, xpds_done(xbus), INITIALIZATION_TIMEOUT); - if(ret == 0) { + if (ret == 0) { XBUS_ERR(xbus, "Card Initialization Timeout\n"); len = -ETIMEDOUT; goto out; - } else if(ret < 0) { + } else if (ret < 0) { XBUS_ERR(xbus, "Card Initialization Interrupted %d\n", ret); len = ret; goto out; @@ -1604,7 +1604,7 @@ "Finished initialization of %d XPD's in %d seconds.\n", worker->num_units_initialized, (INITIALIZATION_TIMEOUT - ret)/HZ); - if(XBUS_IS(xbus, FAIL)) { + if (XBUS_IS(xbus, FAIL)) { len += sprintf(buf, "FAILED: %s\n", xbus->busname); } else { spin_lock_irqsave(&xbus->lock, flags); @@ -1624,12 +1624,12 @@ int len = 0; xbus_t *xbus = data; - if(!xbus) + if (!xbus) goto out; XBUS_NOTICE(xbus, "%s: DEPRECATED: %s[%d] read from /proc interface instead of /sys\n", __FUNCTION__, current->comm, current->tgid); /* first handle special cases */ - if(!count || off) + if (!count || off) goto out; len = waitfor_xpds(xbus, page); out: @@ -1659,15 +1659,15 @@ const size_t max_len = xbus->transport.max_send_size; const size_t max_text = max_len * 3 + 10; - if(count > max_text) { + if (count > max_text) { XBUS_ERR(xbus, "%s: line too long (%ld > %zd)\n", __FUNCTION__, count, max_len); return -EFBIG; } /* 3 bytes per hex-digit and space */ buf = kmalloc(max_text, GFP_KERNEL); - if(!buf) + if (!buf) return -ENOMEM; - if(copy_from_user(buf, buffer, count)) { + if (copy_from_user(buf, buffer, count)) { count = -EINVAL; goto out; } @@ -1679,15 +1679,15 @@ * as the binary representation is shorter */ q = pack_start = buf; - for(p = buf; *p;) { + for (p = buf; *p;) { int val; char hexdigit[3]; - while(*p && isspace(*p)) // skip whitespace + while (*p && isspace(*p)) // skip whitespace p++; - if(!(*p)) + if (!(*p)) break; - if(!isxdigit(*p)) { + if (!isxdigit(*p)) { XBUS_ERR(xbus, "%s: bad hex value ASCII='0x%X' at position %ld\n", __FUNCTION__, *p, (long)(p - buf)); count = -EINVAL; @@ -1696,9 +1696,9 @@ hexdigit[0] = *p++; hexdigit[1] = '\0'; hexdigit[2] = '\0'; - if(isxdigit(*p)) + if (isxdigit(*p)) hexdigit[1] = *p++; - if(sscanf(hexdigit, "%2X", &val) != 1) { + if (sscanf(hexdigit, "%2X", &val) != 1) { XBUS_ERR(xbus, "%s: bad hex value '%s' at position %ld\n", __FUNCTION__, hexdigit, (long)(p - buf)); count = -EINVAL; @@ -1709,11 +1709,11 @@ } len = q - pack_start; xframe = ALLOC_SEND_XFRAME(xbus); - if(!xframe) { + if (!xframe) { count = -ENOMEM; goto out; } - if(len > max_len) + if (len > max_len) len = max_len; atomic_set(&xframe->frame_len, len); memcpy(xframe->packets, pack_start, len); /* FIXME: checksum? */ @@ -1733,10 +1733,10 @@ int i; spin_lock_irqsave(&xbuses_lock, flags); - for(i = 0; i < MAX_BUSES; i++) { + for (i = 0; i < MAX_BUSES; i++) { xbus_t *xbus = xbus_num(i); - if(xbus) { + if (xbus) { len += sprintf(page + len, "%s: CONNECTOR=%s LABEL=[%s] STATUS=%s\n", xbus->busname, xbus->connector, @@ -1791,7 +1791,7 @@ atomic_read(&xbus->transport.transport_refcount)); ret = wait_event_interruptible(xbus->transport.transport_unused, atomic_read(&xbus->transport.transport_refcount) == 0); - if(ret) + if (ret) XBUS_ERR(xbus, "Waiting for transport_refcount interrupted!!!\n"); xbus->transport.ops = NULL; xbus->transport.priv = NULL; @@ -1804,7 +1804,7 @@ BUG_ON(!xbus); atomic_inc(&xbus->transport.transport_refcount); ops = xbus->transport.ops; - if(!ops) + if (!ops) atomic_dec(&xbus->transport.transport_refcount); /* fall through */ return ops; @@ -1817,7 +1817,7 @@ BUG_ON(!xbus); ops = xbus->transport.ops; BUG_ON(!ops); - if(atomic_dec_and_test(&xbus->transport.transport_refcount)) + if (atomic_dec_and_test(&xbus->transport.transport_refcount)) wake_up(&xbus->transport.transport_unused); } @@ -1826,13 +1826,13 @@ { finalize_xbuses_array(); #ifdef XPP_DEBUGFS - if(debugfs_root) { + if (debugfs_root) { DBG(GENERAL, "Removing xpp from debugfs\n"); debugfs_remove(debugfs_root); } #endif #ifdef CONFIG_PROC_FS - if(proc_xbuses) { + if (proc_xbuses) { DBG(PROC, "Removing " PROC_XBUSES " from proc\n"); remove_proc_entry(PROC_XBUSES, xpp_proc_toplevel); proc_xbuses = NULL; @@ -1863,13 +1863,13 @@ #ifdef XPP_DEBUGFS DBG(GENERAL, "Creating debugfs xpp root\n"); debugfs_root = debugfs_create_dir("xpp", NULL); - if(!debugfs_root) { + if (!debugfs_root) { ERR("Failed to create debugfs root\n"); ret = -EFAULT; goto err; } #endif - if((ret = xpp_driver_init()) < 0) + if ((ret = xpp_driver_init()) < 0) goto err; return 0; err: @@ -1882,7 +1882,7 @@ { int i; - for(i = 0; i < MAX_BUSES; i++) + for (i = 0; i < MAX_BUSES; i++) BUG_ON(xbus_num(i)); xbus_core_cleanup(); xpp_driver_exit(); Index: drivers/dahdi/xpp/xbus-pcm.c =================================================================== --- drivers/dahdi/xpp/xbus-pcm.c (revision 7493) +++ drivers/dahdi/xpp/xbus-pcm.c (working copy) @@ -85,9 +85,9 @@ unsigned long flags; spin_lock_irqsave(&ticker->lock, flags); - if(cycle < SYNC_ADJ_QUICK) + if (cycle < SYNC_ADJ_QUICK) cycle = SYNC_ADJ_QUICK; - if(cycle > SYNC_ADJ_SLOW) + if (cycle > SYNC_ADJ_SLOW) cycle = SYNC_ADJ_SLOW; ticker->cycle = cycle; spin_unlock_irqrestore(&ticker->lock, flags); @@ -110,7 +110,7 @@ spin_lock_irqsave(&ticker->lock, flags); ticker->last_sample.tv = *t; - if((ticker->count % ticker->cycle) == ticker->cycle - 1) { /* rate adjust */ + if ((ticker->count % ticker->cycle) == ticker->cycle - 1) { /* rate adjust */ usec = (long)usec_diff( &ticker->last_sample.tv, &ticker->first_sample.tv); @@ -155,9 +155,9 @@ #ifdef SAMPLE_TICKS static void sample_tick(xbus_t *xbus, int sample) { - if(!xbus->sample_running) + if (!xbus->sample_running) return; - if(xbus->sample_pos < SAMPLE_SIZE) + if (xbus->sample_pos < SAMPLE_SIZE) xbus->sample_ticks[xbus->sample_pos++] = sample; else { xbus->sample_running = 0; @@ -177,24 +177,24 @@ spin_lock_irqsave(&driftinfo->lock, flags); cycled = xpp_ticker_step(&xbus->ticker, tv); - if(ref_ticker && ref_ticker != &xbus->ticker && syncer && xbus->sync_mode == SYNC_MODE_PLL) { + if (ref_ticker && ref_ticker != &xbus->ticker && syncer && xbus->sync_mode == SYNC_MODE_PLL) { int new_delta_tick = ticker->count - ref_ticker->count; int lost_ticks = new_delta_tick - driftinfo->delta_tick; driftinfo->delta_tick = new_delta_tick; - if(lost_ticks) { + if (lost_ticks) { static int rate_limit; driftinfo->lost_ticks++; driftinfo->lost_tick_count += abs(lost_ticks); - if((rate_limit++ % 1003) == 0) { + if ((rate_limit++ % 1003) == 0) { XBUS_DBG(SYNC, xbus, "Lost %d tick%s\n", lost_ticks, (abs(lost_ticks) > 1) ? "s": ""); } ticker_set_cycle(ticker, SYNC_ADJ_QUICK); - if(abs(lost_ticks) > 100) + if (abs(lost_ticks) > 100) ticker->count = ref_ticker->count; } else { long usec_delta; @@ -205,17 +205,17 @@ &ref_ticker->last_sample.tv); usec_delta -= driftinfo->wanted_offset; sample_tick(xbus, usec_delta); - if(abs(usec_delta) > 300) { + if (abs(usec_delta) > 300) { /* * We are close to the edge, send a brutal * fix, and skip calculation until next time. */ - if(usec_delta > 0 && xbus->sync_adjustment > -SYNC_ADJ_MAX) { + if (usec_delta > 0 && xbus->sync_adjustment > -SYNC_ADJ_MAX) { XBUS_DBG(SYNC, xbus, "Pullback usec_delta=%ld\n", usec_delta); driftinfo->kicks_down++; send_drift(xbus, -SYNC_ADJ_MAX); /* emergency push */ } - if(usec_delta < 0 && xbus->sync_adjustment < SYNC_ADJ_MAX) { + if (usec_delta < 0 && xbus->sync_adjustment < SYNC_ADJ_MAX) { XBUS_DBG(SYNC, xbus, "Pushback usec_delta=%ld\n", usec_delta); driftinfo->kicks_up++; send_drift(xbus, SYNC_ADJ_MAX); /* emergency push */ @@ -224,26 +224,26 @@ nofix = 1; } else { /* good data, use it */ - if(usec_delta > driftinfo->delta_max) + if (usec_delta > driftinfo->delta_max) driftinfo->delta_max = usec_delta; - if(usec_delta < driftinfo->delta_min) + if (usec_delta < driftinfo->delta_min) driftinfo->delta_min = usec_delta; } - if(!nofix && cycled) { + if (!nofix && cycled) { int offset = 0; driftinfo->median = (driftinfo->delta_max + driftinfo->delta_min) / 2; driftinfo->jitter = driftinfo->delta_max - driftinfo->delta_min; - if(abs(driftinfo->median) >= 150) { /* more than 1 usb uframe */ + if (abs(driftinfo->median) >= 150) { /* more than 1 usb uframe */ int factor = abs(driftinfo->median) / 125; factor = 1 + (factor * 8000) / ticker->cycle; - if(driftinfo->median > 0) + if (driftinfo->median > 0) offset = driftinfo->calc_drift - factor; else offset = driftinfo->calc_drift + factor; /* for large median, push some more */ - if(abs(driftinfo->median) >= 300) { /* more than 2 usb uframes */ + if (abs(driftinfo->median) >= 300) { /* more than 2 usb uframes */ ticker_set_cycle(ticker, SYNC_ADJ_QUICK); XBUS_NOTICE(xbus, "Back to quick: median=%d\n", @@ -260,12 +260,12 @@ driftinfo->jitter, driftinfo->median, offset); - if(offset < -SYNC_ADJ_MAX) + if (offset < -SYNC_ADJ_MAX) offset = -SYNC_ADJ_MAX; - if(offset > SYNC_ADJ_MAX) + if (offset > SYNC_ADJ_MAX) offset = SYNC_ADJ_MAX; xbus->sync_adjustment_offset = offset; - if(xbus != syncer && xbus->sync_adjustment != offset) + if (xbus != syncer && xbus->sync_adjustment != offset) send_drift(xbus, offset); driftinfo_recalc(driftinfo); } @@ -282,7 +282,7 @@ [SYNC_MODE_PLL] = "PLL", [SYNC_MODE_QUERY] = "QUERY", }; - if(mode >= ARRAY_SIZE(sync_mode_names)) + if (mode >= ARRAY_SIZE(sync_mode_names)) return NULL; return sync_mode_names[mode]; } @@ -292,20 +292,20 @@ unsigned long flags; spin_lock_irqsave(&ref_ticker_lock, flags); - if(!xbus) { /* Special case, no more syncers */ + if (!xbus) { /* Special case, no more syncers */ DBG(SYNC, "No more syncers\n"); syncer = NULL; - if(ref_ticker != &dahdi_ticker) + if (ref_ticker != &dahdi_ticker) ref_ticker = NULL; goto out; } - if(syncer != xbus && on) { + if (syncer != xbus && on) { XBUS_DBG(SYNC, xbus, "New syncer\n"); syncer = xbus; - } else if(syncer == xbus && !on) { + } else if (syncer == xbus && !on) { XBUS_DBG(SYNC, xbus, "Lost syncer\n"); syncer = NULL; - if(ref_ticker != &dahdi_ticker) + if (ref_ticker != &dahdi_ticker) ref_ticker = NULL; } else XBUS_DBG(SYNC, xbus, "ignore %s (current syncer: %s)\n", @@ -323,22 +323,22 @@ BUG_ON(!xbus); do_gettimeofday(&now); xbus_command_queue_tick(xbus); - if(!xbus->self_ticking) + if (!xbus->self_ticking) mod_timer(&xbus->command_timer, jiffies + 1); /* Must be 1KHz rate */ } void xbus_set_command_timer(xbus_t *xbus, bool on) { XBUS_DBG(SYNC, xbus, "%s\n", (on)?"ON":"OFF"); - if(on) { - if(!timer_pending(&xbus->command_timer)) { + if (on) { + if (!timer_pending(&xbus->command_timer)) { XBUS_DBG(SYNC, xbus, "add_timer\n"); xbus->command_timer.function = xbus_command_timer; xbus->command_timer.data = (unsigned long)xbus; xbus->command_timer.expires = jiffies + 1; add_timer(&xbus->command_timer); } - } else if(timer_pending(&xbus->command_timer)) { + } else if (timer_pending(&xbus->command_timer)) { XBUS_DBG(SYNC, xbus, "del_timer\n"); del_timer(&xbus->command_timer); } @@ -354,13 +354,13 @@ spin_lock_irqsave(&xbus->lock, flags); xbus->sync_adjustment = (signed char)drift; - if(xbus->sync_mode == mode) { + if (xbus->sync_mode == mode) { /* XBUS_DBG(SYNC, xbus, "Already in mode '%s'. Ignored\n", sync_mode_name(mode)); */ goto out; } XBUS_DBG(SYNC, xbus, "Mode %s (%d), drift=%d (pcm_rx_counter=%d)\n", sync_mode_name(mode), mode, drift, atomic_read(&xbus->pcm_rx_counter)); - switch(mode) { + switch (mode) { case SYNC_MODE_AB: xbus->sync_mode = mode; xbus_set_command_timer(xbus, 0); @@ -392,7 +392,7 @@ BUG_ON(!xbus); XBUS_DBG(SYNC, xbus, "sent request (mode=%d)\n", mode); CALL_PROTO(GLOBAL, SYNC_SOURCE, xbus, NULL, mode, 0); - if(mode == SYNC_MODE_NONE) { + if (mode == SYNC_MODE_NONE) { xbus_set_command_timer(xbus, 1); } } @@ -402,10 +402,10 @@ int i; //DBG(SYNC, "%d\n", atomic_read(&xpp_tick_counter)); - for(i = 0; i < MAX_BUSES; i++) { + for (i = 0; i < MAX_BUSES; i++) { xbus_t *xbus = xbus_num(i); - if(!xbus) + if (!xbus) continue; /* * Don't send to non self_ticking Astribanks: @@ -413,8 +413,8 @@ * - Or maybe they didn't answer us in the first place (e.g: wrong firmware version, etc). */ - if(xbus->self_ticking) { - if(!XBUS_FLAGS(xbus, CONNECTED)) { + if (xbus->self_ticking) { + if (!XBUS_FLAGS(xbus, CONNECTED)) { XBUS_DBG(GENERAL, xbus, "Dropped packet. Is shutting down.\n"); } else { @@ -432,14 +432,14 @@ BUG_ON(abs(drift) > SYNC_ADJ_MAX); do_gettimeofday(&now); - if(drift > xbus->sync_adjustment) + if (drift > xbus->sync_adjustment) msg = "up"; else msg = "down"; XBUS_DBG(SYNC, xbus, "%sDRIFT adjust %s (%d) (last update %ld seconds ago)\n", (disable_pll_sync) ? "Fake " : "", msg, drift, now.tv_sec - xbus->pll_updated_at); - if(!disable_pll_sync) + if (!disable_pll_sync) CALL_PROTO(GLOBAL, SYNC_SOURCE, xbus, NULL, SYNC_MODE_PLL, drift); xbus->pll_updated_at = now.tv_sec; } @@ -450,7 +450,7 @@ do_gettimeofday(&now); atomic_inc(&xpp_tick_counter); - if((atomic_read(&xpp_tick_counter) % BIG_TICK_INTERVAL) == 0) + if ((atomic_read(&xpp_tick_counter) % BIG_TICK_INTERVAL) == 0) reset_sync_counters(); xpp_ticker_step(&global_ticks_series, &now); } @@ -462,35 +462,35 @@ static int redundant_ticks; /* for extra spans */ struct timeval now; - if(!force_dahdi_sync) + if (!force_dahdi_sync) goto noop; do_gettimeofday(&now); BUG_ON(!xpd); /* * Detect if any of our spans is dahdi sync master */ - if(is_master) { + if (is_master) { static int rate_limit; - if((rate_limit++ % 10003) == 0) + if ((rate_limit++ % 10003) == 0) XPD_NOTICE(xpd, "Is a DAHDI sync master: ignore sync from DAHDI\n"); goto noop; } /* Now we know for sure someone else is dahdi sync master */ - if(syncer) { + if (syncer) { static int rate_limit; - if((rate_limit++ % 5003) == 0) + if ((rate_limit++ % 5003) == 0) XBUS_DBG(SYNC, syncer, "is a SYNCer: ignore sync from DAHDI\n"); goto noop; } /* ignore duplicate calls from all our registered spans */ - if((redundant_ticks++ % total_registered_spans()) != 0) { + if ((redundant_ticks++ % total_registered_spans()) != 0) { #if 0 static int rate_limit; - if((rate_limit++ % 1003) < 16) + if ((rate_limit++ % 1003) < 16) XPD_NOTICE(xpd, "boop (%d)\n", dahdi_tick_count); #endif goto noop; @@ -533,16 +533,16 @@ * they'll revert it to PLL instead of AB. */ spin_lock_irqsave(&ref_ticker_lock, flags); - if(syncer) + if (syncer) xbus_drift_clear(syncer); /* Clean old data */ - if(new_syncer) { + if (new_syncer) { XBUS_DBG(SYNC, new_syncer, "pcm_rx_counter=%d\n", atomic_read(&new_syncer->pcm_rx_counter)); force_dahdi_sync = 0; ref_ticker = &new_syncer->ticker; xbus_drift_clear(new_syncer); /* Clean new data */ xbus_request_sync(new_syncer, SYNC_MODE_AB); - } else if(force_dahdi_sync) { + } else if (force_dahdi_sync) { ref_ticker = &dahdi_ticker; } else { ref_ticker = NULL; @@ -550,12 +550,12 @@ spin_unlock_irqrestore(&ref_ticker_lock, flags); DBG(SYNC, "stop unwanted syncers\n"); /* Shut all down except the wanted sync master */ - for(i = 0; i < MAX_BUSES; i++) { + for (i = 0; i < MAX_BUSES; i++) { xbus_t *xbus = xbus_num(i); - if(!xbus) + if (!xbus) continue; - if(XBUS_FLAGS(xbus, CONNECTED) && xbus != new_syncer) { - if(xbus->self_ticking) + if (XBUS_FLAGS(xbus, CONNECTED) && xbus != new_syncer) { + if (xbus->self_ticking) xbus_request_sync(xbus, SYNC_MODE_PLL); else XBUS_DBG(SYNC, xbus, "Not self_ticking yet. Ignore\n"); @@ -571,36 +571,36 @@ xpd_t *best_xpd = NULL; xbus_t *the_xbus = NULL; - for(i = 0; i < MAX_BUSES; i++) { + for (i = 0; i < MAX_BUSES; i++) { xbus_t *xbus = xbus_num(i); - if(!xbus) + if (!xbus) continue; - if(XBUS_IS(xbus, READY)) { - if(!the_xbus) + if (XBUS_IS(xbus, READY)) { + if (!the_xbus) the_xbus = xbus; /* First candidate */ - for(j = 0; j < MAX_XPDS; j++) { + for (j = 0; j < MAX_XPDS; j++) { xpd_t *xpd = xpd_of(xbus, j); - if(!xpd || !xpd->card_present) + if (!xpd || !xpd->card_present) continue; - if(xpd->timing_priority > 0 && xpd->timing_priority < timing_priority) { + if (xpd->timing_priority > 0 && xpd->timing_priority < timing_priority) { timing_priority = xpd->timing_priority; best_xpd = xpd; } } } } - if(best_xpd) { + if (best_xpd) { the_xbus = best_xpd->xbus; XPD_DBG(SYNC, best_xpd, "%s: elected with priority %d\n", msg, timing_priority); - } else if(the_xbus) { + } else if (the_xbus) { XBUS_DBG(SYNC, the_xbus, "%s: elected\n", msg); } else { DBG(SYNC, "%s: No more syncers\n", msg); xpp_set_syncer(NULL, 0); the_xbus = NULL; } - if(the_xbus != syncer) + if (the_xbus != syncer) update_sync_master(the_xbus, force_dahdi_sync); } @@ -635,13 +635,13 @@ pcm_mask &= ~xpd->digital_inputs; pcm_mask &= ~xpd->digital_outputs; for_each_line(xpd, i) - if(IS_SET(pcm_mask, i)) + if (IS_SET(pcm_mask, i)) line_count++; /* * FIXME: Workaround a bug in sync code of the Astribank. * Send dummy PCM for sync. */ - if(xpd->addr.unit == 0 && pcm_mask == 0) { + if (xpd->addr.unit == 0 && pcm_mask == 0) { pcm_mask = BIT(0); line_count = 1; } @@ -668,7 +668,7 @@ static u_char beep_alt[] = { 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, /* silence */ }; - if(alternate) { + if (alternate) { which = num % ARRAY_SIZE(beep_alt); snd = &beep_alt[which]; } else { @@ -685,9 +685,9 @@ for (i = 0;i < xpd->span.channels; i++) { struct dahdi_chan *chan = XPD_CHAN(xpd, i); - if(unlikely(IS_SET(xpd->digital_signalling, i))) /* Don't echo cancel BRI D-chans */ + if (unlikely(IS_SET(xpd->digital_signalling, i))) /* Don't echo cancel BRI D-chans */ continue; - if(!IS_SET(xpd->wanted_pcm_mask, i)) /* No ec for unwanted PCM */ + if (!IS_SET(xpd->wanted_pcm_mask, i)) /* No ec for unwanted PCM */ continue; dahdi_ec_chunk(chan, chan->readchunk, xpd->ec_chunk2[i]); memcpy(xpd->ec_chunk2[i], xpd->ec_chunk1[i], DAHDI_CHUNKSIZE); @@ -731,15 +731,15 @@ * ignore the channels of the other xpd's in the same unit. */ for (i = 0; i < CHANNELS_PERXPD; i++) - if(IS_SET(lines, i)) + if (IS_SET(lines, i)) count++; /* FRAMES: include opcode in calculation */ good_len = RPACKET_HEADERSIZE + sizeof(xpp_line_t) + count * 8; - if(XPACKET_LEN(pack) != good_len) { + if (XPACKET_LEN(pack) != good_len) { static int rate_limit = 0; XPD_COUNTER(xpd, RECV_ERRORS)++; - if((rate_limit++ % 1000) <= 10) { + if ((rate_limit++ % 1000) <= 10) { XPD_ERR(xpd, "BAD PCM REPLY: packet_len=%d (should be %d), count=%d\n", XPACKET_LEN(pack), good_len, count); dump_packet("BAD PCM REPLY", pack, 1); @@ -759,29 +759,29 @@ spin_lock_irqsave(&xbus->lock, flags); do_gettimeofday(&now); - if(unlikely(disable_pcm || !XBUS_IS(xbus, READY))) + if (unlikely(disable_pcm || !XBUS_IS(xbus, READY))) goto dropit; - if(XPACKET_ADDR_SYNC((xpacket_t *)xframe->packets)) { + if (XPACKET_ADDR_SYNC((xpacket_t *)xframe->packets)) { usec = usec_diff(&now, &xbus->last_tx_sync); xbus->last_tx_sync = now; /* ignore startup statistics */ - if(likely(atomic_read(&xbus->pcm_rx_counter) > BIG_TICK_INTERVAL)) { - if(abs(usec - 1000) > TICK_TOLERANCE) { + if (likely(atomic_read(&xbus->pcm_rx_counter) > BIG_TICK_INTERVAL)) { + if (abs(usec - 1000) > TICK_TOLERANCE) { static int rate_limit; - if((rate_limit++ % 5003) == 0) + if ((rate_limit++ % 5003) == 0) XBUS_DBG(SYNC, xbus, "Bad PCM TX timing(%d): usec=%ld.\n", rate_limit, usec); } - if(usec > xbus->max_tx_sync) + if (usec > xbus->max_tx_sync) xbus->max_tx_sync = usec; - if(usec < xbus->min_tx_sync) + if (usec < xbus->min_tx_sync) xbus->min_tx_sync = usec; } } spin_unlock_irqrestore(&xbus->lock, flags); /* OK, really send it */ - if(debug & DBG_PCM ) + if (debug & DBG_PCM ) dump_xframe("TX_XFRAME_PCM", xbus, xframe, debug); send_pcm_frame(xbus, xframe); XBUS_COUNTER(xbus, TX_XFRAME_PCM)++; @@ -812,12 +812,12 @@ for (i = 0; i < xpd->channels; i++) { struct dahdi_chan *chan = XPD_CHAN(xpd, i); - if(IS_SET(wanted_lines, i)) { - if(SPAN_REGISTERED(xpd)) { + if (IS_SET(wanted_lines, i)) { + if (SPAN_REGISTERED(xpd)) { #ifdef DEBUG_PCMTX int channo = chan->channo; - if(pcmtx >= 0 && pcmtx_chan == channo) + if (pcmtx >= 0 && pcmtx_chan == channo) memset((u_char *)pcm, pcmtx, DAHDI_CHUNKSIZE); else #endif @@ -847,20 +847,20 @@ */ pcm_mute = ~xpd->wanted_pcm_mask; pcm_mute |= xpd->mute_dtmf | xpd->silence_pcm; - if(!SPAN_REGISTERED(xpd)) + if (!SPAN_REGISTERED(xpd)) goto out; for (i = 0; i < xpd->channels; i++) { volatile u_char *r = XPD_CHAN(xpd, i)->readchunk; bool got_data = IS_SET(pcm_mask, i); - if(got_data && !IS_SET(pcm_mute, i)) { + if (got_data && !IS_SET(pcm_mute, i)) { /* We have and want real data */ // memset((u_char *)r, 0x5A, DAHDI_CHUNKSIZE); // DEBUG memcpy((u_char *)r, pcm, DAHDI_CHUNKSIZE); - } else if(IS_SET(xpd->wanted_pcm_mask | xpd->silence_pcm, i)) { + } else if (IS_SET(xpd->wanted_pcm_mask | xpd->silence_pcm, i)) { /* Inject SILENCE */ memset((u_char *)r, 0x7F, DAHDI_CHUNKSIZE); - if(IS_SET(xpd->silence_pcm, i)) { + if (IS_SET(xpd->silence_pcm, i)) { /* * This will clear the EC buffers until next tick * So we don't have noise residues from the past. @@ -869,7 +869,7 @@ memset(xpd->ec_chunk1[i], 0x7F, DAHDI_CHUNKSIZE); } } - if(got_data) + if (got_data) pcm += DAHDI_CHUNKSIZE; } out: @@ -884,7 +884,7 @@ byte *p; int ret = -EPROTO; /* Assume error */ - if(debug & DBG_PCM) + if (debug & DBG_PCM) dump_xframe("RX_XFRAME_PCM", xbus, xframe, debug); /* handle content */ @@ -897,10 +897,10 @@ pack = (xpacket_t *)p; len = XPACKET_LEN(pack); /* Sanity checks */ - if(unlikely(XPACKET_OP(pack) != XPROTO_NAME(GLOBAL,PCM_READ))) { + if (unlikely(XPACKET_OP(pack) != XPROTO_NAME(GLOBAL,PCM_READ))) { static int rate_limit; - if((rate_limit++ % 1003) == 0) { + if ((rate_limit++ % 1003) == 0) { XBUS_NOTICE(xbus, "%s: Non-PCM packet within a PCM xframe. (%d)\n", __FUNCTION__, rate_limit); @@ -909,10 +909,10 @@ goto out; } p += len; - if(p > xframe_end || len < RPACKET_HEADERSIZE) { + if (p > xframe_end || len < RPACKET_HEADERSIZE) { static int rate_limit; - if((rate_limit++ % 1003) == 0) { + if ((rate_limit++ % 1003) == 0) { XBUS_NOTICE(xbus, "%s: Invalid packet length %d. (%d)\n", __FUNCTION__, len, rate_limit); @@ -921,22 +921,22 @@ goto out; } xpd = xpd_byaddr(xbus, XPACKET_ADDR_UNIT(pack), XPACKET_ADDR_SUBUNIT(pack)); - if(unlikely(!xpd)) { + if (unlikely(!xpd)) { static int rate_limit; - if((rate_limit++ % 1003) == 0) { + if ((rate_limit++ % 1003) == 0) { notify_bad_xpd(__FUNCTION__, xbus, XPACKET_ADDR(pack), "RECEIVE PCM"); dump_xframe("Unknown XPD addr", xbus, xframe, debug); } goto out; } - if(!pcm_valid(xpd, pack)) + if (!pcm_valid(xpd, pack)) goto out; - if(SPAN_REGISTERED(xpd)) { + if (SPAN_REGISTERED(xpd)) { XBUS_COUNTER(xbus, RX_PACK_PCM)++; CALL_XMETHOD(card_pcm_tospan, xbus, xpd, pack); } - } while(p < xframe_end); + } while (p < xframe_end); ret = 0; /* all good */ XBUS_COUNTER(xbus, RX_XFRAME_PCM)++; out: @@ -955,9 +955,9 @@ /* * Update dahdi */ - for(i = 0; i < MAX_XPDS; i++) { + for (i = 0; i < MAX_XPDS; i++) { xpd = xpd_of(xbus, i); - if(xpd && SPAN_REGISTERED(xpd)) { + if (xpd && SPAN_REGISTERED(xpd)) { #ifdef OPTIMIZE_CHANMUTE int j; xpp_line_t xmit_mask = xpd->wanted_pcm_mask; @@ -980,27 +980,27 @@ /* * Fill xframes */ - for(i = 0; i < MAX_XPDS; i++) { + for (i = 0; i < MAX_XPDS; i++) { size_t pcm_len; - if((xpd = xpd_of(xbus, i)) == NULL) + if ((xpd = xpd_of(xbus, i)) == NULL) continue; pcm_len = xpd->pcm_len; - if(SPAN_REGISTERED(xpd)) { - if(pcm_len && xpd->card_present) { + if (SPAN_REGISTERED(xpd)) { + if (pcm_len && xpd->card_present) { do { // pack = NULL; /* FORCE single packet frames */ - if(xframe && !pack) { /* FULL frame */ + if (xframe && !pack) { /* FULL frame */ pcm_frame_out(xbus, xframe); xframe = NULL; XBUS_COUNTER(xbus, TX_PCM_FRAG)++; } - if(!xframe) { /* Alloc frame */ + if (!xframe) { /* Alloc frame */ xframe = ALLOC_SEND_XFRAME(xbus); if (!xframe) { static int rate_limit; - if((rate_limit++ % 3001) == 0) + if ((rate_limit++ % 3001) == 0) XBUS_ERR(xbus, "%s: failed to allocate new xframe\n", __FUNCTION__); @@ -1008,10 +1008,10 @@ } } pack = xframe_next_packet(xframe, pcm_len); - } while(!pack); + } while (!pack); XPACKET_INIT(pack, GLOBAL, PCM_WRITE, xpd->xbus_idx, 1, 0); XPACKET_LEN(pack) = pcm_len; - if(!sent_sync_bit) { + if (!sent_sync_bit) { XPACKET_ADDR_SYNC(pack) = 1; sent_sync_bit = 1; } @@ -1020,14 +1020,14 @@ } } } - if(xframe) /* clean any leftovers */ + if (xframe) /* clean any leftovers */ pcm_frame_out(xbus, xframe); /* * Receive PCM */ - while((xframe = xframe_dequeue(&xbus->pcm_tospan)) != NULL) { + while ((xframe = xframe_dequeue(&xbus->pcm_tospan)) != NULL) { copy_pcm_tospan(xbus, xframe); - if(XPACKET_ADDR_SYNC((xpacket_t *)xframe->packets)) { + if (XPACKET_ADDR_SYNC((xpacket_t *)xframe->packets)) { struct timeval now; unsigned long usec; @@ -1035,26 +1035,26 @@ usec = usec_diff(&now, &xbus->last_rx_sync); xbus->last_rx_sync = now; /* ignore startup statistics */ - if(likely(atomic_read(&xbus->pcm_rx_counter) > BIG_TICK_INTERVAL)) { - if(abs(usec - 1000) > TICK_TOLERANCE) { + if (likely(atomic_read(&xbus->pcm_rx_counter) > BIG_TICK_INTERVAL)) { + if (abs(usec - 1000) > TICK_TOLERANCE) { static int rate_limit; - if((rate_limit++ % 5003) == 0) + if ((rate_limit++ % 5003) == 0) XBUS_DBG(SYNC, xbus, "Bad PCM RX timing(%d): usec=%ld.\n", rate_limit, usec); } - if(usec > xbus->max_rx_sync) + if (usec > xbus->max_rx_sync) xbus->max_rx_sync = usec; - if(usec < xbus->min_rx_sync) + if (usec < xbus->min_rx_sync) xbus->min_rx_sync = usec; } } } - for(i = 0; i < MAX_XPDS; i++) { + for (i = 0; i < MAX_XPDS; i++) { xpd = xpd_of(xbus, i); - if(!xpd || !xpd->card_present) + if (!xpd || !xpd->card_present) continue; - if(SPAN_REGISTERED(xpd)) { + if (SPAN_REGISTERED(xpd)) { do_ec(xpd); dahdi_receive(&xpd->span); } @@ -1074,22 +1074,22 @@ unsigned long flags; xbus_command_queue_tick(xbus); - if(global_ticker == xbus) + if (global_ticker == xbus) global_tick(); /* called from here or dahdi_sync_tick() */ spin_lock_irqsave(&ref_ticker_lock, flags); xpp_drift_step(xbus, tv_received); spin_unlock_irqrestore(&ref_ticker_lock, flags); - if(likely(xbus->self_ticking)) + if (likely(xbus->self_ticking)) xbus_tick(xbus); xbus->global_counter = counter; } void xframe_receive_pcm(xbus_t *xbus, xframe_t *xframe) { - if(!xframe_enqueue(&xbus->pcm_tospan, xframe)) { + if (!xframe_enqueue(&xbus->pcm_tospan, xframe)) { static int rate_limit; - if((rate_limit++ % 1003) == 0) + if ((rate_limit++ % 1003) == 0) XBUS_DBG(SYNC, xbus, "Failed to enqueue received pcm frame. (%d)\n", rate_limit); @@ -1100,7 +1100,7 @@ * of the frame, regardless of the XPD that is sync master. * FIXME: what about PRI split? */ - if(XPACKET_ADDR_SYNC((xpacket_t *)xframe->packets)) { + if (XPACKET_ADDR_SYNC((xpacket_t *)xframe->packets)) { do_tick(xbus, &xframe->tv_received); atomic_inc(&xbus->pcm_rx_counter); } else @@ -1113,19 +1113,19 @@ int xbusno; xbus_t *xbus; - if(strncmp("DAHDI", buf, 6) == 0) { /* Ignore the newline */ + if (strncmp("DAHDI", buf, 6) == 0) { /* Ignore the newline */ DBG(SYNC, "DAHDI"); update_sync_master(NULL, 1); - } else if(sscanf(buf, "SYNC=%d", &xbusno) == 1) { + } else if (sscanf(buf, "SYNC=%d", &xbusno) == 1) { DBG(SYNC, "SYNC=%d\n", xbusno); - if((xbus = xbus_num(xbusno)) == NULL) { + if ((xbus = xbus_num(xbusno)) == NULL) { ERR("No bus %d exists\n", xbusno); return -ENXIO; } update_sync_master(xbus, 0); - } else if(sscanf(buf, "QUERY=%d", &xbusno) == 1) { + } else if (sscanf(buf, "QUERY=%d", &xbusno) == 1) { DBG(SYNC, "QUERY=%d\n", xbusno); - if((xbus = xbus_num(xbusno)) == NULL) { + if ((xbus = xbus_num(xbusno)) == NULL) { ERR("No bus %d exists\n", xbusno); return -ENXIO; } @@ -1141,7 +1141,7 @@ { int len = 0; - if(!syncer) { + if (!syncer) { len += snprintf(buf, count, "%s\n", (force_dahdi_sync) ? "DAHDI" : "NO-SYNC"); } else @@ -1167,7 +1167,7 @@ len += sprintf(page + len, "# QUERY=nn - Query XBUS-nn for sync information (DEBUG)\n"); len += fill_sync_string(page + len, PAGE_SIZE - len); #ifdef DAHDI_SYNC_TICK - if(force_dahdi_sync) { + if (force_dahdi_sync) { len += sprintf(page + len, "Dahdi Reference Sync (%d registered spans):\n", total_registered_spans()); @@ -1203,9 +1203,9 @@ // DBG(SYNC, "%s: count=%ld\n", __FUNCTION__, count); NOTICE("%s: DEPRECATED: %s[%d] write to /proc interface instead of /sys\n", __FUNCTION__, current->comm, current->tgid); - if(count >= MAX_PROC_WRITE) + if (count >= MAX_PROC_WRITE) return -EINVAL; - if(copy_from_user(buf, buffer, count)) + if (copy_from_user(buf, buffer, count)) return -EFAULT; buf[count] = '\0'; return exec_sync_command(buf, count); @@ -1238,7 +1238,7 @@ top = toplevel; ent = create_proc_entry(PROC_SYNC, 0644, top); - if(ent) { + if (ent) { ent->read_proc = proc_sync_read; ent->write_proc = proc_sync_write; ent->data = NULL; Index: drivers/dahdi/xpp/xbus-sysfs.c =================================================================== --- drivers/dahdi/xpp/xbus-sysfs.c (revision 7493) +++ drivers/dahdi/xpp/xbus-sysfs.c (working copy) @@ -85,9 +85,9 @@ xbus = dev_to_xbus(dev); XBUS_DBG(GENERAL, xbus, "%s\n", buf); - if(strncmp(buf, "stop", 4) == 0) + if (strncmp(buf, "stop", 4) == 0) xbus_deactivate(xbus); - else if(XBUS_IS(xbus, IDLE) && strncmp(buf, "start", 5) == 0) + else if (XBUS_IS(xbus, IDLE) && strncmp(buf, "start", 5) == 0) xbus_activate(xbus); else { XBUS_NOTICE(xbus, "%s: Illegal action %s in state %s. Ignored.\n", @@ -119,7 +119,7 @@ xbus = dev_to_xbus(dev); driftinfo = &xbus->drift; len += snprintf(buf + len, PAGE_SIZE - len, "%-3s", sync_mode_name(xbus->sync_mode)); - if(xbus->sync_mode == SYNC_MODE_PLL) { + if (xbus->sync_mode == SYNC_MODE_PLL) { len += snprintf(buf + len, PAGE_SIZE - len, " %5d: jitter %4d median %4d calc_drift %3d lost (%4d,%4d) : ", xbus->ticker.cycle, @@ -151,10 +151,10 @@ int i; xbus = dev_to_xbus(dev); - if(xbus->sample_running) + if (xbus->sample_running) return -EBUSY; - for(i = 0; i < SAMPLE_SIZE; i++) { - if(len > PAGE_SIZE - 20) + for (i = 0; i < SAMPLE_SIZE; i++) { + if (len > PAGE_SIZE - 20) break; len += snprintf(buf + len, PAGE_SIZE - len, "%d\n", xbus->sample_ticks[i]); } @@ -166,7 +166,7 @@ xbus_t *xbus; xbus = dev_to_xbus(dev); - if(xbus->sample_running) + if (xbus->sample_running) return -EBUSY; memset(xbus->sample_ticks, 0, sizeof(*xbus->sample_ticks)); xbus->sample_pos = 0; @@ -288,11 +288,11 @@ { xbus_t *xbus; - if(!dev) + if (!dev) return -ENODEV; xbus = dev_to_xbus(dev); envp[0] = buff; - if(snprintf(buff, bufsize, "XBUS_NAME=%s", xbus->busname) >= bufsize) + if (snprintf(buff, bufsize, "XBUS_NAME=%s", xbus->busname) >= bufsize) return -ENOMEM; envp[1] = NULL; return 0; @@ -304,7 +304,7 @@ XBUS_ADD_UEVENT_VAR("XPP_INIT_DIR=%s", initdir); \ XBUS_ADD_UEVENT_VAR("XBUS_NUM=%02d", xbus->num); \ XBUS_ADD_UEVENT_VAR("XBUS_NAME=%s", xbus->busname); \ - } while(0) + } while (0) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) #define XBUS_ADD_UEVENT_VAR(fmt, val...) \ @@ -323,7 +323,7 @@ int len = 0; extern char *initdir; - if(!dev) + if (!dev) return -ENODEV; xbus = dev_to_xbus(dev); DBG(GENERAL, "SYFS bus_id=%s xbus=%s\n", dev_name(dev), xbus->busname); @@ -345,7 +345,7 @@ xbus_t *xbus; extern char *initdir; - if(!dev) + if (!dev) return -ENODEV; xbus = dev_to_xbus(dev); DBG(GENERAL, "SYFS bus_id=%s xbus=%s\n", dev_name(dev), xbus->busname); @@ -392,11 +392,11 @@ BUG_ON(!dev); xbus = dev_to_xbus(dev); - if(XBUS_FLAGS(xbus, CONNECTED)) { + if (XBUS_FLAGS(xbus, CONNECTED)) { XBUS_ERR(xbus, "Try to release CONNECTED device.\n"); BUG(); } - if(!XBUS_IS(xbus, IDLE) && !XBUS_IS(xbus, FAIL) && !XBUS_IS(xbus, DEACTIVATED)) { + if (!XBUS_IS(xbus, IDLE) && !XBUS_IS(xbus, FAIL) && !XBUS_IS(xbus, DEACTIVATED)) { XBUS_ERR(xbus, "Try to release in state %s\n", xbus_statename(XBUS_STATE(xbus))); BUG(); @@ -458,7 +458,7 @@ BUG_ON(!dev); xpd = dev_to_xpd(dev); - if(!xpd) + if (!xpd) return -ENODEV; spin_lock_irqsave(&xpd->lock, flags); regs = &xpd->last_reply; @@ -466,12 +466,12 @@ len += sprintf(buf + len, "# Consult firmware docs first\n"); len += sprintf(buf + len, "#\n"); do_datah = REG_FIELD(regs, do_datah) ? 1 : 0; - if(do_datah) { + if (do_datah) { snprintf(datah_str, ARRAY_SIZE(datah_str), "\t%02X", REG_FIELD(regs, data_high)); } else datah_str[0] = '\0'; - if(REG_FIELD(regs, do_subreg)) { + if (REG_FIELD(regs, do_subreg)) { len += sprintf(buf + len, "#CH\tOP\tReg.\tSub\tDL%s\n", (do_datah) ? "\tDH" : ""); len += sprintf(buf + len, "%2d\tRS\t%02X\t%02X\t%02X%s\n", @@ -501,27 +501,27 @@ BUG_ON(!dev); xpd = dev_to_xpd(dev); //XPD_DBG(GENERAL, xpd, "%s\n", buf); - if(!xpd) + if (!xpd) return -ENODEV; p = buf; - while((p - buf) < count) { + while ((p - buf) < count) { i = strcspn(p, "\r\n"); - if(i > 0) { - if(i >= MAX_PROC_WRITE) { + if (i > 0) { + if (i >= MAX_PROC_WRITE) { XPD_NOTICE(xpd, "Command too long (%d chars)\n", i); return -E2BIG; } memcpy(tmp, p, i); tmp[i] = '\0'; ret = parse_chip_command(xpd, tmp); - if(ret < 0) { + if (ret < 0) { XPD_NOTICE(xpd, "Failed writing command: '%s'\n", tmp); return ret; } } p += i + 1; /* Don't flood command_queue */ - if(xframe_queue_count(&xpd->xbus->command_queue) > 5) + if (xframe_queue_count(&xpd->xbus->command_queue) > 5) msleep(6); } return count; @@ -535,7 +535,7 @@ BUG_ON(!dev); xpd = dev_to_xpd(dev); - if(!xpd) + if (!xpd) return -ENODEV; spin_lock_irqsave(&xpd->lock, flags); len += sprintf(buf, "0x%lX\n", xpd->blink_mode); @@ -552,12 +552,12 @@ BUG_ON(!dev); xpd = dev_to_xpd(dev); //XPD_DBG(GENERAL, xpd, "%s\n", buf); - if(!xpd) + if (!xpd) return -ENODEV; blink = simple_strtoul(buf, &endp, 0); - if(*endp != '\0' && *endp != '\n' && *endp != '\r') + if (*endp != '\0' && *endp != '\n' && *endp != '\r') return -EINVAL; - if(blink > 0xFFFF) + if (blink > 0xFFFF) return -EINVAL; XPD_DBG(GENERAL, xpd, "BLINK channels: 0x%lX\n", blink); xpd->blink_mode = blink; @@ -572,7 +572,7 @@ BUG_ON(!dev); xpd = dev_to_xpd(dev); - if(!xpd) + if (!xpd) return -ENODEV; spin_lock_irqsave(&xpd->lock, flags); len += sprintf(buf, "%d\n", SPAN_REGISTERED(xpd) ? xpd->span.spanno : 0); @@ -588,15 +588,15 @@ BUG_ON(!dev); xpd = dev_to_xpd(dev); - if(!xpd) + if (!xpd) return -ENODEV; ret = sscanf(buf, "%d", &dahdi_reg); - if(ret != 1) + if (ret != 1) return -EINVAL; - if(!XBUS_IS(xpd->xbus, READY)) + if (!XBUS_IS(xpd->xbus, READY)) return -ENODEV; XPD_DBG(GENERAL, xpd, "%s\n", (dahdi_reg) ? "register" : "unregister"); - if(dahdi_reg) + if (dahdi_reg) ret = dahdi_register_xpd(xpd); else ret = dahdi_unregister_xpd(xpd); @@ -610,7 +610,7 @@ BUG_ON(!dev); xpd = dev_to_xpd(dev); - if(!xpd) + if (!xpd) return -ENODEV; len += sprintf(buf, "%s\n", xpd->type_name); return len; @@ -624,12 +624,12 @@ BUG_ON(!dev); xpd = dev_to_xpd(dev); - if(!xpd) + if (!xpd) return -ENODEV; for_each_line(xpd, i) { len += sprintf(buf + len, "%d ", IS_OFFHOOK(xpd, i)); } - if(len) { + if (len) { len--; /* backout last space */ len += sprintf(buf + len, "\n"); } @@ -644,7 +644,7 @@ BUG_ON(!dev); xpd = dev_to_xpd(dev); - if(!xpd) + if (!xpd) return -ENODEV; spin_lock_irqsave(&xpd->lock, flags); len += sprintf(buf + len, "%d\n", xpd->timing_priority); @@ -659,7 +659,7 @@ xpd_driver = driver_to_xpd_driver(driver); xpd = dev_to_xpd(dev); - if(xpd_driver->type != xpd->type) { + if (xpd_driver->type != xpd->type) { XPD_DBG(DEVICES, xpd, "SYSFS match fail: xpd->type = %d, xpd_driver->type = %d\n", xpd->type, xpd_driver->type); return 0; @@ -691,7 +691,7 @@ DBG(DEVICES, "%s\n", driver->name); driver->bus = &xpd_type; - if((ret = driver_register(driver)) < 0) { + if ((ret = driver_register(driver)) < 0) { ERR("%s: driver_register(%s) failed. Error number %d", __FUNCTION__, driver->name, ret); } @@ -727,7 +727,7 @@ dev_set_drvdata(dev, xpd); dev->release = xpd_release; ret = device_register(dev); - if(ret) { + if (ret) { XPD_ERR(xpd, "%s: device_register failed: %d\n", __FUNCTION__, ret); return ret; } @@ -745,7 +745,7 @@ BUG_ON(!xbus); XPD_DBG(DEVICES, xpd, "SYSFS\n"); dev = &xpd->xpd_dev; - if(!dev_get_drvdata(dev)) + if (!dev_get_drvdata(dev)) return; BUG_ON(dev_get_drvdata(dev) != xpd); device_unregister(dev); @@ -763,7 +763,7 @@ astribank = &xbus->astribank; BUG_ON(!astribank); sysfs_remove_link(&astribank->kobj, "transport"); - if(!dev_get_drvdata(astribank)) + if (!dev_get_drvdata(astribank)) return; BUG_ON(dev_get_drvdata(astribank) != xbus); device_unregister(&xbus->astribank); @@ -784,13 +784,13 @@ dev_set_drvdata(astribank, xbus); astribank->release = astribank_release; ret = device_register(astribank); - if(ret) { + if (ret) { XBUS_ERR(xbus, "%s: device_register failed: %d\n", __FUNCTION__, ret); dev_set_drvdata(astribank, NULL); goto out; } ret = sysfs_create_link(&astribank->kobj, &astribank->parent->kobj, "transport"); - if(ret < 0) { + if (ret < 0) { XBUS_ERR(xbus, "%s: sysfs_create_link failed: %d\n", __FUNCTION__, ret); dev_set_drvdata(astribank, NULL); goto out; @@ -804,17 +804,17 @@ int ret; DBG(DEVICES, "SYSFS\n"); - if((ret = bus_register(&toplevel_bus_type)) < 0) { + if ((ret = bus_register(&toplevel_bus_type)) < 0) { ERR("%s: bus_register(%s) failed. Error number %d", __FUNCTION__, toplevel_bus_type.name, ret); goto failed_bus; } - if((ret = driver_register(&xpp_driver)) < 0) { + if ((ret = driver_register(&xpp_driver)) < 0) { ERR("%s: driver_register(%s) failed. Error number %d", __FUNCTION__, xpp_driver.name, ret); goto failed_xpp_driver; } - if((ret = bus_register(&xpd_type)) < 0) { + if ((ret = bus_register(&xpd_type)) < 0) { ERR("%s: bus_register(%s) failed. Error number %d", __FUNCTION__, xpd_type.name, ret); goto failed_xpd_bus; Index: drivers/dahdi/xpp/xdefs.h =================================================================== --- drivers/dahdi/xpp/xdefs.h (revision 7493) +++ drivers/dahdi/xpp/xdefs.h (working copy) @@ -112,7 +112,7 @@ #define KZFREE(p) do { \ memset((p), 0, sizeof(*(p))); \ kfree(p); \ - } while(0); + } while (0); /* * Hotplug replaced with uevent in 2.6.16 @@ -139,9 +139,9 @@ ssize_t name(struct device_driver *drv, char * buf) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) -#define SET_PROC_DIRENTRY_OWNER(p) do { (p)->owner = THIS_MODULE; } while(0); +#define SET_PROC_DIRENTRY_OWNER(p) do { (p)->owner = THIS_MODULE; } while (0); #else -#define SET_PROC_DIRENTRY_OWNER(p) do { } while(0); +#define SET_PROC_DIRENTRY_OWNER(p) do { } while (0); #endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) Index: drivers/dahdi/xpp/xframe_queue.c =================================================================== --- drivers/dahdi/xpp/xframe_queue.c (revision 7493) +++ drivers/dahdi/xpp/xframe_queue.c (working copy) @@ -49,11 +49,11 @@ { int ret = 1; - if(unlikely(q->disabled)) { + if (unlikely(q->disabled)) { ret = 0; goto out; } - if(q->count >= q->max_count) { + if (q->count >= q->max_count) { q->overflows++; NOTICE("Overflow of %-15s: counts %3d, %3d, %3d worst %3d, overflows %3d worst_lag %02ld.%ld ms\n", q->name, @@ -68,7 +68,7 @@ ret = 0; goto out; } - if(++q->count > q->worst_count) + if (++q->count > q->worst_count) q->worst_count = q->count; list_add_tail(&xframe->frame_list, &q->head); do_gettimeofday(&xframe->tv_queued); @@ -94,7 +94,7 @@ struct timeval now; unsigned long usec_lag; - if(list_empty(&q->head)) + if (list_empty(&q->head)) goto out; h = q->head.next; list_del_init(h); @@ -104,7 +104,7 @@ usec_lag = (now.tv_sec - frm->tv_queued.tv_sec)*1000*1000 + (now.tv_usec - frm->tv_queued.tv_usec); - if(q->worst_lag_usec < usec_lag) + if (q->worst_lag_usec < usec_lag) q->worst_lag_usec = usec_lag; out: return frm; @@ -132,7 +132,7 @@ int i = 0; xframe_queue_disable(q, 1); - while((xframe = xframe_dequeue(q)) != NULL) { + while ((xframe = xframe_dequeue(q)) != NULL) { transport_free_xframe(xbus, xframe); i++; } @@ -154,17 +154,17 @@ BUG_ON(!xbus); ops = transportops_get(xbus); - if(unlikely(!ops)) { + if (unlikely(!ops)) { XBUS_ERR(xbus, "Missing transport\n"); return NULL; } spin_lock_irqsave(&xbus->transport.lock, flags); //XBUS_INFO(xbus, "%s (transport_refcount=%d)\n", __FUNCTION__, atomic_read(&xbus->transport.transport_refcount)); xframe = ops->alloc_xframe(xbus, gfp_flags); - if(!xframe) { + if (!xframe) { static int rate_limit; - if((rate_limit++ % 3001) == 0) + if ((rate_limit++ % 3001) == 0) XBUS_ERR(xbus, "Failed xframe allocation from transport (%d)\n", rate_limit); @@ -203,33 +203,33 @@ BUG_ON(!xbus); spin_lock_irqsave(&q->lock, flags); delta = q->count - q->steady_state_count; - if(delta < -XFRAME_QUEUE_MARGIN) { + if (delta < -XFRAME_QUEUE_MARGIN) { /* Increase pool by one frame */ //XBUS_INFO(xbus, "%s(%d): Allocate one\n", q->name, delta); xframe = transport_alloc_xframe(xbus, GFP_ATOMIC); - if(!xframe) { + if (!xframe) { static int rate_limit; - if((rate_limit++ % 3001) == 0) + if ((rate_limit++ % 3001) == 0) XBUS_ERR(xbus, "%s: failed frame allocation\n", q->name); goto out; } - if(!__xframe_enqueue(q, xframe)) { + if (!__xframe_enqueue(q, xframe)) { static int rate_limit; - if((rate_limit++ % 3001) == 0) + if ((rate_limit++ % 3001) == 0) XBUS_ERR(xbus, "%s: failed enqueueing frame\n", q->name); transport_free_xframe(xbus, xframe); goto out; } - } else if(delta > XFRAME_QUEUE_MARGIN) { + } else if (delta > XFRAME_QUEUE_MARGIN) { /* Decrease pool by one frame */ //XBUS_INFO(xbus, "%s(%d): Free one\n", q->name, delta); xframe = __xframe_dequeue(q); - if(!xframe) { + if (!xframe) { static int rate_limit; - if((rate_limit++ % 3001) == 0) + if ((rate_limit++ % 3001) == 0) XBUS_ERR(xbus, "%s: failed dequeueing frame\n", q->name); goto out; } @@ -251,10 +251,10 @@ BUG_ON(!xbus); xframe_queue_adjust(q); xframe = xframe_dequeue(q); - if(!xframe) { + if (!xframe) { static int rate_limit; - if((rate_limit++ % 3001) == 0) + if ((rate_limit++ % 3001) == 0) XBUS_ERR(xbus, "%s STILL EMPTY (%d)\n", q->name, rate_limit); return NULL; } @@ -283,7 +283,7 @@ BUG_ON(!xbus); //XBUS_INFO(xbus, "%s\n", __FUNCTION__); BUG_ON(!TRANSPORT_EXIST(xbus)); - if(unlikely(!xframe_enqueue(q, xframe))) { + if (unlikely(!xframe_enqueue(q, xframe))) { XBUS_ERR(xbus, "Failed returning xframe to %s\n", q->name); transport_free_xframe(xbus, xframe); return; Index: drivers/dahdi/xpp/xpd.h =================================================================== --- drivers/dahdi/xpp/xpd.h (revision 7493) +++ drivers/dahdi/xpp/xpd.h (working copy) @@ -226,7 +226,7 @@ u_char ec_chunk2[CHANNELS_PERXPD][DAHDI_CHUNKSIZE]; }; -#define for_each_line(xpd,i) for((i) = 0; (i) < (xpd)->channels; (i)++) +#define for_each_line(xpd,i) for ((i) = 0; (i) < (xpd)->channels; (i)++) #define IS_BRI(xpd) ((xpd)->type == XPD_TYPE_BRI) #define TICK_TOLERANCE 500 /* usec */ @@ -241,7 +241,7 @@ void *p; p = kmalloc(size, flags); - if(p) + if (p) memset(p, 0, size); return p; } Index: drivers/dahdi/xpp/xpp_dahdi.c =================================================================== --- drivers/dahdi/xpp/xpp_dahdi.c (revision 7493) +++ drivers/dahdi/xpp/xpp_dahdi.c (working copy) @@ -95,9 +95,9 @@ { int num = xbus->num; - if(num == parport_xbuses[0]) + if (num == parport_xbuses[0]) flip_parport_bit(bitnum0); - if(num == parport_xbuses[1]) + if (num == parport_xbuses[1]) flip_parport_bit(bitnum1); } EXPORT_SYMBOL(xbus_flip_bit); @@ -147,22 +147,22 @@ static void xpd_proc_remove(xbus_t *xbus, xpd_t *xpd) { #ifdef CONFIG_PROC_FS - if(xpd->proc_xpd_dir) { + if (xpd->proc_xpd_dir) { #ifdef OLD_PROC chip_proc_remove(xbus, xpd); #endif - if(xpd->proc_xpd_summary) { + if (xpd->proc_xpd_summary) { XPD_DBG(PROC, xpd, "Removing proc '%s'\n", PROC_XPD_SUMMARY); remove_proc_entry(PROC_XPD_SUMMARY, xpd->proc_xpd_dir); xpd->proc_xpd_summary = NULL; } #ifdef OLD_PROC - if(xpd->proc_xpd_ztregister) { + if (xpd->proc_xpd_ztregister) { XPD_DBG(PROC, xpd, "Removing proc '%s'\n", PROC_XPD_ZTREGISTER); remove_proc_entry(PROC_XPD_ZTREGISTER, xpd->proc_xpd_dir); xpd->proc_xpd_ztregister = NULL; } - if(xpd->proc_xpd_blink) { + if (xpd->proc_xpd_blink) { XPD_DBG(PROC, xpd, "Removing proc '%s'\n", PROC_XPD_BLINK); remove_proc_entry(PROC_XPD_BLINK, xpd->proc_xpd_dir); xpd->proc_xpd_blink = NULL; @@ -181,13 +181,13 @@ #ifdef CONFIG_PROC_FS XPD_DBG(PROC, xpd, "Creating proc directory\n"); xpd->proc_xpd_dir = proc_mkdir(xpd->xpdname, xbus->proc_xbus_dir); - if(!xpd->proc_xpd_dir) { + if (!xpd->proc_xpd_dir) { XPD_ERR(xpd, "Failed to create proc directory\n"); goto err; } xpd->proc_xpd_summary = create_proc_read_entry(PROC_XPD_SUMMARY, 0444, xpd->proc_xpd_dir, xpd_read_proc, xpd); - if(!xpd->proc_xpd_summary) { + if (!xpd->proc_xpd_summary) { XPD_ERR(xpd, "Failed to create proc file '%s'\n", PROC_XPD_SUMMARY); goto err; } @@ -211,7 +211,7 @@ xpd->proc_xpd_blink->data = xpd; xpd->proc_xpd_blink->read_proc = proc_xpd_blink_read; xpd->proc_xpd_blink->write_proc = proc_xpd_blink_write; - if(chip_proc_create(xbus, xpd) < 0) + if (chip_proc_create(xbus, xpd) < 0) goto err; #endif #endif @@ -226,13 +226,13 @@ xbus_t *xbus = NULL; unsigned int x; - if(!xpd) + if (!xpd) return; - if(xpd->xproto) + if (xpd->xproto) xproto_put(xpd->xproto); /* was taken in xpd_alloc() */ xpd->xproto = NULL; xbus = xpd->xbus; - if(!xbus) + if (!xbus) return; XPD_DBG(DEVICES, xpd, "\n"); xpd_proc_remove(xbus, xpd); @@ -266,18 +266,18 @@ to_phone = BIT(subunit) & port_dir; BUG_ON(!xbus); xpd = xpd_byaddr(xbus, unit, subunit); - if(xpd) { + if (xpd) { XPD_NOTICE(xpd, "XPD at %d%d already exists\n", unit, subunit); return 0; } - if(subunit_ports <= 0 || subunit_ports > CHANNELS_PERXPD) { + if (subunit_ports <= 0 || subunit_ports > CHANNELS_PERXPD) { XBUS_NOTICE(xbus, "Illegal number of ports %d for XPD %d%d\n", subunit_ports, unit, subunit); return 0; } xpd = proto_table->xops.card_new(xbus, unit, subunit, proto_table, subtype, subunits, subunit_ports, to_phone); - if(!xpd) { + if (!xpd) { XBUS_NOTICE(xbus, "card_new(%d,%d,%d,%d,%d) failed. Ignored.\n", unit, subunit, proto_table->type, subtype, to_phone); return -EINVAL; @@ -288,7 +288,7 @@ void xpd_post_init(xpd_t *xpd) { XPD_DBG(DEVICES, xpd, "\n"); - if(dahdi_autoreg) + if (dahdi_autoreg) dahdi_register_xpd(xpd); } @@ -310,7 +310,7 @@ xbus_t *xbus; int i; - if(!xpd) + if (!xpd) goto out; xbus = xpd->xbus; @@ -364,7 +364,7 @@ len += sprintf(page + len, "%d ", IS_SET(xpd->no_pcm, i)); } #if 1 - if(SPAN_REGISTERED(xpd)) { + if (SPAN_REGISTERED(xpd)) { len += sprintf(page + len, "\nPCM:\n | [readchunk] | [writechunk] | W D"); for_each_line(xpd, i) { struct dahdi_chan *chan = XPD_CHAN(xpd, i); @@ -374,22 +374,22 @@ byte *wp; int j; - if(IS_SET(xpd->digital_outputs, i)) + if (IS_SET(xpd->digital_outputs, i)) continue; - if(IS_SET(xpd->digital_inputs, i)) + if (IS_SET(xpd->digital_inputs, i)) continue; - if(IS_SET(xpd->digital_signalling, i)) + if (IS_SET(xpd->digital_signalling, i)) continue; rp = chan->readchunk; wp = chan->writechunk; memcpy(rchunk, rp, DAHDI_CHUNKSIZE); memcpy(wchunk, wp, DAHDI_CHUNKSIZE); len += sprintf(page + len, "\n port %2d> | ", i); - for(j = 0; j < DAHDI_CHUNKSIZE; j++) { + for (j = 0; j < DAHDI_CHUNKSIZE; j++) { len += sprintf(page + len, "%02X ", rchunk[j]); } len += sprintf(page + len, " | "); - for(j = 0; j < DAHDI_CHUNKSIZE; j++) { + for (j = 0; j < DAHDI_CHUNKSIZE; j++) { len += sprintf(page + len, "%02X ", wchunk[j]); } len += sprintf(page + len, " | %c", @@ -400,7 +400,7 @@ } #endif #if 0 - if(SPAN_REGISTERED(xpd)) { + if (SPAN_REGISTERED(xpd)) { len += sprintf(page + len, "\nSignalling:\n"); for_each_line(xpd, i) { struct dahdi_chan *chan = XPD_CHAN(xpd, i); @@ -409,7 +409,7 @@ } #endif len += sprintf(page + len, "\nCOUNTERS:\n"); - for(i = 0; i < XPD_COUNTER_MAX; i++) { + for (i = 0; i < XPD_COUNTER_MAX; i++) { len += sprintf(page + len, "\t\t%-20s = %d\n", xpd_counters[i].name, xpd->counters[i]); } @@ -431,7 +431,7 @@ const char *xpd_statename(enum xpd_state st) { - switch(st) { + switch (st) { case XPD_STATE_START: return "START"; case XPD_STATE_INIT_REGS: return "INIT_REGS"; case XPD_STATE_READY: return "READY"; @@ -446,13 +446,13 @@ XPD_DBG(DEVICES, xpd, "%s: %s (%d) -> %s (%d)\n", __FUNCTION__, xpd_statename(xpd->xpd_state), xpd->xpd_state, xpd_statename(newstate), newstate); - switch(newstate) { + switch (newstate) { case XPD_STATE_START: goto badstate; case XPD_STATE_INIT_REGS: - if(xpd->xpd_state != XPD_STATE_START) + if (xpd->xpd_state != XPD_STATE_START) goto badstate; - if(xpd->addr.subunit != 0) { + if (xpd->addr.subunit != 0) { XPD_NOTICE(xpd, "%s: Moving to %s allowed only for subunit 0\n", __FUNCTION__, xpd_statename(newstate)); @@ -460,12 +460,12 @@ } break; case XPD_STATE_READY: - if(xpd->addr.subunit == 0) { + if (xpd->addr.subunit == 0) { /* Unit 0 script initialize registers of all subunits */ - if(xpd->xpd_state != XPD_STATE_INIT_REGS) + if (xpd->xpd_state != XPD_STATE_INIT_REGS) goto badstate; } else { - if(xpd->xpd_state != XPD_STATE_START) + if (xpd->xpd_state != XPD_STATE_START) goto badstate; } break; @@ -502,13 +502,13 @@ BUG_ON(!proto_table); XBUS_DBG(DEVICES, xbus, "type=%d channels=%d (alloc_size=%zd)\n", type, channels, alloc_size); - if(channels > CHANNELS_PERXPD) { + if (channels > CHANNELS_PERXPD) { XBUS_ERR(xbus, "%s: type=%d: too many channels %d\n", __FUNCTION__, type, channels); goto err; } - if((xpd = KZALLOC(alloc_size, GFP_KERNEL)) == NULL) { + if ((xpd = KZALLOC(alloc_size, GFP_KERNEL)) == NULL) { XBUS_ERR(xbus, "%s: type=%d: Unable to allocate memory\n", __FUNCTION__, type); goto err; @@ -532,7 +532,7 @@ atomic_set(&xpd->open_counter, 0); /* For USB-1 disable some channels */ - if(MAX_SEND_SIZE(xbus) < RPACKET_SIZE(GLOBAL, PCM_WRITE)) { + if (MAX_SEND_SIZE(xbus) < RPACKET_SIZE(GLOBAL, PCM_WRITE)) { xpp_line_t no_pcm; no_pcm = 0x7F | xpd->digital_outputs | xpd->digital_inputs; @@ -547,13 +547,13 @@ } } xbus_xpd_bind(xbus, xpd, unit, subunit); - if(xpd_proc_create(xbus, xpd) < 0) + if (xpd_proc_create(xbus, xpd) < 0) goto err; xbus = get_xbus(__FUNCTION__, xbus); /* returned in xpd_free() */ xproto_get(type); /* will be returned in xpd_free() */ return xpd; err: - if(xpd) { + if (xpd) { xpd_proc_remove(xbus, xpd); for (x = 0; x < xpd->channels; x++) { if (xpd->chans[x]) { @@ -577,9 +577,9 @@ unsigned long flags; int i; - for(i = 0; i < MAX_XPDS; i++) { + for (i = 0; i < MAX_XPDS; i++) { xpd_t *xpd = xpd_of(xbus, i); - if(xpd) { + if (xpd) { XPD_DBG(DEVICES, xpd, "\n"); spin_lock_irqsave(&xpd->lock, flags); xpd->card_present = 0; @@ -589,10 +589,10 @@ } } /* Now notify dahdi */ - for(i = 0; i < MAX_XPDS; i++) { + for (i = 0; i < MAX_XPDS; i++) { xpd_t *xpd = xpd_of(xbus, i); - if(xpd) { - if(SPAN_REGISTERED(xpd)) { + if (xpd) { + if (SPAN_REGISTERED(xpd)) { int i; dahdi_alarm_notify(&xpd->span); @@ -625,7 +625,7 @@ { struct dahdi_span *span = &xpd->span; - if(!SPAN_REGISTERED(xpd)) { + if (!SPAN_REGISTERED(xpd)) { // XPD_NOTICE(xpd, "%s: XPD is not registered. Skipping.\n", __FUNCTION__); return; } @@ -637,7 +637,7 @@ // Nothing break; } - if(span->alarms == alarm_flag) + if (span->alarms == alarm_flag) return; XPD_DBG(GENERAL, xpd, "Update XPD alarms: %s -> %02X\n", xpd->span.name, alarm_flag); span->alarms = alarm_flag; @@ -651,7 +651,7 @@ */ void oht_pcm(xpd_t *xpd, int pos, bool pass) { - if(pass) { + if (pass) { LINE_DBG(SIGNAL, xpd, pos, "OHT PCM: pass\n"); BIT_SET(xpd->oht_pcm_pass, pos); } else { @@ -666,7 +666,7 @@ */ void mark_offhook(xpd_t *xpd, int pos, bool to_offhook) { - if(to_offhook) { + if (to_offhook) { LINE_DBG(SIGNAL, xpd, pos, "OFFHOOK\n"); BIT_SET(xpd->offhook_state, pos); } else { @@ -687,7 +687,7 @@ * a nested spinlock scenario */ LINE_DBG(SIGNAL, xpd, pos, "rxsig=%s\n", rxsig2str(rxsig)); - if(SPAN_REGISTERED(xpd)) + if (SPAN_REGISTERED(xpd)) dahdi_hooksig(XPD_CHAN(xpd, pos), rxsig); } @@ -700,7 +700,7 @@ { BUG_ON(!xpd); mark_offhook(xpd, pos, to_offhook); - if(!to_offhook) { + if (!to_offhook) { oht_pcm(xpd, pos, 0); /* * To prevent latest PCM to stay in buffers @@ -749,18 +749,18 @@ BUG_ON(!xpd); XPD_NOTICE(xpd, "%s: DEPRECATED: %s[%d] wrote to /proc interface instead of /sys\n", __FUNCTION__, current->comm, current->tgid); - if(count >= MAX_PROC_WRITE) + if (count >= MAX_PROC_WRITE) return -EINVAL; - if(copy_from_user(buf, buffer, count)) + if (copy_from_user(buf, buffer, count)) return -EFAULT; buf[count] = '\0'; ret = sscanf(buf, "%d", &dahdi_reg); - if(ret != 1) + if (ret != 1) return -EINVAL; - if(!XBUS_IS(xpd->xbus, READY)) + if (!XBUS_IS(xpd->xbus, READY)) return -ENODEV; XPD_DBG(GENERAL, xpd, "%s\n", (dahdi_reg) ? "register" : "unregister"); - if(dahdi_reg) + if (dahdi_reg) ret = dahdi_register_xpd(xpd); else ret = dahdi_unregister_xpd(xpd); @@ -801,15 +801,15 @@ BUG_ON(!xpd); XPD_NOTICE(xpd, "%s: DEPRECATED: %s[%d] wrote to /proc interface instead of /sys\n", __FUNCTION__, current->comm, current->tgid); - if(count >= MAX_PROC_WRITE) + if (count >= MAX_PROC_WRITE) return -EINVAL; - if(copy_from_user(buf, buffer, count)) + if (copy_from_user(buf, buffer, count)) return -EFAULT; buf[count] = '\0'; - if(count > 0 && buf[count-1] == '\n') /* chomp */ + if (count > 0 && buf[count-1] == '\n') /* chomp */ buf[count-1] = '\0'; blink = simple_strtoul(buf, &endp, 0); - if(*endp != '\0' || blink > 0xFFFF) + if (*endp != '\0' || blink > 0xFFFF) return -EINVAL; XPD_DBG(GENERAL, xpd, "BLINK channels: 0x%lX\n", blink); xpd->blink_mode = blink; @@ -858,7 +858,7 @@ BUG(); } pos = chan->chanpos - 1; - if(!xpd->card_present) { + if (!xpd->card_present) { LINE_NOTICE(xpd, pos, "Cannot open -- device not ready\n"); put_xpd(__FUNCTION__, xpd); return -ENODEV; @@ -870,7 +870,7 @@ current->comm, current->pid, atomic_read(&xpd->open_counter)); spin_unlock_irqrestore(&xbus->lock, flags); - if(xpd->xops->card_open) + if (xpd->xops->card_open) xpd->xops->card_open(xpd, pos); return 0; } @@ -884,7 +884,7 @@ spin_lock_irqsave(&xbus->lock, flags); spin_unlock_irqrestore(&xbus->lock, flags); - if(xpd->xops->card_close) + if (xpd->xops->card_close) xpd->xops->card_close(xpd, pos); LINE_DBG(DEVICES, xpd, pos, "%s[%d]: open_counter=%d\n", current->comm, current->pid, @@ -898,7 +898,7 @@ { char *extra_msg = ""; - if(_IOC_TYPE(cmd) == 'J') + if (_IOC_TYPE(cmd) == 'J') extra_msg = " (for old ZAPTEL)"; XPD_NOTICE(xpd, "%s: Bad ioctl%s\n", msg, extra_msg); XPD_NOTICE(xpd, "ENOTTY: chan=%d cmd=0x%x\n", pos, cmd); @@ -913,7 +913,7 @@ xpd_t *xpd = chan->pvt; int pos = chan->chanpos - 1; - if(!xpd) { + if (!xpd) { ERR("%s: channel in pos %d, was already closed. Ignore.\n", __FUNCTION__, pos); return -ENODEV; @@ -936,12 +936,12 @@ xbus_t *xbus; int pos = chan->chanpos - 1; - if(!xpd) { + if (!xpd) { ERR("%s: channel in pos %d, was already closed. Ignore.\n", __FUNCTION__, pos); return -ENODEV; } - if(!xpd->xops->card_hooksig) { + if (!xpd->xops->card_hooksig) { LINE_ERR(xpd, pos, "%s: No hooksig method for this channel. Ignore.\n", __FUNCTION__); @@ -967,7 +967,7 @@ #endif DBG(GENERAL, "span->mainttimer=%d\n", span->mainttimer); - switch(cmd) { + switch (cmd) { case DAHDI_MAINT_NONE: INFO("XXX Turn off local and remote loops XXX\n"); break; @@ -1006,7 +1006,7 @@ { static int rate_limit = 0; - if((rate_limit++ % 1000) == 0) + if ((rate_limit++ % 1000) == 0) DBG(GENERAL, "\n"); return 0; } @@ -1030,26 +1030,26 @@ BUG_ON(!xpd); spin_lock_irqsave(&xpd->lock, flags); - if(!SPAN_REGISTERED(xpd)) { + if (!SPAN_REGISTERED(xpd)) { XPD_NOTICE(xpd, "Already unregistered\n"); spin_unlock_irqrestore(&xpd->lock, flags); return -EIDRM; } update_xpd_status(xpd, DAHDI_ALARM_NOTOPEN); /* We should now have only a ref from the xbus (from create_xpd()) */ - if(atomic_read(&xpd->open_counter)) { + if (atomic_read(&xpd->open_counter)) { XPD_NOTICE(xpd, "Busy (open_counter=%d). Skipping.\n", atomic_read(&xpd->open_counter)); spin_unlock_irqrestore(&xpd->lock, flags); return -EBUSY; } mdelay(2); // FIXME: This is to give chance for transmit/receiveprep to finish. spin_unlock_irqrestore(&xpd->lock, flags); - if(xpd->card_present) + if (xpd->card_present) xpd->xops->card_dahdi_preregistration(xpd, 0); atomic_dec(&xpd->dahdi_registered); atomic_dec(&num_registered_spans); dahdi_unregister(&xpd->span); - if(xpd->card_present) + if (xpd->card_present) xpd->xops->card_dahdi_postregistration(xpd, 0); return 0; } @@ -1074,7 +1074,7 @@ cn = xpd->channels; XPD_DBG(DEVICES, xpd, "Initializing span: %d channels.\n", cn); memset(&xpd->span, 0, sizeof(struct dahdi_span)); - for(i = 0; i < cn; i++) { + for (i = 0; i < cn; i++) { memset(XPD_CHAN(xpd, i), 0, sizeof(struct dahdi_chan)); } @@ -1089,7 +1089,7 @@ span->open = xpp_open; span->close = xpp_close; span->flags = DAHDI_FLAG_RBS; - if(xops->card_hooksig) + if (xops->card_hooksig) span->hooksig = xpp_hooksig; /* Only with RBS bits */ span->ioctl = xpp_ioctl; span->maint = xpp_maint; @@ -1136,11 +1136,11 @@ xbus->num, xpd->addr.unit, xpd->addr.subunit, xpd->type_name); XPD_DBG(GENERAL, xpd, "Registering span '%s'\n", xpd->span.desc); xpd->xops->card_dahdi_preregistration(xpd, 1); - if(!xpd->span.owner) { + if (!xpd->span.owner) { XPD_ERR(xpd, "NO span.owner field -- bug in low-level driver\n"); WARN_ON(!xpd->span.owner); } - if(dahdi_register(&xpd->span, prefmaster)) { + if (dahdi_register(&xpd->span, prefmaster)) { XPD_ERR(xpd, "Failed to dahdi_register span\n"); return -ENODEV; } @@ -1157,7 +1157,7 @@ * after open). */ for_each_line(xpd, cn) { - if(IS_OFFHOOK(xpd, cn)) + if (IS_OFFHOOK(xpd, cn)) notify_rxsig(xpd, cn, DAHDI_RXSIG_OFFHOOK); } return 0; @@ -1168,7 +1168,7 @@ static void do_cleanup(void) { #ifdef CONFIG_PROC_FS - if(xpp_proc_toplevel) { + if (xpp_proc_toplevel) { DBG(GENERAL, "Removing '%s' from proc\n", PROC_DIR); remove_proc_entry(PROC_DIR, NULL); xpp_proc_toplevel = NULL; @@ -1189,18 +1189,18 @@ #endif #ifdef CONFIG_PROC_FS xpp_proc_toplevel = proc_mkdir(PROC_DIR, NULL); - if(!xpp_proc_toplevel) { + if (!xpp_proc_toplevel) { ret = -EIO; goto err; } #endif ret = xbus_core_init(); - if(ret) { + if (ret) { ERR("xbus_core_init failed (%d)\n", ret); goto err; } ret = xbus_pcm_init(xpp_proc_toplevel); - if(ret) { + if (ret) { ERR("xbus_pcm_init failed (%d)\n", ret); xbus_core_shutdown(); goto err; Index: drivers/dahdi/xpp/xpp_usb.c =================================================================== --- drivers/dahdi/xpp/xpp_usb.c (revision 7493) +++ drivers/dahdi/xpp/xpp_usb.c (working copy) @@ -86,20 +86,20 @@ # define USB_MAX_STRING 128 # define USB_GET_STRING(udev,field,buf) \ do { \ - if((udev)->descriptor.field) { \ + if ((udev)->descriptor.field) { \ char tmp[USB_MAX_STRING]; \ - if(usb_string((udev), (udev)->descriptor.field, tmp, sizeof(tmp)) > 0) \ + if (usb_string((udev), (udev)->descriptor.field, tmp, sizeof(tmp)) > 0) \ snprintf((buf), USB_MAX_STRING, "%s", tmp); \ } \ - } while(0); + } while (0); # define USB_GET_IFACE_NAME(udev,iface,buf) \ do { \ - if((iface)->desc.iInterface) { \ + if ((iface)->desc.iInterface) { \ char tmp[USB_MAX_STRING]; \ - if(usb_string((udev), (iface)->desc.iInterface, tmp, sizeof(tmp)) > 0) \ + if (usb_string((udev), (iface)->desc.iInterface, tmp, sizeof(tmp)) > 0) \ snprintf((buf), USB_MAX_STRING, "%s", tmp); \ } \ - } while(0); + } while (0); #endif #ifdef DEBUG_PCM_TIMING @@ -294,23 +294,23 @@ BUG_ON(!xbus); xusb = xusb_of(xbus); BUG_ON(!xusb); - if(!xusb->present) { - if((rate_limit++ % 1003) == 0) + if (!xusb->present) { + if ((rate_limit++ % 1003) == 0) XUSB_ERR(xusb, "abort allocations during device disconnect (%d)\n", rate_limit); return NULL; } size = min(xusb->endpoints[XUSB_SEND].max_size, xusb->endpoints[XUSB_RECV].max_size); uframe = kmem_cache_alloc(xusb_cache, gfp_flags); - if(!uframe) { - if((rate_limit++ % 1003) == 0) + if (!uframe) { + if ((rate_limit++ % 1003) == 0) XUSB_ERR(xusb, "frame allocation failed (%d)\n", rate_limit); return NULL; } usb_init_urb(&uframe->urb); p = usb_buffer_alloc(xusb->udev, size, gfp_flags, &uframe->urb.transfer_dma); - if(!p) { - if((rate_limit++ % 1003) == 0) + if (!p) { + if ((rate_limit++ % 1003) == 0) XUSB_ERR(xusb, "buffer allocation failed (%d)\n", rate_limit); kmem_cache_free(xusb_cache, uframe); return NULL; @@ -353,10 +353,10 @@ BUG_ON(xframe->xframe_magic != XFRAME_MAGIC); xusb = xusb_of(xbus); BUG_ON(!xusb); - if(!xusb->present) { + if (!xusb->present) { static int rate_limit; - if((rate_limit++ % 1003) == 0) + if ((rate_limit++ % 1003) == 0) XUSB_ERR(xusb, "abort do_send_xframe during device disconnect (%d)\n", rate_limit); ret = -ENODEV; @@ -365,10 +365,10 @@ /* * If something really bad happend, do not overflow the USB stack */ - if(atomic_read(&xusb->pending_writes) > MAX_PENDING_WRITES) { + if (atomic_read(&xusb->pending_writes) > MAX_PENDING_WRITES) { static int rate_limit; - if((rate_limit++ % 5000) == 0) + if ((rate_limit++ % 5000) == 0) XUSB_ERR(xusb, "USB device is totaly stuck. Dropping packets (#%d).\n", rate_limit); @@ -385,10 +385,10 @@ urb->transfer_buffer_length = XFRAME_LEN(xframe); do_gettimeofday(&xframe->tv_submitted); ret = usb_submit_urb(urb, GFP_ATOMIC); - if(ret < 0) { + if (ret < 0) { static int rate_limit; - if((rate_limit++ % 1000) == 0) + if ((rate_limit++ % 1000) == 0) XBUS_ERR(xbus, "%s: usb_submit_urb failed: %d\n", __FUNCTION__, ret); ret = -EBADF; @@ -415,7 +415,7 @@ BUG_ON(!xframe); xusb = xusb_of(xbus); BUG_ON(!xusb); - if(xusb->drop_next_pcm) { + if (xusb->drop_next_pcm) { FREE_SEND_XFRAME(xbus, xframe); /* return to pool */ xusb->drop_next_pcm = 0; return -EIO; @@ -446,17 +446,17 @@ BUG_ON(!xbus); xframe = ALLOC_RECV_XFRAME(xbus); - if(!xframe) { + if (!xframe) { XBUS_ERR(xbus, "Empty receive_pool\n"); goto out; } uframe = xframe_to_uframe(xframe); uframe_recompute(uframe, XUSB_RECV); ret = usb_submit_urb(&uframe->urb, GFP_ATOMIC); - if(ret < 0) { + if (ret < 0) { static int rate_limit; - if((rate_limit++ % 1000) == 0) + if ((rate_limit++ % 1000) == 0) XBUS_ERR(xbus, "%s: usb_submit_urb failed: %d\n", __FUNCTION__, ret); FREE_RECV_XFRAME(xbus, xframe); @@ -561,10 +561,10 @@ { const char *msg = (usb_pipein(endpoint->bEndpointAddress))?"input":"output"; - if(endpoint->wMaxPacketSize >= sizeof(xpacket_t)) + if (endpoint->wMaxPacketSize >= sizeof(xpacket_t)) return 1; - if(usb1) { + if (usb1) { NOTICE("USB1 endpoint detected: USB %s endpoint 0x%X support only wMaxPacketSize=%d.\n", msg, endpoint->bEndpointAddress, endpoint->wMaxPacketSize); return 1; @@ -592,13 +592,13 @@ endpoint = &iface_desc->endpoint[i].desc; ep_addr = endpoint->bEndpointAddress; - if(!BULK_ENDPOINT(endpoint)) { + if (!BULK_ENDPOINT(endpoint)) { DBG(DEVICES, "endpoint 0x%x is not bulk: mbAttributes=0x%X\n", ep_addr, endpoint->bmAttributes); continue; } - if(usb_pipein(ep_addr)) { // Input - if(ep_addr == model_info->in.ep_addr) { + if (usb_pipein(ep_addr)) { // Input + if (ep_addr == model_info->in.ep_addr) { if (!check_usb1(endpoint)) return 0; xusb_ep = &xusb->endpoints[XUSB_RECV]; @@ -607,7 +607,7 @@ xusb_ep->callback = xpp_receive_callback; } } else { // Output - if(ep_addr == model_info->out.ep_addr) { + if (ep_addr == model_info->out.ep_addr) { if (!check_usb1(endpoint)) return 0; xusb_ep = &xusb->endpoints[XUSB_SEND]; @@ -655,12 +655,12 @@ int i; DBG(DEVICES, "New XUSB device MODEL=%s\n", model_info->desc); - if(iface_desc->desc.bInterfaceNumber != model_info->iface_num) { + if (iface_desc->desc.bInterfaceNumber != model_info->iface_num) { DBG(DEVICES, "Skip interface #%d != #%d\n", iface_desc->desc.bInterfaceNumber, model_info->iface_num); return -ENODEV; } - if((retval = DO_USB_RESET_DEVICE(udev)) < 0) { + if ((retval = DO_USB_RESET_DEVICE(udev)) < 0) { ERR("usb_reset_device failed: %d\n", retval); goto probe_failed; } @@ -687,7 +687,7 @@ xusb->interface = interface; xusb->model_info = model_info; - if(!set_endpoints(xusb, iface_desc, model_info)) { + if (!set_endpoints(xusb, iface_desc, model_info)) { retval = -ENODEV; goto probe_failed; } @@ -722,24 +722,24 @@ /* let the user know what node this device is now attached to */ DBG(DEVICES, "USB XPP device now attached to minor %d\n", xusb->minor); xbus = xbus_new(&xusb_ops, min(xusb->endpoints[XUSB_SEND].max_size, xusb->endpoints[XUSB_RECV].max_size), &udev->dev, xusb); - if(!xbus) { + if (!xbus) { retval = -ENOMEM; goto probe_failed; } spin_lock_irqsave(&xusb_lock, flags); - for(i = 0; i < MAX_BUSES; i++) { - if(xusb_array[i] == NULL) + for (i = 0; i < MAX_BUSES; i++) { + if (xusb_array[i] == NULL) break; } spin_unlock_irqrestore(&xusb_lock, flags); - if(i >= MAX_BUSES) { + if (i >= MAX_BUSES) { ERR("xpp_usb: Too many XPP USB buses\n"); retval = -ENOMEM; goto probe_failed; } usb_make_path(udev, xusb->path, XBUS_DESCLEN); // May trunacte... ignore snprintf(xbus->connector, XBUS_DESCLEN, "%s", xusb->path); - if(xusb->serial && xusb->serial[0]) + if (xusb->serial && xusb->serial[0]) snprintf(xbus->label, LABEL_SIZE, "usb:%s", xusb->serial); xusb->index = i; xusb_array[i] = xusb; @@ -760,23 +760,23 @@ bus_count++; xusb->xbus_num = xbus->num; /* prepare several pending frames for receive side */ - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) xusb_listen(xusb); xbus_connect(xbus); return retval; probe_failed: ERR("Failed to initialize xpp usb bus: %d\n", retval); usb_set_intfdata(interface, NULL); - if(xusb) { - if(xusb->minor) { // passed registration phase + if (xusb) { + if (xusb->minor) { // passed registration phase ERR("Calling usb_deregister_dev()\n"); usb_deregister_dev(interface, &xusb_class); } ERR("Removing failed xusb\n"); KZFREE(xusb); } - if(xbus) { - if(procsummary) { + if (xbus) { + if (procsummary) { XBUS_DBG(PROC, xbus, "Remove proc_entry: " PROC_USBXPP_SUMMARY "\n"); remove_proc_entry(PROC_USBXPP_SUMMARY, xbus->proc_xbus_dir); procsummary = NULL; @@ -816,15 +816,15 @@ xbus = xbus_num(xusb->xbus_num); /* find our xusb */ - for(i = 0; i < MAX_BUSES; i++) { - if(xusb_array[i] == xusb) + for (i = 0; i < MAX_BUSES; i++) { + if (xusb_array[i] == xusb) break; } BUG_ON(i >= MAX_BUSES); xusb_array[i] = NULL; #ifdef CONFIG_PROC_FS - if(xbus->proc_xbus_dir) { + if (xbus->proc_xbus_dir) { XBUS_DBG(PROC, xbus, "Remove proc_entry: " PROC_USBXPP_SUMMARY "\n"); remove_proc_entry(PROC_USBXPP_SUMMARY, xbus->proc_xbus_dir); } @@ -856,7 +856,7 @@ int writes = atomic_read(&xusb->pending_writes); int i; - if(!xbus) { + if (!xbus) { XUSB_ERR(xusb, "Sent URB does not belong to a valid xbus anymore...\n"); return; } @@ -865,18 +865,18 @@ do_gettimeofday(&now); xusb->last_tx = xframe->tv_submitted; usec = usec_diff(&now, &xframe->tv_submitted); - if(usec > xusb->max_tx_delay) + if (usec > xusb->max_tx_delay) xusb->max_tx_delay = usec; i = usec / USEC_BUCKET; - if(i >= NUM_BUCKETS) + if (i >= NUM_BUCKETS) i = NUM_BUCKETS - 1; xusb->usb_tx_delay[i]++; - if(unlikely(usec > tx_sluggish)) { + if (unlikely(usec > tx_sluggish)) { atomic_inc(&xusb->usb_sluggish_count); - if(xusb->sluggish_debounce++ > drop_pcm_after) { + if (xusb->sluggish_debounce++ > drop_pcm_after) { static int rate_limit; - if((rate_limit++ % 1003) == 500) /* skip first messages */ + if ((rate_limit++ % 1003) == 500) /* skip first messages */ XUSB_NOTICE(xusb, "Sluggish USB. Dropping next PCM frame (pending_writes=%d)\n", writes); @@ -889,7 +889,7 @@ /* sync/async unlink faults aren't errors */ if (urb->status && !(urb->status == -ENOENT || urb->status == -ECONNRESET)) { static int rate_limit; - if((rate_limit++ % 1000) < 10) { + if ((rate_limit++ % 1000) < 10) { XUSB_ERR(xusb, "nonzero write bulk status received: %d (pending_writes=%d)\n", urb->status, writes); @@ -899,7 +899,7 @@ } else XUSB_COUNTER(xusb, TX_FRAMES)++; FREE_SEND_XFRAME(xbus, xframe); - if(!xusb->present) + if (!xusb->present) XUSB_ERR(xusb, "A urb from non-connected device?\n"); } @@ -916,12 +916,12 @@ do_gettimeofday(&now); atomic_dec(&xusb->pending_reads); - if(!xbus) { + if (!xbus) { XUSB_ERR(xusb, "Received URB does not belong to a valid xbus anymore...\n"); return; } is_inuse = 1; - if(!xusb->present) { + if (!xusb->present) { do_resubmit = 0; goto err; } @@ -931,10 +931,10 @@ goto err; } size = urb->actual_length; - if(size == 0) { + if (size == 0) { static int rate_limit; - if((rate_limit++ % 5003) == 0) + if ((rate_limit++ % 5003) == 0) XUSB_NOTICE(xusb, "Received a zero length URBs (%d)\n", rate_limit); XUSB_COUNTER(xusb, RCV_ZERO_LEN)++; goto err; @@ -948,7 +948,7 @@ /* Send UP */ xbus_receive_xframe(xbus, xframe); end: - if(do_resubmit) + if (do_resubmit) xusb_listen(xusb); return; err: @@ -961,7 +961,7 @@ static void xpp_usb_cleanup(void) { - if(xusb_cache) { + if (xusb_cache) { kmem_cache_destroy(xusb_cache); xusb_cache = NULL; } @@ -984,7 +984,7 @@ NULL, #endif NULL); - if(!xusb_cache) { + if (!xusb_cache) { ret = -ENOMEM; goto failure; } @@ -1024,7 +1024,7 @@ uint usb_tx_delay[NUM_BUCKETS]; const int mark_limit = tx_sluggish/USEC_BUCKET; - if(!xusb) + if (!xusb) goto out; // TODO: probably needs a per-xusb lock: spin_lock_irqsave(&xusb_lock, flags); @@ -1055,10 +1055,10 @@ memcpy(usb_tx_delay, xusb->usb_tx_delay, sizeof(usb_tx_delay)); len += sprintf(page + len, "usb_tx_delay[%d,%d,%d]: ", USEC_BUCKET, BUCKET_START, NUM_BUCKETS); - for(i = BUCKET_START; i < NUM_BUCKETS; i++) { + for (i = BUCKET_START; i < NUM_BUCKETS; i++) { len += sprintf(page + len, "%6d ", usb_tx_delay[i]); - if(i == mark_limit) + if (i == mark_limit) len += sprintf(page + len, "| "); } len += sprintf(page + len, "\nPCM_TX_DROPS: %5d (sluggish: %d)\n", @@ -1066,7 +1066,7 @@ atomic_read(&xusb->usb_sluggish_count) ); len += sprintf(page + len, "\nCOUNTERS:\n"); - for(i = 0; i < XUSB_COUNTER_MAX; i++) { + for (i = 0; i < XUSB_COUNTER_MAX; i++) { len += sprintf(page + len, "\t%-15s = %d\n", xusb_counters[i].name, xusb->counters[i]); } #if 0 Index: drivers/dahdi/xpp/xproto.c =================================================================== --- drivers/dahdi/xpp/xproto.c (revision 7493) +++ drivers/dahdi/xpp/xproto.c (working copy) @@ -70,7 +70,7 @@ static const xproto_table_t *xproto_table(xpd_type_t cardtype) { - if(cardtype >= XPD_TYPE_NOMODULE) + if (cardtype >= XPD_TYPE_NOMODULE) return NULL; return xprotocol_tables[cardtype]; } @@ -79,24 +79,24 @@ { const xproto_table_t *xtable; - if(cardtype >= XPD_TYPE_NOMODULE) + if (cardtype >= XPD_TYPE_NOMODULE) return NULL; xtable = xprotocol_tables[cardtype]; - if(!xtable) { /* Try to load the relevant module */ + if (!xtable) { /* Try to load the relevant module */ int ret = request_module(XPD_TYPE_PREFIX "%d", cardtype); - if(ret != 0) { + if (ret != 0) { NOTICE("%s: Failed to load module for type=%d. exit status=%d.\n", __FUNCTION__, cardtype, ret); /* Drop through: we may be lucky... */ } xtable = xprotocol_tables[cardtype]; } - if(xtable) { + if (xtable) { BUG_ON(!xtable->owner); #ifdef CONFIG_MODULE_UNLOAD DBG(GENERAL, "%s refcount was %d\n", xtable->name, module_refcount(xtable->owner)); #endif - if(!try_module_get(xtable->owner)) { + if (!try_module_get(xtable->owner)) { ERR("%s: try_module_get for %s failed.\n", __FUNCTION__, xtable->name); return NULL; } @@ -139,8 +139,8 @@ int ret = -EPROTO; BUG_ON(!pack); - if(!valid_xpd_addr(&XPACKET_ADDR(pack))) { - if(printk_ratelimit()) { + if (!valid_xpd_addr(&XPACKET_ADDR(pack))) { + if (printk_ratelimit()) { XBUS_NOTICE(xbus, "%s: from %d%d: bad address.\n", __FUNCTION__, XPACKET_ADDR_UNIT(pack), XPACKET_ADDR_SUBUNIT(pack)); @@ -153,11 +153,11 @@ /* XPD may be NULL (e.g: during bus polling */ xe = xproto_global_entry(op); /*-------- Validations -----------*/ - if(!xe) { + if (!xe) { const xproto_table_t *xtable; - if(!xpd) { - if(printk_ratelimit()) { + if (!xpd) { + if (printk_ratelimit()) { XBUS_NOTICE(xbus, "%s: from %d%d opcode=0x%02X: no such global command.\n", __FUNCTION__, XPACKET_ADDR_UNIT(pack), XPACKET_ADDR_SUBUNIT(pack), op); @@ -166,16 +166,16 @@ goto out; } xtable = xproto_table(xpd->type); - if(!xtable) { - if(printk_ratelimit()) + if (!xtable) { + if (printk_ratelimit()) XPD_ERR(xpd, "%s: no protocol table (type=%d)\n", __FUNCTION__, xpd->type); goto out; } xe = xproto_card_entry(xtable, op); - if(!xe) { - if(printk_ratelimit()) { + if (!xe) { + if (printk_ratelimit()) { XPD_NOTICE(xpd, "%s: bad command (type=%d,opcode=0x%x)\n", __FUNCTION__, xpd->type, op); @@ -186,8 +186,8 @@ } table = xe->table; BUG_ON(!table); - if(!table->packet_is_valid(pack)) { - if(printk_ratelimit()) { + if (!table->packet_is_valid(pack)) { + if (printk_ratelimit()) { ERR("xpp: %s: wrong size %d for opcode=0x%02X\n", __FUNCTION__, XPACKET_LEN(pack), op); dump_packet("packet_process -- wrong size", pack, debug); @@ -211,7 +211,7 @@ int len; int ret; - if(debug & DBG_COMMANDS) + if (debug & DBG_COMMANDS) dump_xframe("RX-CMD", xbus, xframe, DBG_ANY); p = xframe->packets; xframe_end = p + XFRAME_LEN(xframe); @@ -219,10 +219,10 @@ pack = (xpacket_t *)p; len = XPACKET_LEN(pack); /* Sanity checks */ - if(unlikely(XPACKET_OP(pack) == XPROTO_NAME(GLOBAL,PCM_READ))) { + if (unlikely(XPACKET_OP(pack) == XPROTO_NAME(GLOBAL,PCM_READ))) { static int rate_limit; - if((rate_limit++ % 1003) == 0) { + if ((rate_limit++ % 1003) == 0) { XBUS_DBG(GENERAL, xbus, "A PCM packet within a Non-PCM xframe\n"); dump_xframe("In Non-PCM xframe", xbus, xframe, debug); } @@ -230,10 +230,10 @@ goto out; } p += len; - if(p > xframe_end || len < RPACKET_HEADERSIZE) { + if (p > xframe_end || len < RPACKET_HEADERSIZE) { static int rate_limit; - if((rate_limit++ % 1003) == 0) { + if ((rate_limit++ % 1003) == 0) { XBUS_NOTICE(xbus, "Invalid packet length %d\n", len); dump_xframe("BAD LENGTH", xbus, xframe, debug); } @@ -241,9 +241,9 @@ goto out; } ret = packet_process(xbus, pack); - if(unlikely(ret < 0)) + if (unlikely(ret < 0)) break; - } while(p < xframe_end); + } while (p < xframe_end); out: FREE_RECV_XFRAME(xbus, xframe); return ret; @@ -256,17 +256,17 @@ struct timeval tv_received; int usec; - if(XFRAME_LEN(xframe) < RPACKET_HEADERSIZE) { + if (XFRAME_LEN(xframe) < RPACKET_HEADERSIZE) { static int rate_limit; - if((rate_limit++ % 1003) == 0) { + if ((rate_limit++ % 1003) == 0) { XBUS_NOTICE(xbus, "short xframe\n"); dump_xframe("short xframe", xbus, xframe, debug); } FREE_RECV_XFRAME(xbus, xframe); return -EPROTO; } - if(!XBUS_FLAGS(xbus, CONNECTED)) { + if (!XBUS_FLAGS(xbus, CONNECTED)) { XBUS_DBG(GENERAL, xbus, "Dropped xframe. Is shutting down.\n"); return -ENODEV; } @@ -274,8 +274,8 @@ /* * We want to check that xframes do not mix PCM and other commands */ - if(XPACKET_IS_PCM((xpacket_t *)xframe->packets)) { - if(!XBUS_IS(xbus, READY)) + if (XPACKET_IS_PCM((xpacket_t *)xframe->packets)) { + if (!XBUS_IS(xbus, READY)) FREE_RECV_XFRAME(xbus, xframe); else xframe_receive_pcm(xbus, xframe); @@ -287,7 +287,7 @@ do_gettimeofday(&now); usec = (now.tv_sec - tv_received.tv_sec) * 1000000 + now.tv_usec - tv_received.tv_usec; - if(usec > xbus->max_rx_process) + if (usec > xbus->max_rx_process) xbus->max_rx_process = usec; return ret; } @@ -300,7 +300,7 @@ byte op = XPACKET_OP(packet); byte *addr = (byte *)&XPACKET_ADDR(packet); - if(!debug) + if (!debug) return; printk(KERN_DEBUG "%s: XPD=%1X-%1X%c (0x%X) OP=0x%02X LEN=%d", msg, @@ -316,14 +316,14 @@ byte *p = (byte *)packet; printk(" BYTES: "); - for(i = 0; i < XPACKET_LEN(packet); i++) { + for (i = 0; i < XPACKET_LEN(packet); i++) { static int limiter = 0; - if(i >= sizeof(xpacket_t)) { - if(limiter < ERR_REPORT_LIMIT) { + if (i >= sizeof(xpacket_t)) { + if (limiter < ERR_REPORT_LIMIT) { ERR("%s: length overflow i=%d > sizeof(xpacket_t)=%lu\n", __FUNCTION__, i+1, (long)sizeof(xpacket_t)); - } else if(limiter == ERR_REPORT_LIMIT) { + } else if (limiter == ERR_REPORT_LIMIT) { ERR("%s: error packet #%d... squelsh reports.\n", __FUNCTION__, limiter); } @@ -347,12 +347,12 @@ char reg_buf[MAX_PROC_WRITE]; char data_buf[MAX_PROC_WRITE]; - if(regcmd->bytes > sizeof(*regcmd) - 1) { /* The size byte is not included */ + if (regcmd->bytes > sizeof(*regcmd) - 1) { /* The size byte is not included */ PORT_NOTICE(xbus, unit, port, "%s: %s: Too long: regcmd->bytes = %d\n", __FUNCTION__, msg, regcmd->bytes); return; } - if(regcmd->is_multibyte) { + if (regcmd->is_multibyte) { char buf[MAX_PROC_WRITE + 1]; int i; int n = 0; @@ -360,7 +360,7 @@ const byte *p = REG_XDATA(regcmd); buf[0] = '\0'; - for(i = 0; i < len && n < MAX_PROC_WRITE; i++) + for (i = 0; i < len && n < MAX_PROC_WRITE; i++) n += snprintf(&buf[n], MAX_PROC_WRITE - n, "%02X ", p[i]); PORT_DBG(REGS, xbus, unit, port, "UNIT-%d PORT-%d: Multibyte(eoframe=%d) %s[0..%zd]: %s%s\n", @@ -368,7 +368,7 @@ msg, len-1, buf, (n >= MAX_PROC_WRITE)?"...":""); return; } - if(regcmd->bytes != sizeof(*regcmd) - 1) { /* The size byte is not included */ + if (regcmd->bytes != sizeof(*regcmd) - 1) { /* The size byte is not included */ PORT_NOTICE(xbus, unit, port, "%s: %s: Wrong size: regcmd->bytes = %d\n", __FUNCTION__, msg, regcmd->bytes); return; @@ -378,7 +378,7 @@ (REG_FIELD(regcmd, all_ports_broadcast)) ? "*" : ""); action = (REG_FIELD(regcmd, read_request)) ? 'R' : 'W'; modifier = 'D'; - if(REG_FIELD(regcmd, do_subreg)) { + if (REG_FIELD(regcmd, do_subreg)) { snprintf(reg_buf, MAX_PROC_WRITE, "%02X %02X", REG_FIELD(regcmd, regnum), REG_FIELD(regcmd, subreg)); @@ -387,9 +387,9 @@ snprintf(reg_buf, MAX_PROC_WRITE, "%02X", REG_FIELD(regcmd, regnum)); } - if(REG_FIELD(regcmd, read_request)) { + if (REG_FIELD(regcmd, read_request)) { data_buf[0] = '\0'; - } else if(REG_FIELD(regcmd, do_datah)) { + } else if (REG_FIELD(regcmd, do_datah)) { snprintf(data_buf, MAX_PROC_WRITE, "%02X %02X", REG_FIELD(regcmd, data_low), REG_FIELD(regcmd, data_high)); @@ -409,13 +409,13 @@ BUG_ON(xpd_type >= XPD_TYPE_NOMODULE); proto_table = xprotocol_tables[xpd_type]; - if(!proto_table) + if (!proto_table) return NULL; return proto_table->name; } #define CHECK_XOP(f) \ - if(!(xops)->f) { \ + if (!(xops)->f) { \ ERR("%s: missing xmethod %s [%s (%d)]\n", __FUNCTION__, #f, name, type); \ return -EINVAL; \ } @@ -429,12 +429,12 @@ BUG_ON(!proto_table); type = proto_table->type; name = proto_table->name; - if(type >= XPD_TYPE_NOMODULE) { + if (type >= XPD_TYPE_NOMODULE) { NOTICE("%s: Bad xproto type %d\n", __FUNCTION__, type); return -EINVAL; } DBG(GENERAL, "%s (%d)\n", name, type); - if(xprotocol_tables[type]) + if (xprotocol_tables[type]) NOTICE("%s: overriding registration of %s (%d)\n", __FUNCTION__, name, type); xops = &proto_table->xops; CHECK_XOP(card_new); @@ -463,11 +463,11 @@ type = proto_table->type; name = proto_table->name; DBG(GENERAL, "%s (%d)\n", name, type); - if(type >= XPD_TYPE_NOMODULE) { + if (type >= XPD_TYPE_NOMODULE) { NOTICE("%s: Bad xproto type %s (%d)\n", __FUNCTION__, name, type); return; } - if(!xprotocol_tables[type]) + if (!xprotocol_tables[type]) NOTICE("%s: xproto type %s (%d) is already unregistered\n", __FUNCTION__, name, type); xprotocol_tables[type] = NULL; } Index: drivers/dahdi/xpp/xproto.h =================================================================== --- drivers/dahdi/xpp/xproto.h (revision 7493) +++ drivers/dahdi/xpp/xproto.h (working copy) @@ -45,7 +45,7 @@ (p)->unit = (u); \ (p)->subunit = (s); \ (p)->sync_master = 0; \ - } while(0) + } while (0) struct xpacket_header { uint16_t packet_len:10; @@ -141,23 +141,23 @@ XPACKET_ADDR_SUBUNIT(p) = XBUS_SUBUNIT(to); \ XPACKET_ADDR_SYNC(p) = 0; \ XPACKET_ADDR_RESERVED(p) = 0; \ - } while(0) + } while (0) #define XFRAME_NEW_CMD(frm, p, xbus, card, op, to) \ do { \ int pack_len = RPACKET_SIZE(card,op); \ \ - if(!XBUS_FLAGS(xbus, CONNECTED)) \ + if (!XBUS_FLAGS(xbus, CONNECTED)) \ return -ENODEV; \ (frm) = ALLOC_SEND_XFRAME(xbus); \ - if(!(frm)) \ + if (!(frm)) \ return -ENOMEM; \ (p) = xframe_next_packet(frm, pack_len); \ - if(!(p)) \ + if (!(p)) \ return -ENOMEM; \ XPACKET_INIT(p, card, op, to, 0, 0); \ (frm)->usec_towait = 0; \ - } while(0) + } while (0) #endif Index: include/dahdi/fasthdlc.h =================================================================== --- include/dahdi/fasthdlc.h (revision 7493) +++ include/dahdi/fasthdlc.h (working copy) @@ -155,7 +155,7 @@ frame header */ x=1; p=7; - while(p && (c & x)) { + while (p && (c & x)) { x <<= 1; p--; } @@ -166,7 +166,7 @@ static inline void hdlc_search_print(char c, char r) { int x=0x80; - while(x) { + while (x) { printf("%s", c & x ? "1" : "0"); x >>= 1; } @@ -187,7 +187,7 @@ unsigned char data=0; int bits=0; int consumed=0; - while(bits < 8) { + while (bits < 8) { data >>=1; consumed++; if (ones == 5) { @@ -240,7 +240,7 @@ "Valid", }; printf("%d one's then ", x); - while(z) { + while (z) { printf("%s", c & z ? "1" : "0"); z >>= 1; } @@ -299,7 +299,7 @@ unsigned short c; printf("%d ones, %02x (", x, y); z = 0x80; - while(z) { + while (z) { printf("%s", y & z ? "1" : "0"); z >>= 1; } @@ -467,7 +467,7 @@ while ((h->bits >= minbits[h->state]) && (retval == RETURN_EMPTY_FLAG)) { /* Run until we can no longer be assured that we will have enough bits to continue */ - switch(h->state) { + switch (h->state) { case FRAME_SEARCH: /* Look for an HDLC frame, keying from the top byte. */ @@ -484,7 +484,7 @@ h->data <<= ((next & 0x0f00) >> 8); h->state = (next & STATE_MASK) >> 15; h->ones = (next & ONES_MASK) >> 12; - switch(next & STATUS_MASK) { + switch (next & STATUS_MASK) { case STATUS_CONTROL: if (next & CONTROL_COMPLETE) { /* A complete, valid frame received */