summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2012-01-11 15:20:05 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2012-01-11 15:20:05 +0000
commitf56a75587b57b0b23d62bbd5c085c1b992152189 (patch)
tree04417bc785dc5b08a13402dea8efb5798c818697
parent12792163453c97fb0268e470d65c4d94146beecd (diff)
xpp: style - insert space afer if/while/for/switch
* Applied via: perl -pi -e 's/\b(if|while|for|switch)\b\(/$1 (/g' "$@" Signed-off-by: Oron Peled <oron.peled@xorcom.com> Acked-By: Tzafrir Cohen <tzafrir.cohen@xorcom.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10425 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r--drivers/dahdi/xpp/card_bri.c196
-rw-r--r--drivers/dahdi/xpp/card_fxo.c210
-rw-r--r--drivers/dahdi/xpp/card_fxs.c210
-rw-r--r--drivers/dahdi/xpp/card_global.c126
-rw-r--r--drivers/dahdi/xpp/card_pri.c362
-rw-r--r--drivers/dahdi/xpp/dahdi_debug.c12
-rw-r--r--drivers/dahdi/xpp/dahdi_debug.h10
-rw-r--r--drivers/dahdi/xpp/mmapdrv.c6
-rw-r--r--drivers/dahdi/xpp/parport_debug.c10
-rw-r--r--drivers/dahdi/xpp/xbus-core.c254
-rw-r--r--drivers/dahdi/xpp/xbus-pcm.c242
-rw-r--r--drivers/dahdi/xpp/xbus-sysfs.c86
-rw-r--r--drivers/dahdi/xpp/xdefs.h6
-rw-r--r--drivers/dahdi/xpp/xframe_queue.c40
-rw-r--r--drivers/dahdi/xpp/xpd.h4
-rw-r--r--drivers/dahdi/xpp/xpp_dahdi.c112
-rw-r--r--drivers/dahdi/xpp/xpp_usb.c126
-rw-r--r--drivers/dahdi/xpp/xproto.c98
-rw-r--r--drivers/dahdi/xpp/xproto.h12
19 files changed, 1061 insertions, 1061 deletions
diff --git a/drivers/dahdi/xpp/card_bri.c b/drivers/dahdi/xpp/card_bri.c
index 3d84694..e859d74 100644
--- a/drivers/dahdi/xpp/card_bri.c
+++ b/drivers/dahdi/xpp/card_bri.c
@@ -84,7 +84,7 @@ static const char *xhfc_state_name(bool is_nt, enum xhfc_states state)
_E(NT_DEACTIVTING),
};
#undef _E
- if(is_nt) {
+ if (is_nt) {
if (state > ST_NT_DEACTIVTING)
p = "NT ???";
else
@@ -242,7 +242,7 @@ static void dump_hex_buf(xpd_t *xpd, char *msg, byte *buf, size_t len)
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)?"...":"");
@@ -258,19 +258,19 @@ static void dump_dchan_packet(xpd_t *xpd, bool transmit, byte *buf, int len)
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]);
@@ -284,7 +284,7 @@ static void dump_dchan_packet(xpd_t *xpd, bool transmit, byte *buf, int len)
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);
@@ -298,9 +298,9 @@ static void dchan_state(xpd_t *xpd, bool up)
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 {
@@ -318,11 +318,11 @@ static void layer1_state(xpd_t *xpd, bool up)
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);
}
@@ -336,8 +336,8 @@ static void te_activation(xpd_t *xpd, bool on)
BUG_ON(!priv);
curr_state = priv->state_register.bits.v_su_sta;
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);
@@ -379,8 +379,8 @@ static void nt_activation(xpd_t *xpd, bool on)
BUG_ON(!priv);
curr_state = priv->state_register.bits.v_su_sta;
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 */
@@ -397,7 +397,7 @@ static void nt_activation(xpd_t *xpd, bool on)
break;
}
} else {
- switch(curr_state) {
+ switch (curr_state) {
case ST_RESET: /* F/G 0 */
case ST_NT_DEACTIVATED: /* G1 */
case ST_NT_DEACTIVTING: /* G4 */
@@ -428,16 +428,16 @@ static int bri_check_stat(xpd_t *xpd, struct dahdi_chan *dchan, byte *buf, int l
priv = xpd->priv;
BUG_ON(!priv);
- if(len <= 0) {
+ if (len <= 0) {
XPD_NOTICE(xpd, "D-Chan RX DROP: short frame (len=%d)\n", len);
dahdi_hdlc_abort(dchan, DAHDI_EVENT_ABORT);
return -EPROTO;
}
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);
@@ -462,31 +462,31 @@ static int rx_dchan(xpd_t *xpd, reg_cmd_t *regcmd)
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;
BUG_ON(!priv);
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");
goto out;
}
XPD_DBG(GENERAL, xpd, "D-Chan RX: eoframe=%d len=%d\n", eoframe, len);
dahdi_hdlc_putbuf(dchan, src, (eoframe) ? len - 1 : len);
- 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.
*/
dahdi_hdlc_finish(dchan);
priv->dchan_rx_counter++;
@@ -645,7 +645,7 @@ static void bri_proc_remove(xbus_t *xbus, xpd_t *xpd)
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);
}
@@ -662,7 +662,7 @@ static int bri_proc_create(xbus_t *xbus, xpd_t *xpd)
#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);
bri_proc_remove(xbus, xpd);
return -EINVAL;
@@ -678,17 +678,17 @@ static xpd_t *BRI_card_new(xbus_t *xbus, int unit, int subunit, const xproto_tab
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;
PHONEDEV(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:
@@ -753,7 +753,7 @@ static int BRI_card_dahdi_preregistration(xpd_t *xpd, bool on)
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;
}
@@ -770,7 +770,7 @@ static int BRI_card_dahdi_preregistration(xpd_t *xpd, bool on)
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;
@@ -816,7 +816,7 @@ static void handle_leds(xbus_t *xbus, xpd_t *xpd)
int mod;
BUG_ON(!xpd);
- if(IS_NT(xpd)) {
+ if (IS_NT(xpd)) {
which_led = RED_LED;
other_led = GREEN_LED;
} else {
@@ -826,10 +826,10 @@ static void handle_leds(xbus_t *xbus, xpd_t *xpd)
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 {
@@ -839,11 +839,11 @@ static void handle_leds(xbus_t *xbus, xpd_t *xpd)
}
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;
@@ -851,9 +851,9 @@ static void handle_leds(xbus_t *xbus, xpd_t *xpd)
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);
@@ -864,7 +864,7 @@ static void handle_leds(xbus_t *xbus, xpd_t *xpd)
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);
}
}
@@ -876,12 +876,12 @@ static void handle_bri_timers(xpd_t *xpd)
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 */
@@ -915,9 +915,9 @@ static int BRI_card_tick(xbus_t *xbus, xpd_t *xpd)
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,
@@ -932,7 +932,7 @@ static int BRI_card_tick(xbus_t *xbus, xpd_t *xpd)
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");
@@ -943,18 +943,18 @@ static int BRI_card_tick(xbus_t *xbus, xpd_t *xpd)
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;
@@ -971,7 +971,7 @@ static int BRI_card_tick(xbus_t *xbus, xpd_t *xpd)
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:
@@ -991,7 +991,7 @@ static int BRI_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long a
static int BRI_card_open(xpd_t *xpd, lineno_t pos)
{
BUG_ON(!xpd);
- if(pos == 2) {
+ if (pos == 2) {
LINE_DBG(SIGNAL, xpd, pos, "OFFHOOK the whole span\n");
BIT_SET(PHONEDEV(xpd).offhook_state, 0);
BIT_SET(PHONEDEV(xpd).offhook_state, 1);
@@ -1004,7 +1004,7 @@ static int BRI_card_open(xpd_t *xpd, lineno_t pos)
static int BRI_card_close(xpd_t *xpd, lineno_t pos)
{
/* Clear D-Channel pending data */
- if(pos == 2) {
+ if (pos == 2) {
LINE_DBG(SIGNAL, xpd, pos, "ONHOOK the whole span\n");
BIT_CLR(PHONEDEV(xpd).offhook_state, 0);
BIT_CLR(PHONEDEV(xpd).offhook_state, 1);
@@ -1088,14 +1088,14 @@ static int bri_startup(struct file *file, struct dahdi_span *span)
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_PHONE_METHOD(card_state, xpd, 1);
- if(SPAN_REGISTERED(xpd)) {
+ if (SPAN_REGISTERED(xpd)) {
dchan = XPD_CHAN(xpd, 2);
span->flags |= DAHDI_FLAG_RUNNING;
/*
@@ -1121,7 +1121,7 @@ static int bri_shutdown(struct dahdi_span *span)
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;
}
@@ -1143,7 +1143,7 @@ static void BRI_card_pcm_recompute(xpd_t *xpd,
BUG_ON(!xpd);
main_xpd = xpd_byaddr(xpd->xbus, xpd->addr.unit, 0);
- if(!main_xpd) {
+ if (!main_xpd) {
XPD_DBG(DEVICES, xpd, "Unit 0 is already gone. Ignore request\n");
return;
}
@@ -1154,19 +1154,19 @@ static void BRI_card_pcm_recompute(xpd_t *xpd,
spin_lock_irqsave(&PHONEDEV(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(xpd->xbus, main_xpd->addr.unit, i);
- if(sub_xpd) {
+ if (sub_xpd) {
xpp_line_t lines =
PHONEDEV(sub_xpd).offhook_state & ~(PHONEDEV(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);
}
}
@@ -1175,7 +1175,7 @@ static void BRI_card_pcm_recompute(xpd_t *xpd,
* 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;
}
@@ -1202,23 +1202,23 @@ static void BRI_card_pcm_fromspan(xpd_t *xpd, xpacket_t *pack)
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(xpd->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 = PHONEDEV(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
@@ -1246,26 +1246,26 @@ static void BRI_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack)
/*
* 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(xpd->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);
@@ -1371,12 +1371,12 @@ static void su_new_state(xpd_t *xpd, byte reg_x30)
BUG_ON(!xpd);
priv = xpd->priv;
BUG_ON(!priv);
- if(!priv->initialized) {
+ if (!priv->initialized) {
XPD_ERR(xpd, "%s called on uninitialized AB\n", __func__);
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;
@@ -1389,7 +1389,7 @@ static void su_new_state(xpd_t *xpd, byte reg_x30)
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");
@@ -1436,7 +1436,7 @@ static void su_new_state(xpd_t *xpd, byte reg_x30)
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 */
@@ -1473,17 +1473,17 @@ static int BRI_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info)
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(__func__, 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 {
@@ -1494,23 +1494,23 @@ static int BRI_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info)
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(&PHONEDEV(xpd).open_counter) > 0)
+ if (atomic_read(&PHONEDEV(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)) {
@@ -1529,14 +1529,14 @@ static int BRI_card_state(xpd_t *xpd, bool on)
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( ! IS_NT(xpd))
+ if (on) {
+ if (!test_bit(HFC_L1_ACTIVATED, &priv->l1_flags)) {
+ if ( ! IS_NT(xpd))
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;
}
@@ -1602,13 +1602,13 @@ static int proc_bri_info_read(char *page, char **start, off_t off, int count, in
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',
@@ -1620,7 +1620,7 @@ static int proc_bri_info_read(char *page, char **start, off_t off, int count, in
priv->state_register.bits.v_g2_g3);
} else
len += sprintf(page + len, "Unknown\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);
@@ -1630,7 +1630,7 @@ static int proc_bri_info_read(char *page, char **start, off_t off, int count, in
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 {
@@ -1661,7 +1661,7 @@ static int bri_xpd_probe(struct device *dev)
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;
@@ -1695,7 +1695,7 @@ static int __init card_bri_startup(void)
{
int ret;
- if((ret = xpd_driver_register(&bri_driver.driver)) < 0)
+ if ((ret = xpd_driver_register(&bri_driver.driver)) < 0)
return ret;
INFO("revision %s\n", XPP_VERSION);
xproto_register(&PROTO_TABLE(BRI));
diff --git a/drivers/dahdi/xpp/card_fxo.c b/drivers/dahdi/xpp/card_fxo.c
index 1b1c5ac..83778d5 100644
--- a/drivers/dahdi/xpp/card_fxo.c
+++ b/drivers/dahdi/xpp/card_fxo.c
@@ -160,8 +160,8 @@ struct FXO_priv_data {
#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 @@ struct FXO_priv_data {
static const char *power2str(enum power_state pw)
{
- switch(pw) {
+ switch (pw) {
case POWER_UNKNOWN: return "UNKNOWN";
case POWER_OFF: return "OFF";
case POWER_ON: return "ON";
@@ -213,12 +213,12 @@ static int do_led(xpd_t *xpd, lineno_t chan, byte which, bool on)
xbus = xpd->xbus;
priv = xpd->priv;
which = which % NUM_LEDS;
- if(IS_SET(PHONEDEV(xpd).digital_outputs, chan) || IS_SET(PHONEDEV(xpd).digital_inputs, chan))
+ if (IS_SET(PHONEDEV(xpd).digital_outputs, chan) || IS_SET(PHONEDEV(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 @@ static void handle_fxo_leds(xpd_t *xpd)
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(PHONEDEV(xpd).digital_outputs, i) || IS_SET(PHONEDEV(xpd).digital_inputs, i))
+ if (IS_SET(PHONEDEV(xpd).digital_outputs, i) || IS_SET(PHONEDEV(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 handle_fxo_leds(xpd_t *xpd)
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 @@ static void mark_ring(xpd_t *xpd, lineno_t pos, bool on, bool update_dahdi)
* due to voltage fluctuations.
*/
reset_battery_readings(xpd, pos);
- if(on && !PHONEDEV(xpd).ringing[pos]) {
+ if (on && !PHONEDEV(xpd).ringing[pos]) {
LINE_DBG(SIGNAL, xpd, pos, "START\n");
PHONEDEV(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 && PHONEDEV(xpd).ringing[pos]) {
+ } else if (!on && PHONEDEV(xpd).ringing[pos]) {
LINE_DBG(SIGNAL, xpd, pos, "STOP\n");
PHONEDEV(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 @@ static int do_sethook(xpd_t *xpd, int pos, bool to_offhook)
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 @@ static int do_sethook(xpd_t *xpd, int pos, bool to_offhook)
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 @@ static void fxo_proc_remove(xbus_t *xbus, xpd_t *xpd)
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 @@ static int fxo_proc_create(xbus_t *xbus, xpd_t *xpd)
#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);
fxo_proc_remove(xbus, xpd);
return -EINVAL;
@@ -411,7 +411,7 @@ static int fxo_proc_create(xbus_t *xbus, xpd_t *xpd)
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);
fxo_proc_remove(xbus, xpd);
return -EINVAL;
@@ -428,22 +428,22 @@ static xpd_t *FXO_card_new(xbus_t *xbus, int unit, int subunit, const xproto_tab
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;
PHONEDEV(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 @@ static int FXO_card_init(xbus_t *xbus, xpd_t *xpd)
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");
@@ -560,7 +560,7 @@ static int FXO_card_hooksig(xpd_t *xpd, int pos, enum dahdi_txsig txsig)
LINE_DBG(SIGNAL, xpd, pos, "%s\n", txsig2str(txsig));
BUG_ON(PHONEDEV(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);
@@ -582,8 +582,8 @@ static void dahdi_report_battery(xpd_t *xpd, lineno_t chan)
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;
@@ -633,13 +633,13 @@ static void handle_fxo_ring(xpd_t *xpd)
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);
}
}
@@ -650,16 +650,16 @@ static void handle_fxo_power_denial(xpd_t *xpd)
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(PHONEDEV(xpd).ringing[i] || !IS_OFFHOOK(xpd, i)) {
+ if (PHONEDEV(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
*/
@@ -667,9 +667,9 @@ static void handle_fxo_power_denial(xpd_t *xpd)
}
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.
@@ -712,17 +712,17 @@ static void check_etsi_dtmf(xpd_t *xpd)
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) || PHONEDEV(xpd).ringing[portno])
+ if (IS_OFFHOOK(xpd, portno) || PHONEDEV(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);
@@ -730,14 +730,14 @@ static void check_etsi_dtmf(xpd_t *xpd)
}
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);
@@ -756,16 +756,16 @@ static int FXO_card_tick(xbus_t *xbus, xpd_t *xpd)
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;
@@ -785,7 +785,7 @@ static int FXO_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long a
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:
@@ -834,7 +834,7 @@ HANDLER_DEF(FXO, SIG_CHANGED)
int i;
struct FXO_priv_data *priv;
- if(!xpd) {
+ if (!xpd) {
notify_bad_xpd(__func__, xbus, XPACKET_ADDR(pack), cmd->name);
return -EPROTO;
}
@@ -845,8 +845,8 @@ HANDLER_DEF(FXO, SIG_CHANGED)
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
@@ -856,7 +856,7 @@ HANDLER_DEF(FXO, SIG_CHANGED)
}
/* 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.
@@ -880,18 +880,18 @@ static void update_battery_voltage(xpd_t *xpd, byte data_low, xportno_t portno)
priv = xpd->priv;
BUG_ON(!priv);
priv->battery_voltage[portno] = volts;
- if(PHONEDEV(xpd).ringing[portno])
+ if (PHONEDEV(xpd).ringing[portno])
goto ignore_reading; /* ring voltage create false alarms */
- if(abs(volts) < battery_threshold) {
+ if (abs(volts) < battery_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 > battery_debounce) {
+ if (milliseconds > battery_debounce) {
LINE_DBG(SIGNAL, xpd, portno, "BATTERY OFF voltage=%d\n", volts);
priv->battery[portno] = BATTERY_OFF;
dahdi_report_battery(xpd, portno);
@@ -909,7 +909,7 @@ static void update_battery_voltage(xpd_t *xpd, byte data_low, xportno_t portno)
}
} 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);
@@ -919,25 +919,25 @@ static void update_battery_voltage(xpd_t *xpd, byte data_low, xportno_t portno)
/*
* 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
*/
@@ -951,12 +951,12 @@ static void update_battery_voltage(xpd_t *xpd, byte data_low, xportno_t portno)
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();
@@ -968,9 +968,9 @@ static void update_battery_voltage(xpd_t *xpd, byte data_low, xportno_t portno)
* 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);
@@ -997,23 +997,23 @@ static void update_battery_current(xpd_t *xpd, byte data_low, xportno_t portno)
* During ringing, current is not stable.
* During onhook there should not be current anyway.
*/
- if(PHONEDEV(xpd).ringing[portno] || !IS_OFFHOOK(xpd, portno))
+ if (PHONEDEV(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 */
@@ -1040,13 +1040,13 @@ static void update_metering_state(xpd_t *xpd, byte data_low, lineno_t portno)
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);
@@ -1062,7 +1062,7 @@ static int FXO_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info)
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;
@@ -1081,7 +1081,7 @@ static int FXO_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info)
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 @@ static int proc_fxo_info_read(char *page, char **start, off_t off, int count, in
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(PHONEDEV(xpd).digital_outputs, i) && !IS_SET(PHONEDEV(xpd).digital_inputs, i))
+ if (!IS_SET(PHONEDEV(xpd).digital_outputs, i) && !IS_SET(PHONEDEV(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(PHONEDEV(xpd).digital_outputs, i) && !IS_SET(PHONEDEV(xpd).digital_inputs, i))
+ if (!IS_SET(PHONEDEV(xpd).digital_outputs, i) && !IS_SET(PHONEDEV(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(PHONEDEV(xpd).digital_outputs, i) && !IS_SET(PHONEDEV(xpd).digital_inputs, i))
+ if (!IS_SET(PHONEDEV(xpd).digital_outputs, i) && !IS_SET(PHONEDEV(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 @@ static int proc_fxo_info_read(char *page, char **start, off_t off, int count, in
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 @@ static int proc_fxo_info_read(char *page, char **start, off_t off, int count, in
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 @@ static int proc_fxo_info_read(char *page, char **start, off_t off, int count, in
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 = ".";
@@ -1284,7 +1284,7 @@ static int proc_xpd_metering_read(char *page, char **start, off_t off, int count
struct FXO_priv_data *priv;
int i;
- if(!xpd)
+ if (!xpd)
return -ENODEV;
priv = xpd->priv;
BUG_ON(!priv);
@@ -1320,7 +1320,7 @@ static DEVICE_ATTR_READER(fxo_battery_show, dev, buf)
BUG_ON(!dev);
xpd = dev_to_xpd(dev);
- if(!xpd)
+ if (!xpd)
return -ENODEV;
priv = xpd->priv;
BUG_ON(!priv);
@@ -1328,9 +1328,9 @@ static DEVICE_ATTR_READER(fxo_battery_show, dev, buf)
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 = '.';
@@ -1351,14 +1351,14 @@ static int fxo_xpd_probe(struct device *dev)
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", __func__, ret);
goto fail_fxo_battery;
}
@@ -1393,11 +1393,11 @@ static int __init card_fxo_startup(void)
{
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
diff --git a/drivers/dahdi/xpp/card_fxs.c b/drivers/dahdi/xpp/card_fxs.c
index cb13821..4f322cb 100644
--- a/drivers/dahdi/xpp/card_fxs.c
+++ b/drivers/dahdi/xpp/card_fxs.c
@@ -151,8 +151,8 @@ struct FXS_priv_data {
#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 */
@@ -236,12 +236,12 @@ static int do_led(xpd_t *xpd, lineno_t chan, byte which, bool on)
xbus = xpd->xbus;
priv = xpd->priv;
which = which % NUM_LEDS;
- if(IS_SET(PHONEDEV(xpd).digital_outputs, chan) || IS_SET(PHONEDEV(xpd).digital_inputs, chan))
+ if (IS_SET(PHONEDEV(xpd).digital_outputs, chan) || IS_SET(PHONEDEV(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);
@@ -250,7 +250,7 @@ static int do_led(xpd_t *xpd, lineno_t chan, byte which, bool on)
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);
@@ -269,27 +269,27 @@ static void handle_fxs_leds(xpd_t *xpd)
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(PHONEDEV(xpd).digital_outputs | PHONEDEV(xpd).digital_inputs, i))
+ if (IS_SET(PHONEDEV(xpd).digital_outputs | PHONEDEV(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);
}
@@ -304,7 +304,7 @@ static void restore_leds(xpd_t *xpd)
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);
@@ -331,14 +331,14 @@ static void fxs_proc_remove(xbus_t *xbus, xpd_t *xpd)
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;
@@ -356,7 +356,7 @@ static int fxs_proc_create(xbus_t *xbus, xpd_t *xpd)
#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);
fxs_proc_remove(xbus, xpd);
return -EINVAL;
@@ -365,7 +365,7 @@ static int fxs_proc_create(xbus_t *xbus, xpd_t *xpd)
#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);
fxs_proc_remove(xbus, xpd);
return -EINVAL;
@@ -390,25 +390,25 @@ static xpd_t *FXS_card_new(xbus_t *xbus, int unit, int subunit, const xproto_tab
int d_inputs = 0;
int d_outputs = 0;
- 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;
/* Calculate digital inputs/outputs */
- if(unit == 0 && subtype != 4) {
+ if (unit == 0 && subtype != 4) {
channels += 6; /* 2 DIGITAL OUTPUTS, 4 DIGITAL INPUTS */
d_inputs = LINES_DIGI_INP;
d_outputs = LINES_DIGI_OUT;
}
xpd = xpd_alloc(xbus, unit, subunit, subtype, subunits, sizeof(struct FXS_priv_data), proto_table, channels);
- if(!xpd)
+ if (!xpd)
return NULL;
/* Initialize digital inputs/outputs */
if (d_inputs) {
@@ -427,7 +427,7 @@ static xpd_t *FXS_card_new(xbus_t *xbus, int unit, int subunit, const xproto_tab
XBUS_DBG(GENERAL, xbus, "No digital outputs\n");
PHONEDEV(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) {
@@ -450,7 +450,7 @@ static int FXS_card_init(xbus_t *xbus, xpd_t *xpd)
*/
/* 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);
@@ -476,7 +476,7 @@ static int FXS_card_init(xbus_t *xbus, xpd_t *xpd)
* So we do this after the LEDs
*/
for_each_line(xpd, i) {
- if(IS_SET(PHONEDEV(xpd).digital_outputs | PHONEDEV(xpd).digital_inputs, i))
+ if (IS_SET(PHONEDEV(xpd).digital_outputs | PHONEDEV(xpd).digital_inputs, i))
continue;
SLIC_DIRECT_REQUEST(xbus, xpd, i, SLIC_READ, REG_LOOPCLOSURE, 0);
}
@@ -512,10 +512,10 @@ static int FXS_card_dahdi_preregistration(xpd_t *xpd, bool on)
struct dahdi_chan *cur_chan = XPD_CHAN(xpd, i);
XPD_DBG(GENERAL, xpd, "setting FXS channel %d\n", i);
- if(IS_SET(PHONEDEV(xpd).digital_outputs, i)) {
+ if (IS_SET(PHONEDEV(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(PHONEDEV(xpd).digital_inputs, i)) {
+ } else if (IS_SET(PHONEDEV(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 {
@@ -569,7 +569,7 @@ static void __do_mute_dtmf(xpd_t *xpd, int pos, bool muteit)
priv = xpd->priv;
LINE_DBG(SIGNAL, xpd, pos, "%s\n", (muteit) ? "MUTE" : "UNMUTE");
- if(muteit)
+ if (muteit)
BIT_SET(PHONEDEV(xpd).mute_dtmf, pos);
else
BIT_CLR(PHONEDEV(xpd).mute_dtmf, pos);
@@ -672,7 +672,7 @@ static int relay_out(xpd_t *xpd, int pos, bool on)
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);
@@ -693,10 +693,10 @@ static int send_ring(xpd_t *xpd, lineno_t chan, bool on)
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;
@@ -717,9 +717,9 @@ static int FXS_card_hooksig(xpd_t *xpd, int pos, enum dahdi_txsig txsig)
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);
PHONEDEV(xpd).ringing[pos] = 0;
@@ -729,7 +729,7 @@ static int FXS_card_hooksig(xpd_t *xpd, int pos, enum dahdi_txsig txsig)
BIT_CLR(priv->want_dtmf_mute, pos);
__do_mute_dtmf(xpd, pos, 0);
spin_unlock_irqrestore(&xpd->lock, flags);
- if(IS_SET(PHONEDEV(xpd).digital_outputs, pos)) {
+ if (IS_SET(PHONEDEV(xpd).digital_outputs, pos)) {
LINE_DBG(SIGNAL, xpd, pos, "%s -> digital output OFF\n", txsig2str(txsig));
ret = relay_out(xpd, pos, 0);
return ret;
@@ -740,15 +740,15 @@ static int FXS_card_hooksig(xpd_t *xpd, int pos, enum dahdi_txsig txsig)
*/
LINE_DBG(SIGNAL, xpd, pos, "KEWL STOP\n");
linefeed_control(xpd->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(xpd->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:
@@ -762,18 +762,18 @@ static int FXS_card_hooksig(xpd_t *xpd, int pos, enum dahdi_txsig txsig)
ret = linefeed_control(xpd->xbus, xpd, pos, txhook);
break;
case DAHDI_TXSIG_OFFHOOK:
- if(IS_SET(PHONEDEV(xpd).digital_outputs, pos)) {
+ if (IS_SET(PHONEDEV(xpd).digital_outputs, pos)) {
LINE_NOTICE(xpd, pos, "%s -> Is digital output. Ignored\n", txsig2str(txsig));
return -EINVAL;
}
txhook = priv->lasttxhook[pos];
- if(PHONEDEV(xpd).ringing[pos]) {
+ if (PHONEDEV(xpd).ringing[pos]) {
oht_pcm(xpd, pos, 1);
txhook = FXS_LINE_OHTRANS;
}
PHONEDEV(xpd).ringing[pos] = 0;
- if(chan) {
- switch(chan->sig) {
+ if (chan) {
+ switch (chan->sig) {
case DAHDI_SIG_EM:
txhook = FXS_LINE_POL_ACTIVE;
break;
@@ -788,7 +788,7 @@ static int FXS_card_hooksig(xpd_t *xpd, int pos, enum dahdi_txsig txsig)
PHONEDEV(xpd).ringing[pos] = 1;
oht_pcm(xpd, pos, 0);
vmwi_search(xpd, pos, 0);
- if(IS_SET(PHONEDEV(xpd).digital_outputs, pos)) {
+ if (IS_SET(PHONEDEV(xpd).digital_outputs, pos)) {
LINE_DBG(SIGNAL, xpd, pos, "%s -> digital output ON\n", txsig2str(txsig));
ret = relay_out(xpd, pos, 1);
return ret;
@@ -796,7 +796,7 @@ static int FXS_card_hooksig(xpd_t *xpd, int pos, enum dahdi_txsig txsig)
ret = send_ring(xpd, pos, 1); // RING on
break;
case DAHDI_TXSIG_KEWL:
- if(IS_SET(PHONEDEV(xpd).digital_outputs, pos)) {
+ if (IS_SET(PHONEDEV(xpd).digital_outputs, pos)) {
LINE_DBG(SIGNAL, xpd, pos, "%s -> Is digital output. Ignored\n", txsig2str(txsig));
return -EINVAL;
}
@@ -868,7 +868,7 @@ static int FXS_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long a
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 >= PHONEDEV(xpd).channels) {
XPD_NOTICE(xpd, "Bad channel number %d in %s(), cmd=%u\n",
@@ -902,9 +902,9 @@ static int FXS_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long a
(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);
}
@@ -920,8 +920,8 @@ static int FXS_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long a
* 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");
@@ -929,7 +929,7 @@ static int FXS_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long a
}
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");
@@ -937,7 +937,7 @@ static int FXS_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long a
}
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);
@@ -983,10 +983,10 @@ static int FXS_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long a
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;
- if(!notified++)
+ if (!notified++)
LINE_NOTICE(xpd, pos,
"Got DAHDI_VMWI notification but vmwi_ioctl parameter is off. Ignoring.\n");
return 0;
@@ -1010,7 +1010,7 @@ static int FXS_card_open(xpd_t *xpd, lineno_t chan)
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");
@@ -1051,7 +1051,7 @@ static void poll_inputs(xpd_t *xpd)
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);
@@ -1099,8 +1099,8 @@ static inline bool mem_equal(const char a[], const char b[], size_t len)
{
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;
}
@@ -1132,32 +1132,32 @@ static void detect_vmwi(xpd_t *xpd)
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");
PHONEDEV(xpd).msg_waiting[i] = 1;
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");
PHONEDEV(xpd).msg_waiting[i] = 0;
start_stop_vm_led(xbus, xpd, i);
@@ -1165,7 +1165,7 @@ static void detect_vmwi(xpd_t *xpd)
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");
@@ -1183,7 +1183,7 @@ static int FXS_card_tick(xbus_t *xbus, xpd_t *xpd)
BUG_ON(!priv);
#ifdef POLL_DIGITAL_INPUTS
if (poll_digital_inputs && PHONEDEV(xpd).digital_inputs) {
- if((xpd->timer_count % poll_digital_inputs) == 0)
+ if ((xpd->timer_count % poll_digital_inputs) == 0)
poll_inputs(xpd);
}
#endif
@@ -1196,19 +1196,19 @@ static int FXS_card_tick(xbus_t *xbus, xpd_t *xpd)
* 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 (SPAN_REGISTERED(xpd)) {
if (!vmwi_ioctl && priv->search_fsk_pattern)
detect_vmwi(xpd); /* Detect via FSK modulation */
}
@@ -1234,9 +1234,9 @@ static void process_hookstate(xpd_t *xpd, xpp_line_t offhook, xpp_line_t change_
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(PHONEDEV(xpd).digital_outputs, i) || IS_SET(PHONEDEV(xpd).digital_inputs, i))
+ if (IS_SET(PHONEDEV(xpd).digital_outputs, i) || IS_SET(PHONEDEV(xpd).digital_inputs, i))
continue;
- if(IS_SET(change_mask, i)) {
+ if (IS_SET(change_mask, i)) {
PHONEDEV(xpd).ringing[i] = 0; /* No more ringing... */
#ifdef WITH_METERING
metering_gen(xpd, i, 0); /* Stop metering... */
@@ -1247,7 +1247,7 @@ static void process_hookstate(xpd_t *xpd, xpp_line_t offhook, xpp_line_t change_
*/
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);
@@ -1277,7 +1277,7 @@ HANDLER_DEF(FXS, SIG_CHANGED)
#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
@@ -1302,19 +1302,19 @@ static void process_digital_inputs(xpd_t *xpd, const reg_cmd_t *info)
return;
}
/* 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 = PHONEDEV(xpd).channels - LINES_DIGI_INP + i;
BIT_CLR(lines, channo);
BIT_SET(lines, newchanno);
PHONEDEV(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);
}
@@ -1341,24 +1341,24 @@ static void process_dtmf(xpd_t *xpd, uint portnum, byte val)
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;
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,
@@ -1373,11 +1373,11 @@ static void process_dtmf(xpd_t *xpd, uint portnum, byte val)
* 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);
@@ -1399,7 +1399,7 @@ static int FXS_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info)
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);
@@ -1412,7 +1412,7 @@ static int FXS_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info)
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;
@@ -1421,7 +1421,7 @@ static int FXS_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info)
* 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",
@@ -1436,7 +1436,7 @@ static int FXS_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info)
#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)) {
@@ -1518,7 +1518,7 @@ static int proc_fxs_info_read(char *page, char **start, off_t off, int count, in
int i;
int led;
- if(!xpd)
+ if (!xpd)
return -ENODEV;
spin_lock_irqsave(&xpd->lock, flags);
priv = xpd->priv;
@@ -1534,9 +1534,9 @@ static int proc_fxs_info_read(char *page, char **start, off_t off, int count, in
for_each_line(xpd, i) {
char pref;
- if(IS_SET(PHONEDEV(xpd).digital_outputs, i))
+ if (IS_SET(PHONEDEV(xpd).digital_outputs, i))
pref = 'O';
- else if(IS_SET(PHONEDEV(xpd).digital_inputs, i))
+ else if (IS_SET(PHONEDEV(xpd).digital_inputs, i))
pref = 'I';
else
pref = ' ';
@@ -1551,21 +1551,21 @@ static int proc_fxs_info_read(char *page, char **start, off_t off, int count, in
);
}
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(PHONEDEV(xpd).digital_outputs, i) && !IS_SET(PHONEDEV(xpd).digital_inputs, i))
+ if (!IS_SET(PHONEDEV(xpd).digital_outputs, i) && !IS_SET(PHONEDEV(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(PHONEDEV(xpd).digital_outputs, i) && !IS_SET(PHONEDEV(xpd).digital_inputs, i))
+ if (!IS_SET(PHONEDEV(xpd).digital_outputs, i) && !IS_SET(PHONEDEV(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(PHONEDEV(xpd).digital_outputs, i) && !IS_SET(PHONEDEV(xpd).digital_inputs, i))
+ if (!IS_SET(PHONEDEV(xpd).digital_outputs, i) && !IS_SET(PHONEDEV(xpd).digital_inputs, i))
len += sprintf(page + len, "%d ", LED_COUNTER(priv,i,led));
}
len += sprintf(page + len, "\n");
@@ -1592,26 +1592,26 @@ static int proc_xpd_metering_write(struct file *file, const char __user *buffer,
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;
}
@@ -1625,7 +1625,7 @@ static int fxs_xpd_probe(struct device *dev)
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;
@@ -1659,7 +1659,7 @@ static int __init card_fxs_startup(void)
{
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);
diff --git a/drivers/dahdi/xpp/card_global.c b/drivers/dahdi/xpp/card_global.c
index 51edd7d..fc5b61d 100644
--- a/drivers/dahdi/xpp/card_global.c
+++ b/drivers/dahdi/xpp/card_global.c
@@ -76,7 +76,7 @@ static int parse_hexbyte(const char *buf)
unsigned val;
val = simple_strtoul(buf, &endp, 16);
- if(*endp != '\0' || val > 0xFF)
+ if (*endp != '\0' || val > 0xFF)
return -EBADR;
return (byte)val;
}
@@ -98,7 +98,7 @@ static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[])
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",
@@ -107,24 +107,24 @@ static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[])
}
/* 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 */
@@ -139,7 +139,7 @@ static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[])
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 */
@@ -155,7 +155,7 @@ static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[])
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;
@@ -167,19 +167,19 @@ static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[])
XPD_ERR(xpd, "Unknown 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);
@@ -191,24 +191,24 @@ static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[])
}
/* 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;
}
@@ -216,13 +216,13 @@ static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[])
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;
}
@@ -230,14 +230,14 @@ static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[])
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;
}
@@ -245,7 +245,7 @@ static int execute_chip_command(xpd_t *xpd, const int argc, char *argv[])
argno++;
} else
data_high = 0;
- if(argno < argc) {
+ if (argno < argc) {
XPD_ERR(xpd,
"Command contains an extra %d argument\n",
argc - argno);
@@ -284,22 +284,22 @@ int parse_chip_command(xpd_t *xpd, char *cmdline)
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++;
@@ -307,11 +307,11 @@ int parse_chip_command(xpd_t *xpd, char *cmdline)
}
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 */
@@ -332,7 +332,7 @@ static void global_packet_dump(const char *msg, xpacket_t *pack);
xframe_t *xframe;
xpacket_t *pack;
- if(!xbus) {
+ if (!xbus) {
DBG(DEVICES, "NO XBUS\n");
return -EINVAL;
}
@@ -342,7 +342,7 @@ static void global_packet_dump(const char *msg, xpacket_t *pack);
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;
}
@@ -356,7 +356,7 @@ int xpp_register_request(xbus_t *xbus, xpd_t *xpd, xportno_t portno,
xpacket_t *pack;
reg_cmd_t *reg_cmd;
- if(!xbus) {
+ if (!xbus) {
DBG(REGS, "NO XBUS\n");
return -EINVAL;
}
@@ -368,7 +368,7 @@ int xpp_register_request(xbus_t *xbus, xpd_t *xpd, xportno_t portno,
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 {
@@ -384,14 +384,14 @@ int xpp_register_request(xbus_t *xbus, xpd_t *xpd, xportno_t portno,
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;
@@ -410,7 +410,7 @@ int xpp_register_request(xbus_t *xbus, xpd_t *xpd, xportno_t portno,
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;
}
@@ -460,25 +460,25 @@ HANDLER_DEF(GLOBAL, AB_DESCRIPTION) /* 0x08 */
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;
}
@@ -492,12 +492,12 @@ HANDLER_DEF(GLOBAL, AB_DESCRIPTION) /* 0x08 */
ret = -ENODEV;
goto out;
}
- 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 out;
@@ -541,14 +541,14 @@ HANDLER_DEF(GLOBAL, REGISTER_REPLY)
{
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(__func__, 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);
}
@@ -566,7 +566,7 @@ HANDLER_DEF(GLOBAL, SYNC_REPLY)
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;
}
@@ -586,11 +586,11 @@ HANDLER_DEF(GLOBAL, ERROR_CODE)
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 {
@@ -673,20 +673,20 @@ int run_initialize_registers(xpd_t *xpd)
BUG_ON(!xpd);
xbus = xpd->xbus;
- if(!initdir || !initdir[0]) {
+ if (!initdir || !initdir[0]) {
XPD_NOTICE(xpd, "Missing initdir parameter\n");
ret = -EINVAL;
goto err;
}
- 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);
@@ -704,13 +704,13 @@ int run_initialize_registers(xpd_t *xpd)
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;
@@ -722,15 +722,15 @@ int run_initialize_registers(xpd_t *xpd)
/*
* 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);
diff --git a/drivers/dahdi/xpp/card_pri.c b/drivers/dahdi/xpp/card_pri.c
index 286c348..e2d6f72 100644
--- a/drivers/dahdi/xpp/card_pri.c
+++ b/drivers/dahdi/xpp/card_pri.c
@@ -57,11 +57,11 @@ static DEF_PARM(uint, poll_interval, 500, 0644, "Poll channel state interval in
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;
}
@@ -331,7 +331,7 @@ struct PRI_priv_data {
#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_E];
byte cas_ts_e[NUM_CAS_RS_E];
@@ -503,7 +503,7 @@ static bool valid_pri_modes(const xpd_t *xpd)
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)
@@ -529,8 +529,8 @@ static void PRI_card_pcm_recompute(xpd_t *xpd,
for_each_line(xpd, i)
if (IS_SET(pcm_mask, i))
line_count++;
- 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 */
line_count--;
pcm_mask &= ~BIT(PRI_DCHAN_IDX(priv));
@@ -574,8 +574,8 @@ static int set_pri_proto(xpd_t *xpd, enum pri_protocol set_proto)
__func__, phonedev->span.name, phonedev->span.spanno);
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 {
@@ -584,7 +584,7 @@ static int set_pri_proto(xpd_t *xpd, enum pri_protocol set_proto)
pri_protocol_name(set_proto));
}
}
- switch(set_proto) {
+ switch (set_proto) {
case PRI_PROTO_E1:
deflaw = DAHDI_LAW_ALAW;
dchan_num = 16;
@@ -629,7 +629,7 @@ static int set_pri_proto(xpd_t *xpd, enum pri_protocol set_proto)
* 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;
}
@@ -643,24 +643,24 @@ static void dahdi_update_syncsrc(xpd_t *xpd)
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 = PHONEDEV(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(PHONEDEV(subxpd).span.syncsrc == best_spanno)
+ if (PHONEDEV(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);
@@ -685,27 +685,27 @@ static void set_clocking(xpd_t *xpd)
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(PHONEDEV(subxpd).timing_priority > 0 && PHONEDEV(subxpd).timing_priority < best_subunit_prio) {
+ if (PHONEDEV(subxpd).timing_priority > 0 && PHONEDEV(subxpd).timing_priority < best_subunit_prio) {
best_xpd = subxpd;
best_subunit = i;
best_subunit_prio = PHONEDEV(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;
@@ -716,12 +716,12 @@ static void set_clocking(xpd_t *xpd)
((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;
@@ -743,7 +743,7 @@ static void set_reg_lim0(const char *msg, xpd_t *xpd)
is_master_mode = PHONEDEV(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;
@@ -775,7 +775,7 @@ static int set_localloop(xpd_t *xpd, bool localloop)
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",
PHONEDEV(xpd).span.spanno, __func__);
return -EBUSY;
@@ -822,7 +822,7 @@ static void set_rbslines(xpd_t *xpd, int channo)
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);
@@ -831,7 +831,7 @@ static void set_rbslines(xpd_t *xpd, int channo)
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;
@@ -839,13 +839,13 @@ static void set_rbslines(xpd_t *xpd, int channo)
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),
@@ -866,7 +866,7 @@ static int set_mode_cas(xpd_t *xpd, bool want_cas)
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 {
@@ -902,11 +902,11 @@ static int pri_lineconfig(xpd_t *xpd, int lineconfig)
*/
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,
@@ -919,26 +919,26 @@ static int pri_lineconfig(xpd_t *xpd, int lineconfig)
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",
__func__, 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;
@@ -946,7 +946,7 @@ static int pri_lineconfig(xpd_t *xpd, int lineconfig)
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) {
@@ -967,7 +967,7 @@ static int pri_lineconfig(xpd_t *xpd, int lineconfig)
* 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;
@@ -1021,20 +1021,20 @@ static int pri_lineconfig(xpd_t *xpd, int lineconfig)
write_subunit(xpd, REG_FMR0, fmr0);
XPD_DBG(GENERAL, xpd, "%s: fmr4(0x%02X) = 0x%02X\n", __func__, REG_FMR4, fmr4);
write_subunit(xpd, REG_FMR4, fmr4);
- if(fmr3) {
+ if (fmr3) {
XPD_DBG(GENERAL, xpd, "%s: fmr3(0x%02X) = 0x%02X\n", __func__, REG_FMR3, fmr3);
write_subunit(xpd, REG_FMR3, fmr3);
}
XPD_DBG(GENERAL, xpd, "%s: cmdr(0x%02X) = 0x%02X\n", __func__, 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", __func__, REG_RC0, rc0);
write_subunit(xpd, REG_RC0, rc0);
}
#endif
- if(force_cas) {
- if(priv->pri_protocol == PRI_PROTO_E1) {
+ if (force_cas) {
+ if (priv->pri_protocol == PRI_PROTO_E1) {
int rs1 = 0x0B;
/*
@@ -1080,7 +1080,7 @@ static int pri_spanconfig(struct file *file, struct dahdi_span *span,
BUG_ON(!xpd);
priv = xpd->priv;
- if(lc->span != PHONEDEV(xpd).span.spanno) {
+ if (lc->span != PHONEDEV(xpd).span.spanno) {
XPD_ERR(xpd, "I am span %d but got spanconfig for span %d\n",
PHONEDEV(xpd).span.spanno, lc->span);
return -EINVAL;
@@ -1092,7 +1092,7 @@ static int pri_spanconfig(struct file *file, struct dahdi_span *span,
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;
PHONEDEV(xpd).timing_priority = lc->sync;
set_master_mode("spanconfig", xpd);
@@ -1121,7 +1121,7 @@ static int pri_chanconfig(struct file *file, struct dahdi_chan *chan,
* FIXME: actually use this to prevent duplicate DChan definitions
* and prevent DChan definitions with CAS.
*/
- if(is_sigtype_dchan(sigtype)) {
+ 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));
@@ -1130,19 +1130,19 @@ static int pri_chanconfig(struct file *file, struct dahdi_chan *chan,
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(PHONEDEV(xpd).span.flags & DAHDI_FLAG_RUNNING) {
+ if (PHONEDEV(xpd).span.flags & DAHDI_FLAG_RUNNING) {
XPD_DBG(DEVICES, xpd, "Span is RUNNING. Updating rbslines.\n");
set_rbslines(xpd, chan->channo);
}
@@ -1159,13 +1159,13 @@ static xpd_t *PRI_card_new(xbus_t *xbus, int unit, int subunit, const xproto_tab
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() */
@@ -1184,13 +1184,13 @@ static int PRI_card_init(xbus_t *xbus, xpd_t *xpd)
XPD_DBG(GENERAL, xpd, "\n");
xpd->type = XPD_TYPE_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);
@@ -1198,7 +1198,7 @@ static int PRI_card_init(xbus_t *xbus, xpd_t *xpd)
* 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;
}
@@ -1207,7 +1207,7 @@ static int PRI_card_init(xbus_t *xbus, xpd_t *xpd)
XPD_DBG(DEVICES, xpd, "%s\n", xpd->type_name);
PHONEDEV(xpd).timing_priority = 1; /* High priority SLAVE */
set_master_mode(__func__, 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);
@@ -1292,7 +1292,7 @@ static int apply_pri_protocol(xpd_t *xpd)
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;
}
@@ -1318,7 +1318,7 @@ static int PRI_card_dahdi_preregistration(xpd_t *xpd, bool on)
pri_protocol_name(priv->pri_protocol),
PHONEDEV(xpd).channels,
priv->deflaw);
- if(!on) {
+ if (!on) {
/* Nothing to do yet */
return 0;
}
@@ -1344,20 +1344,20 @@ static void dchan_state(xpd_t *xpd, bool up)
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 < PHONEDEV(xpd).channels) {
+ if (SPAN_REGISTERED(xpd) && d >= 0 && d < PHONEDEV(xpd).channels) {
byte *pcm;
pcm = (byte *)XPD_CHAN(xpd, d)->readchunk;
@@ -1391,7 +1391,7 @@ static void handle_leds(xbus_t *xbus, xpd_t *xpd)
BUG_ON(!xpd);
priv = xpd->priv;
BUG_ON(!priv);
- if(PHONEDEV(xpd).timing_priority == 0) {
+ if (PHONEDEV(xpd).timing_priority == 0) {
which_led = TOP_RED_LED;
other_led = BOTTOM_GREEN_LED;
} else {
@@ -1400,10 +1400,10 @@ static void handle_leds(xbus_t *xbus, xpd_t *xpd)
}
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 {
@@ -1413,11 +1413,11 @@ static void handle_leds(xbus_t *xbus, xpd_t *xpd)
}
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;
@@ -1425,9 +1425,9 @@ static void handle_leds(xbus_t *xbus, xpd_t *xpd)
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);
@@ -1438,7 +1438,7 @@ static void handle_leds(xbus_t *xbus, xpd_t *xpd)
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);
}
}
@@ -1450,18 +1450,18 @@ static int PRI_card_tick(xbus_t *xbus, xpd_t *xpd)
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++;
}
@@ -1474,7 +1474,7 @@ static int PRI_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long a
struct dahdi_chan *chan;
BUG_ON(!xpd);
- if(!XBUS_IS(xpd->xbus, READY))
+ if (!XBUS_IS(xpd->xbus, READY))
return -ENODEV;
chan = XPD_CHAN(xpd, pos);
switch (cmd) {
@@ -1529,7 +1529,7 @@ static int pri_startup(struct file *file, struct dahdi_span *span)
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;
}
@@ -1553,7 +1553,7 @@ static int pri_shutdown(struct dahdi_span *span)
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;
}
@@ -1573,13 +1573,13 @@ static int encode_rbsbits_e1(xpd_t *xpd, int pos, int bits)
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", __func__, pos);
return 0;
}
- if(pos >= 16) {
+ if (pos >= 16) {
/* Low nibble */
rsnum = pos - 16;
val = (priv->cas_ts_e[rsnum] & 0xF0) | (bits & 0x0F);
@@ -1608,7 +1608,7 @@ static int encode_rbsbits_t1(xpd_t *xpd, int pos, int bits)
priv = xpd->priv;
BUG_ON(!priv);
BUG_ON(priv->pri_protocol != PRI_PROTO_T1);
- if(pos < 0 || pos >= PHONEDEV(xpd).channels) {
+ if (pos < 0 || pos >= PHONEDEV(xpd).channels) {
XPD_ERR(xpd, "%s: Bad pos=%d\n", __func__, pos);
return 0;
}
@@ -1680,7 +1680,7 @@ static int pri_rbsbits(struct dahdi_chan *chan, int bits)
pos = chan->chanpos - 1;
priv = xpd->priv;
BUG_ON(!priv);
- if(!priv->is_cas) {
+ if (!priv->is_cas) {
XPD_DBG(SIGNAL, xpd, "RBS: TX: not in CAS mode. Ignore.\n");
return 0;
}
@@ -1690,14 +1690,14 @@ static int pri_rbsbits(struct dahdi_chan *chan, int bits)
sig2str(chan->sig), bits);
return 0;
}
- if(!priv->layer1_up) {
+ if (!priv->layer1_up) {
XPD_DBG(SIGNAL, xpd, "RBS: TX: No layer1 yet. Keep going.\n");
}
- 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",
@@ -1739,33 +1739,33 @@ static void PRI_card_pcm_fromspan(xpd_t *xpd, xpacket_t *pack)
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 */
@@ -1800,7 +1800,7 @@ static void PRI_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack)
int i;
int logical_chan;
- if(!SPAN_REGISTERED(xpd))
+ if (!SPAN_REGISTERED(xpd))
return;
priv = xpd->priv;
BUG_ON(!priv);
@@ -1811,28 +1811,28 @@ static void PRI_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack)
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);
@@ -1926,11 +1926,11 @@ static void layer1_state(xpd_t *xpd, byte data_low)
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 == DAHDI_ALARM_NONE;
@@ -1940,11 +1940,11 @@ static void layer1_state(xpd_t *xpd, byte data_low)
* 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 regbase = cas_regbase(xpd);
@@ -1956,7 +1956,7 @@ static void layer1_state(xpd_t *xpd, byte data_low)
query_subunit(xpd, regbase + i);
}
- if(SPAN_REGISTERED(xpd) && PHONEDEV(xpd).span.alarms != alarms) {
+ if (SPAN_REGISTERED(xpd) && PHONEDEV(xpd).span.alarms != alarms) {
char str1[MAX_PROC_WRITE];
char str2[MAX_PROC_WRITE];
@@ -1995,18 +1995,18 @@ static int decode_cas_e1(xpd_t *xpd, byte regnum, byte data_low)
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 >= NUM_CAS_RS_E) {
+ if (pos >= NUM_CAS_RS_E) {
XPD_ERR(xpd, "%s: got bad pos=%d [0-%d]\n", __func__, pos, NUM_CAS_RS_E);
return -EINVAL;
}
- if(chan1 < 0 || chan1 > PHONEDEV(xpd).channels) {
+ if (chan1 < 0 || chan1 > PHONEDEV(xpd).channels) {
XPD_NOTICE(xpd, "%s: %s CAS: Bad chan1 number (%d)\n",
__func__,
pri_protocol_name(priv->pri_protocol),
chan1);
return -EINVAL;
}
- if(chan2 < 0 || chan2 > PHONEDEV(xpd).channels) {
+ if (chan2 < 0 || chan2 > PHONEDEV(xpd).channels) {
XPD_NOTICE(xpd, "%s: %s CAS: Bad chan2 number (%d)\n",
__func__,
pri_protocol_name(priv->pri_protocol),
@@ -2015,7 +2015,7 @@ static int decode_cas_e1(xpd_t *xpd, byte regnum, byte data_low)
}
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 (SPAN_REGISTERED(xpd)) {
dahdi_rbsbits(XPD_CHAN(xpd, chan1), val1);
dahdi_rbsbits(XPD_CHAN(xpd, chan2), val2);
}
@@ -2036,11 +2036,11 @@ static int decode_cas_t1(xpd_t *xpd, byte regnum, byte data_low)
BUG_ON(!priv->is_cas);
BUG_ON(priv->pri_protocol != PRI_PROTO_T1);
rsnum = regnum - REG_RS1_E;
- if(rsnum >= 12) {
+ if (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;
@@ -2049,7 +2049,7 @@ static int decode_cas_t1(xpd_t *xpd, byte regnum, byte data_low)
(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;
@@ -2057,16 +2057,16 @@ static int decode_cas_t1(xpd_t *xpd, byte regnum, byte data_low)
if (!priv->is_esf)
rxsig <<= 2;
pos = rsnum * chan_per_reg + chan_per_reg - i - 1;
- if(pos < 0 || pos >= PHONEDEV(xpd).channels) {
+ if (pos < 0 || pos >= PHONEDEV(xpd).channels) {
XPD_ERR(xpd, "%s: Bad pos=%d\n", __func__, pos);
continue;
}
chan = XPD_CHAN(xpd, pos);
- if(!chan) {
+ if (!chan) {
XPD_ERR(xpd, "%s: Null channel in pos=%d\n", __func__, 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);
}
@@ -2080,30 +2080,30 @@ static void process_cas_dchan(xpd_t *xpd, byte regnum, byte data_low)
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_RS1_E)
+ if (priv->pri_protocol == PRI_PROTO_E1) {
+ if (regnum == REG_RS1_E)
return; /* Time slot 0: Ignored for E1 */
- if(regnum < REG_RS2_E) {
+ if (regnum < REG_RS2_E) {
/* Should not happen, but harmless. Ignore */
if (regnum == REG_RS1_E)
return;
@@ -2113,16 +2113,16 @@ static void process_cas_dchan(xpd_t *xpd, byte regnum, byte data_low)
__func__, 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",
__func__, 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",
@@ -2147,32 +2147,32 @@ static int PRI_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info)
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(__func__, 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)) {
@@ -2251,7 +2251,7 @@ static DEVICE_ATTR_READER(pri_protocol_show, dev, buf)
BUG_ON(!dev);
xpd = dev_to_xpd(dev);
- if(!xpd)
+ if (!xpd)
return -ENODEV;
priv = xpd->priv;
BUG_ON(!priv);
@@ -2308,7 +2308,7 @@ static DEVICE_ATTR_READER(pri_localloop_show, dev, buf)
BUG_ON(!dev);
xpd = dev_to_xpd(dev);
- if(!xpd)
+ if (!xpd)
return -ENODEV;
priv = xpd->priv;
BUG_ON(!priv);
@@ -2329,17 +2329,17 @@ static DEVICE_ATTR_WRITER(pri_localloop_store, dev, buf, count)
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,
@@ -2362,12 +2362,12 @@ static DEVICE_ATTR_READER(pri_layer1_show, dev, buf)
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"));
@@ -2395,18 +2395,18 @@ static DEVICE_ATTR_READER(pri_alarms_show, dev, buf)
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);
}
}
@@ -2426,23 +2426,23 @@ static DEVICE_ATTR_READER(pri_cas_show, dev, buf)
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_E; i++) {
+ for (i = 0; i < NUM_CAS_RS_E; 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_E; i++) {
+ for (i = 0; i < NUM_CAS_RS_E; i++) {
len += sprintf(buf + len, " %02X", priv->cas_rs_e[i]);
}
len += sprintf(buf + len, "\n");
@@ -2462,7 +2462,7 @@ static DEVICE_ATTR_READER(pri_dchan_show, dev, buf)
BUG_ON(!dev);
xpd = dev_to_xpd(dev);
- if(!xpd)
+ if (!xpd)
return -ENODEV;
priv = xpd->priv;
BUG_ON(!priv);
@@ -2470,7 +2470,7 @@ static DEVICE_ATTR_READER(pri_dchan_show, dev, buf)
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 {
@@ -2491,7 +2491,7 @@ static DEVICE_ATTR_READER(pri_clocking_show, dev, buf)
BUG_ON(!dev);
xpd = dev_to_xpd(dev);
- if(!xpd)
+ if (!xpd)
return -ENODEV;
priv = xpd->priv;
BUG_ON(!priv);
@@ -2510,44 +2510,44 @@ static int pri_xpd_probe(struct device *dev)
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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, ret);
goto fail_pri_clocking;
}
@@ -2600,7 +2600,7 @@ static int __init card_pri_startup(void)
{
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);
#ifdef DAHDI_AUDIO_NOTIFY
diff --git a/drivers/dahdi/xpp/dahdi_debug.c b/drivers/dahdi/xpp/dahdi_debug.c
index 0e0261d..dea17e1 100644
--- a/drivers/dahdi/xpp/dahdi_debug.c
+++ b/drivers/dahdi/xpp/dahdi_debug.c
@@ -58,8 +58,8 @@ void dump_poll(int debug, const char *msg, int poll)
{
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 @@ void alarm2str(int alarm, char *buf, int buflen)
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';
}
diff --git a/drivers/dahdi/xpp/dahdi_debug.h b/drivers/dahdi/xpp/dahdi_debug.h
index ce6ed1b..b93b28d 100644
--- a/drivers/dahdi/xpp/dahdi_debug.h
+++ b/drivers/dahdi/xpp/dahdi_debug.h
@@ -94,7 +94,7 @@ void dump_poll(int debug, const char *msg, int poll);
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 *rxsig2str(enum dahdi_rxsig sig)
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 *txsig2str(enum dahdi_txsig sig)
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 *event2str(int event)
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 *sig2str(int sig)
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";
diff --git a/drivers/dahdi/xpp/mmapdrv.c b/drivers/dahdi/xpp/mmapdrv.c
index 0635903..bd6ec88 100644
--- a/drivers/dahdi/xpp/mmapdrv.c
+++ b/drivers/dahdi/xpp/mmapdrv.c
@@ -115,7 +115,7 @@ static irqreturn_t xpp_mmap_rx_irq(int irq, void *dev_id)
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 @@ static irqreturn_t xpp_mmap_rx_irq(int irq, void *dev_id)
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 @@ static int __init xpp_mmap_init(void)
NULL,
#endif
NULL);
- if(!xframe_cache) {
+ if (!xframe_cache) {
ret = -ENOMEM;
goto fail_cache;
}
diff --git a/drivers/dahdi/xpp/parport_debug.c b/drivers/dahdi/xpp/parport_debug.c
index 950e45d..4b9f83f 100644
--- a/drivers/dahdi/xpp/parport_debug.c
+++ b/drivers/dahdi/xpp/parport_debug.c
@@ -41,8 +41,8 @@ void flip_parport_bit(unsigned char bitnum)
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 @@ void flip_parport_bit(unsigned char bitnum)
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 @@ EXPORT_SYMBOL(flip_parport_bit);
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_attach(struct parport *port)
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;
diff --git a/drivers/dahdi/xpp/xbus-core.c b/drivers/dahdi/xpp/xbus-core.c
index d4db723..9eb2eec 100644
--- a/drivers/dahdi/xpp/xbus-core.c
+++ b/drivers/dahdi/xpp/xbus-core.c
@@ -118,7 +118,7 @@ int xbus_check_unique(xbus_t *xbus)
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";
@@ -144,7 +144,7 @@ xbus_t *xbus_num(uint num)
{
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;
@@ -154,7 +154,7 @@ static void initialize_xbuses_array(void)
{
int i;
- for(i = 0; i < ARRAY_SIZE(xbuses_array); i++)
+ for (i = 0; i < ARRAY_SIZE(xbuses_array); i++)
init_xbus(i, NULL);
}
@@ -162,8 +162,8 @@ static void finalize_xbuses_array(void)
{
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", __func__, i);
BUG();
}
@@ -256,7 +256,7 @@ static void do_hexdump(const char msg[], byte *data, uint16_t len)
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]);
}
@@ -270,23 +270,23 @@ void dump_xframe(const char msg[], const xbus_t *xbus, const xframe_t *xframe, i
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",
__func__, 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);
@@ -294,8 +294,8 @@ void dump_xframe(const char msg[], const xbus_t *xbus, const xframe_t *xframe, i
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);
@@ -303,8 +303,8 @@ void dump_xframe(const char msg[], const xbus_t *xbus, const xframe_t *xframe, i
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);
@@ -312,19 +312,19 @@ void dump_xframe(const char msg[], const xbus_t *xbus, const xframe_t *xframe, i
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))
@@ -341,9 +341,9 @@ void dump_xframe(const char msg[], const xbus_t *xbus, const xframe_t *xframe, i
}
num++;
pos = nextpos;
- if(pos >= frm_len)
+ if (pos >= frm_len)
break;
- } while(1);
+ } while (1);
spin_unlock_irqrestore(&serialize_dump_xframe, flags);
}
@@ -359,7 +359,7 @@ int send_pcm_frame(xbus_t *xbus, xframe_t *xframe)
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;
@@ -368,7 +368,7 @@ int send_pcm_frame(xbus_t *xbus, xframe_t *xframe)
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;
@@ -385,7 +385,7 @@ static int really_send_cmd_frame(xbus_t *xbus, xframe_t *xframe)
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);
@@ -393,11 +393,11 @@ static int really_send_cmd_frame(xbus_t *xbus, xframe_t *xframe)
}
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);
}
@@ -412,25 +412,25 @@ int xbus_command_queue_tick(xbus_t *xbus)
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;
}
@@ -441,7 +441,7 @@ static void xbus_command_queue_clean(xbus_t *xbus)
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);
}
}
@@ -453,7 +453,7 @@ static int xbus_command_queue_waitempty(xbus_t *xbus)
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;
@@ -466,15 +466,15 @@ int send_cmd_frame(xbus_t *xbus, xframe_t *xframe)
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(__func__, 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);
@@ -498,10 +498,10 @@ static void xframe_enqueue_recv(xbus_t *xbus, xframe_t *xframe)
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;
@@ -520,7 +520,7 @@ static void receive_tasklet_func(unsigned long data)
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);
}
}
@@ -528,10 +528,10 @@ static void receive_tasklet_func(unsigned long data)
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 */
@@ -541,14 +541,14 @@ void xbus_receive_xframe(xbus_t *xbus, xframe_t *xframe)
/*------------------------- 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)];
}
@@ -562,11 +562,11 @@ int xbus_xpd_bind(xbus_t *xbus, xpd_t *xpd, int unit, int subunit)
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",
@@ -581,7 +581,7 @@ int xbus_xpd_bind(xbus_t *xbus, xpd_t *xpd, int unit, int subunit)
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", __func__);
/* FIXME: What to do? */
}
@@ -594,15 +594,15 @@ int xbus_xpd_unbind(xbus_t *xbus, xpd_t *xpd)
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", __func__, 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", __func__, 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",
@@ -612,7 +612,7 @@ int xbus_xpd_unbind(xbus_t *xbus, xpd_t *xpd)
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;
@@ -635,7 +635,7 @@ static int new_card(xbus_t *xbus,
const struct echoops *echoops;
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);
@@ -671,13 +671,13 @@ static int new_card(xbus_t *xbus,
if (type == XPD_TYPE_FXO)
xbus->quirks.has_fxo = 1;
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,
@@ -687,7 +687,7 @@ static int new_card(xbus_t *xbus,
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,
@@ -702,7 +702,7 @@ static int new_card(xbus_t *xbus,
type,
subtype, subunit_ports);
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;
@@ -719,10 +719,10 @@ static void xbus_release_xpds(xbus_t *xbus)
int i;
XBUS_DBG(DEVICES, 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(__func__, xpd);
}
}
@@ -761,7 +761,7 @@ static int xpd_initialize(xpd_t *xpd)
{
int ret = -ENODEV;
- if(CALL_XMETHOD(card_init, xpd) < 0) {
+ if (CALL_XMETHOD(card_init, xpd) < 0) {
XPD_ERR(xpd, "Card Initialization failed\n");
goto out;
}
@@ -774,7 +774,7 @@ static int xpd_initialize(xpd_t *xpd)
CALL_PHONE_METHOD(echocancel_setmask, xpd, 0);
CALL_PHONE_METHOD(card_state, 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);
@@ -849,9 +849,9 @@ static int xbus_initialize(xbus_t *xbus)
refcount_xbus(xbus));
if (xbus_aquire_xpds(xbus) < 0) /* Until end of initialization */
return -EBUSY;
- 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 (!XBUS_IS(xbus, RECVD_DESC)) {
XBUS_NOTICE(xbus,
@@ -860,15 +860,15 @@ static int xbus_initialize(xbus_t *xbus)
xbus_statename(XBUS_STATE(xbus)));
goto err;
}
- 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;
if (!XBUS_IS(xbus, RECVD_DESC)) {
XBUS_ERR(xbus,
@@ -877,7 +877,7 @@ static int xbus_initialize(xbus_t *xbus)
goto err;
}
ret = xpd_initialize(xpd);
- if(ret < 0)
+ if (ret < 0)
goto err;
}
}
@@ -994,7 +994,7 @@ void xbus_unregister_dahdi_device(xbus_t *xbus)
int i;
XBUS_NOTICE(xbus, "%s\n", __func__);
- for(i = 0; i < MAX_XPDS; i++) {
+ for (i = 0; i < MAX_XPDS; i++) {
xpd_t *xpd = xpd_of(xbus, i);
xpd_dahdi_preunregister(xpd);
}
@@ -1003,7 +1003,7 @@ void xbus_unregister_dahdi_device(xbus_t *xbus)
XBUS_NOTICE(xbus, "%s: finished dahdi_unregister_device()\n", __func__);
xbus_free_ddev(xbus);
}
- for(i = 0; i < MAX_XPDS; i++) {
+ for (i = 0; i < MAX_XPDS; i++) {
xpd_t *xpd = xpd_of(xbus, i);
xpd_dahdi_postunregister(xpd);
}
@@ -1050,16 +1050,16 @@ void xbus_populate(void *data)
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;
@@ -1090,7 +1090,7 @@ int xbus_process_worker(xbus_t *xbus)
{
struct xbus_workqueue *worker;
- if(!xbus) {
+ if (!xbus) {
ERR("%s: xbus gone -- skip initialization\n", __func__);
return 0;
}
@@ -1108,7 +1108,7 @@ int xbus_process_worker(xbus_t *xbus)
#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(&worker->running_initialization);
return 0;
@@ -1128,7 +1128,7 @@ static void worker_reset(xbus_t *xbus)
worker = &xbus->worker;
name = (xbus) ? xbus->busname : "detached";
DBG(DEVICES, "%s\n", name);
- if(!worker->xpds_init_done) {
+ if (!worker->xpds_init_done) {
NOTICE("%s: worker(%s)->xpds_init_done=%d\n",
__func__, name, worker->xpds_init_done);
}
@@ -1200,7 +1200,7 @@ static int worker_run(xbus_t *xbus)
XBUS_DBG(DEVICES, xbus, "\n");
/* poll related variables */
worker->wq = create_singlethread_workqueue(xbus->busname);
- if(!worker->wq) {
+ if (!worker->wq) {
XBUS_ERR(xbus, "Failed to create worker workqueue.\n");
goto err;
}
@@ -1218,7 +1218,7 @@ bool xbus_setflags(xbus_t *xbus, int flagbit, bool on)
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));
@@ -1233,48 +1233,48 @@ bool xbus_setstate(xbus_t *xbus, enum xbus_state newstate)
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:
@@ -1285,16 +1285,16 @@ bool xbus_setstate(xbus_t *xbus, enum xbus_state newstate)
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:
@@ -1341,7 +1341,7 @@ void xbus_deactivate(xbus_t *xbus)
{
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 */
elect_syncer("deactivate");
@@ -1386,15 +1386,15 @@ static xbus_t *xbus_alloc(void)
int i;
xbus = KZALLOC(sizeof(xbus_t), GFP_KERNEL);
- if(!xbus) {
+ if (!xbus) {
ERR("%s: out of memory\n", __func__);
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", __func__, i);
KZFREE(xbus);
xbus = NULL;
@@ -1414,7 +1414,7 @@ void xbus_free(xbus_t *xbus)
unsigned long flags;
uint num;
- if(!xbus)
+ if (!xbus)
return;
XBUS_DBG(DEVICES, xbus, "Free\n");
spin_lock_irqsave(&xbuses_lock, flags);
@@ -1423,14 +1423,14 @@ void xbus_free(xbus_t *xbus)
BUG_ON(xbus != xbuses_array[num].xbus);
spin_unlock_irqrestore(&xbuses_lock, flags);
#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;
@@ -1455,7 +1455,7 @@ xbus_t *xbus_new(struct xbus_ops *ops, ushort max_send_size, struct device *tran
BUG_ON(!ops);
xbus = xbus_alloc();
- if(!xbus) {
+ if (!xbus) {
ERR("%s: Failed allocating new xbus\n", __func__);
return NULL;
}
@@ -1475,7 +1475,7 @@ xbus_t *xbus_new(struct xbus_ops *ops, ushort max_send_size, struct device *tran
xbus->sync_mode = SYNC_MODE_NONE;
xbus->sync_mode_default = SYNC_MODE_PLL;
err = xbus_sysfs_create(xbus);
- if(err) {
+ if (err) {
XBUS_ERR(xbus, "SYSFS creation failed: %d\n", err);
goto nobus;
}
@@ -1489,7 +1489,7 @@ xbus_t *xbus_new(struct xbus_ops *ops, ushort max_send_size, struct device *tran
#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;
@@ -1543,7 +1543,7 @@ void xbus_reset_counters(xbus_t *xbus)
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;
}
}
@@ -1650,7 +1650,7 @@ static int xbus_read_proc(char *page, char **start, off_t off, int count, int *e
int i = (int)((unsigned long)data);
xbus = get_xbus(__func__, i); /* until end of xbus_read_proc */
- if(!xbus)
+ if (!xbus)
goto out;
spin_lock_irqsave(&xbus->lock, flags);
@@ -1665,7 +1665,7 @@ static int xbus_read_proc(char *page, char **start, off_t off, int count, int *e
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]);
@@ -1694,7 +1694,7 @@ static int xbus_read_proc(char *page, char **start, off_t off, int count, int *e
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]);
}
@@ -1727,15 +1727,15 @@ static int proc_xbus_command_write(struct file *file, const char __user *buffer,
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", __func__, 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;
}
@@ -1747,15 +1747,15 @@ static int proc_xbus_command_write(struct file *file, const char __user *buffer,
* 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",
__func__, *p, (long)(p - buf));
count = -EINVAL;
@@ -1764,9 +1764,9 @@ static int proc_xbus_command_write(struct file *file, const char __user *buffer,
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",
__func__, hexdigit, (long)(p - buf));
count = -EINVAL;
@@ -1777,11 +1777,11 @@ static int proc_xbus_command_write(struct file *file, const char __user *buffer,
}
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? */
@@ -1799,10 +1799,10 @@ static int read_proc_xbuses(char *page, char **start, off_t off, int count, int
int len = 0;
int i;
- for(i = 0; i < MAX_BUSES; i++) {
+ for (i = 0; i < MAX_BUSES; i++) {
xbus_t *xbus = get_xbus(__func__, i);
- if(xbus) {
+ if (xbus) {
len += sprintf(page + len, "%s: CONNECTOR=%s LABEL=[%s] STATUS=%s\n",
xbus->busname,
xbus->connector,
@@ -1857,7 +1857,7 @@ static void transport_destroy(xbus_t *xbus)
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;
@@ -1870,7 +1870,7 @@ struct xbus_ops *transportops_get(xbus_t *xbus)
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;
@@ -1883,7 +1883,7 @@ void transportops_put(xbus_t *xbus)
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);
}
@@ -1892,7 +1892,7 @@ static void xbus_core_cleanup(void)
{
finalize_xbuses_array();
#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;
@@ -1917,7 +1917,7 @@ int __init xbus_core_init(void)
}
SET_PROC_DIRENTRY_OWNER(proc_xbuses);
#endif
- if((ret = xpp_driver_init()) < 0)
+ if ((ret = xpp_driver_init()) < 0)
goto err;
return 0;
err:
diff --git a/drivers/dahdi/xpp/xbus-pcm.c b/drivers/dahdi/xpp/xbus-pcm.c
index 44168b9..d48ae56 100644
--- a/drivers/dahdi/xpp/xbus-pcm.c
+++ b/drivers/dahdi/xpp/xbus-pcm.c
@@ -92,9 +92,9 @@ static void ticker_set_cycle(struct xpp_ticker *ticker, int cycle)
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);
@@ -117,7 +117,7 @@ static int xpp_ticker_step(struct xpp_ticker *ticker, const struct timeval *t)
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);
@@ -156,9 +156,9 @@ void xpp_drift_init(xbus_t *xbus)
#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;
@@ -194,13 +194,13 @@ static void xpp_drift_step(xbus_t *xbus, const struct timeval *tv)
* Do we need to be synchronized and is there an established reference
* ticker (another Astribank or another DAHDI device) already?
*/
- 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 - di->delta_tick;
long usec_delta;
di->delta_tick = new_delta_tick;
- if(lost_ticks) {
+ if (lost_ticks) {
static int rate_limit;
/*
@@ -209,7 +209,7 @@ static void xpp_drift_step(xbus_t *xbus, const struct timeval *tv)
*/
di->lost_ticks++;
di->lost_tick_count += abs(lost_ticks);
- if((rate_limit++ % 1003) == 0) {
+ if ((rate_limit++ % 1003) == 0) {
/* FIXME: This should be a NOTICE.
* However we have several false ones at
* startup.
@@ -218,7 +218,7 @@ static void xpp_drift_step(xbus_t *xbus, const struct timeval *tv)
lost_ticks,
(abs(lost_ticks) > 1) ? "s": "");
}
- if(abs(lost_ticks) > 100) {
+ if (abs(lost_ticks) > 100) {
xbus_drift_clear(xbus);
ticker->count = ref_ticker->count;
}
@@ -231,7 +231,7 @@ static void xpp_drift_step(xbus_t *xbus, const struct timeval *tv)
if ((ticker->count % SYNC_CYCLE) > (SYNC_CYCLE - SYNC_CYCLE_SAMPLE))
di->delta_sum += usec_delta;
- if((ticker->count % SYNC_CYCLE) == 0) {
+ if ((ticker->count % SYNC_CYCLE) == 0) {
/*
* Full sampling cycle passed. Let's calculate
*/
@@ -263,9 +263,9 @@ static void xpp_drift_step(xbus_t *xbus, const struct timeval *tv)
di->min_speed = speed;
if (speed > di->max_speed)
di->max_speed = speed;
- if(offset > di->offset_max)
+ if (offset > di->offset_max)
di->offset_max = offset;
- if(offset < di->offset_min)
+ if (offset < di->offset_min)
di->offset_min = offset;
XBUS_DBG(SYNC, xbus, "offset: %d, min_speed=%d, max_speed=%d, usec_delta(last)=%ld\n",
@@ -273,16 +273,16 @@ static void xpp_drift_step(xbus_t *xbus, const struct timeval *tv)
XBUS_DBG(SYNC, xbus, "ADJ: speed=%d (best_speed=%d) fix=%d\n",
speed, best_speed, fix);
xbus->sync_adjustment_offset = speed;
- if(xbus != syncer && xbus->sync_adjustment != speed)
+ if (xbus != syncer && xbus->sync_adjustment != speed)
send_drift(xbus, speed);
di->sync_inaccuracy = abs(offset) + abs(di->offset_range) / 2;
- if(ticker->count >= SYNC_CYCLE * SYNC_CONVERGE) {
+ if (ticker->count >= SYNC_CYCLE * SYNC_CONVERGE) {
di->offset_range = di->offset_max - di->offset_min;
di->offset_min = INT_MAX;
di->offset_max = -INT_MAX;
- if(di->max_speed > best_speed)
+ if (di->max_speed > best_speed)
di->max_speed--;
- if(di->min_speed < best_speed)
+ if (di->min_speed < best_speed)
di->min_speed++;
}
di->offset_prev = offset;
@@ -301,7 +301,7 @@ const char *sync_mode_name(enum sync_mode mode)
[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];
}
@@ -311,20 +311,20 @@ const char *sync_mode_name(enum sync_mode mode)
*/
static void xpp_set_syncer(xbus_t *xbus, bool on)
{
- 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;
return;
}
- 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",
@@ -340,22 +340,22 @@ static void xbus_command_timer(unsigned long param)
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);
}
@@ -373,14 +373,14 @@ void got_new_syncer(xbus_t *xbus, enum sync_mode mode, int drift)
spin_lock_irqsave(&xbus->lock, flags);
spin_lock_irqsave(&ref_ticker_lock, flags2);
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);
@@ -415,7 +415,7 @@ void xbus_request_sync(xbus_t *xbus, enum sync_mode mode)
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) {
/*
* We must deselect the syncer *now* and not wait for the
* reply from the AB. Otherwise, a disconnect of the syncing
@@ -439,7 +439,7 @@ static void reset_sync_counters(void)
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 = get_xbus(__func__, i);
if (xbus == NULL)
@@ -450,8 +450,8 @@ static void reset_sync_counters(void)
* - 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 {
@@ -470,14 +470,14 @@ static void send_drift(xbus_t *xbus, int drift)
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;
}
@@ -488,7 +488,7 @@ static void global_tick(void)
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);
}
@@ -501,35 +501,35 @@ void dahdi_sync_tick(struct dahdi_span *span, int is_master)
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;
@@ -571,9 +571,9 @@ static void update_sync_master(xbus_t *new_syncer, bool force_dahdi)
* 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;
@@ -581,7 +581,7 @@ static void update_sync_master(xbus_t *new_syncer, bool force_dahdi)
xbus_drift_clear(new_syncer); /* Clean new data */
xpp_set_syncer(new_syncer, 1);
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;
@@ -589,12 +589,12 @@ static void update_sync_master(xbus_t *new_syncer, bool force_dahdi)
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 = get_xbus(__func__, i);
if (xbus == NULL)
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,
xbus->sync_mode_default);
else
@@ -616,19 +616,19 @@ void elect_syncer(const char *msg)
spin_lock_irqsave(&elect_syncer_lock, flags);
DBG(SYNC, "%s: %s syncer=%s\n", __func__, msg,
(syncer) ? syncer->busname : "NULL");
- for(i = 0; i < MAX_BUSES; i++) {
+ for (i = 0; i < MAX_BUSES; i++) {
xbus_t *xbus = get_xbus(__func__, i);
if (xbus == NULL)
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);
int prio;
- if(!xpd || !xpd->card_present || !IS_PHONEDEV(xpd))
+ if (!xpd || !xpd->card_present || !IS_PHONEDEV(xpd))
continue;
prio = CALL_PHONE_METHOD(card_timing_priority, xpd);
if (prio < 0) {
@@ -644,10 +644,10 @@ void elect_syncer(const char *msg)
}
put_xbus(__func__, xbus);
}
- 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 {
unsigned long flags;
@@ -658,7 +658,7 @@ void elect_syncer(const char *msg)
spin_unlock_irqrestore(&ref_ticker_lock, flags);
the_xbus = NULL;
}
- if(the_xbus != syncer)
+ if (the_xbus != syncer)
update_sync_master(the_xbus, force_dahdi_sync);
spin_unlock_irqrestore(&elect_syncer_lock, flags);
}
@@ -694,13 +694,13 @@ void generic_card_pcm_recompute(xpd_t *xpd, xpp_line_t pcm_mask)
pcm_mask &= ~(PHONEDEV(xpd).digital_inputs);
pcm_mask &= ~(PHONEDEV(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;
}
@@ -727,7 +727,7 @@ void fill_beep(u_char *buf, int num, int duration)
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 {
@@ -744,9 +744,9 @@ static void do_ec(xpd_t *xpd)
for (i = 0;i < PHONEDEV(xpd).span.channels; i++) {
struct dahdi_chan *chan = XPD_CHAN(xpd, i);
- if(unlikely(IS_SET(PHONEDEV(xpd).digital_signalling, i))) /* Don't echo cancel BRI D-chans */
+ if (unlikely(IS_SET(PHONEDEV(xpd).digital_signalling, i))) /* Don't echo cancel BRI D-chans */
continue;
- if(!IS_SET(PHONEDEV(xpd).wanted_pcm_mask, i)) /* No ec for unwanted PCM */
+ if (!IS_SET(PHONEDEV(xpd).wanted_pcm_mask, i)) /* No ec for unwanted PCM */
continue;
dahdi_ec_chunk(chan, chan->readchunk, PHONEDEV(xpd).ec_chunk2[i]);
memcpy(PHONEDEV(xpd).ec_chunk2[i], PHONEDEV(xpd).ec_chunk1[i], DAHDI_CHUNKSIZE);
@@ -790,15 +790,15 @@ static bool pcm_valid(xpd_t *xpd, xpacket_t *pack)
* 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;
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);
@@ -818,29 +818,29 @@ static inline void pcm_frame_out(xbus_t *xbus, xframe_t *xframe)
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)++;
@@ -870,12 +870,12 @@ void generic_card_pcm_fromspan(xpd_t *xpd, xpacket_t *pack)
for (i = 0; i < PHONEDEV(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
@@ -905,20 +905,20 @@ void generic_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack)
*/
pcm_mute = ~(PHONEDEV(xpd).wanted_pcm_mask);
pcm_mute |= PHONEDEV(xpd).mute_dtmf | PHONEDEV(xpd).silence_pcm;
- if(!SPAN_REGISTERED(xpd))
+ if (!SPAN_REGISTERED(xpd))
goto out;
for (i = 0; i < PHONEDEV(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(PHONEDEV(xpd).wanted_pcm_mask | PHONEDEV(xpd).silence_pcm, i)) {
+ } else if (IS_SET(PHONEDEV(xpd).wanted_pcm_mask | PHONEDEV(xpd).silence_pcm, i)) {
/* Inject SILENCE */
memset((u_char *)r, 0x7F, DAHDI_CHUNKSIZE);
- if(IS_SET(PHONEDEV(xpd).silence_pcm, i)) {
+ if (IS_SET(PHONEDEV(xpd).silence_pcm, i)) {
/*
* This will clear the EC buffers until next tick
* So we don't have noise residues from the past.
@@ -927,7 +927,7 @@ void generic_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack)
memset(PHONEDEV(xpd).ec_chunk1[i], 0x7F, DAHDI_CHUNKSIZE);
}
}
- if(got_data)
+ if (got_data)
pcm += DAHDI_CHUNKSIZE;
}
out:
@@ -968,7 +968,7 @@ static int copy_pcm_tospan(xbus_t *xbus, xframe_t *xframe)
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 */
@@ -981,10 +981,10 @@ static int copy_pcm_tospan(xbus_t *xbus, xframe_t *xframe)
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",
__func__, rate_limit);
@@ -993,10 +993,10 @@ static int copy_pcm_tospan(xbus_t *xbus, xframe_t *xframe)
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",
__func__, len, rate_limit);
@@ -1005,22 +1005,22 @@ static int copy_pcm_tospan(xbus_t *xbus, xframe_t *xframe)
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(__func__, 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_PHONE_METHOD(card_pcm_tospan, xpd, pack);
}
- } while(p < xframe_end);
+ } while (p < xframe_end);
ret = 0; /* all good */
XBUS_COUNTER(xbus, RX_XFRAME_PCM)++;
out:
@@ -1044,9 +1044,9 @@ static void xbus_tick(xbus_t *xbus)
/*
* 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 = PHONEDEV(xpd).wanted_pcm_mask;
@@ -1069,28 +1069,28 @@ static void xbus_tick(xbus_t *xbus)
/*
* Fill xframes
*/
- for(i = 0; i < MAX_XPDS; i++) {
- if((xpd = xpd_of(xbus, i)) == NULL)
+ for (i = 0; i < MAX_XPDS; i++) {
+ if ((xpd = xpd_of(xbus, i)) == NULL)
continue;
if (!IS_PHONEDEV(xpd))
continue;
- if(SPAN_REGISTERED(xpd)) {
+ if (SPAN_REGISTERED(xpd)) {
size_t pcm_len = PHONEDEV(xpd).pcm_len;
- if(pcm_len && xpd->card_present) {
+ 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",
__func__);
@@ -1098,10 +1098,10 @@ static void xbus_tick(xbus_t *xbus)
}
}
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;
}
@@ -1110,14 +1110,14 @@ static void xbus_tick(xbus_t *xbus)
}
}
}
- 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;
@@ -1125,27 +1125,27 @@ static void xbus_tick(xbus_t *xbus)
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 (IS_PHONEDEV(xpd)) {
- if(SPAN_REGISTERED(xpd)) {
+ if (SPAN_REGISTERED(xpd)) {
do_ec(xpd);
dahdi_receive(&PHONEDEV(xpd).span);
}
@@ -1166,22 +1166,22 @@ static void do_tick(xbus_t *xbus, const struct timeval *tv_received)
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);
@@ -1192,7 +1192,7 @@ void xframe_receive_pcm(xbus_t *xbus, xframe_t *xframe)
* 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
@@ -1205,10 +1205,10 @@ int exec_sync_command(const char *buf, size_t count)
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);
xbus = get_xbus(__func__, xbusno);
if (xbus == NULL) {
@@ -1217,7 +1217,7 @@ int exec_sync_command(const char *buf, size_t count)
}
update_sync_master(xbus, 0);
put_xbus(__func__, xbus);
- } else if(sscanf(buf, "QUERY=%d", &xbusno) == 1) {
+ } else if (sscanf(buf, "QUERY=%d", &xbusno) == 1) {
DBG(SYNC, "QUERY=%d\n", xbusno);
xbus = get_xbus(__func__, xbusno);
if (xbus == NULL) {
@@ -1237,7 +1237,7 @@ int fill_sync_string(char *buf, size_t count)
{
int len = 0;
- if(!syncer) {
+ if (!syncer) {
len += snprintf(buf, count, "%s\n",
(force_dahdi_sync) ? "DAHDI" : "NO-SYNC");
} else
diff --git a/drivers/dahdi/xpp/xbus-sysfs.c b/drivers/dahdi/xpp/xbus-sysfs.c
index c0aaf45..3a20ef0 100644
--- a/drivers/dahdi/xpp/xbus-sysfs.c
+++ b/drivers/dahdi/xpp/xbus-sysfs.c
@@ -82,9 +82,9 @@ static DEVICE_ATTR_WRITER(xbus_state_store, dev, buf, count)
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",
@@ -116,7 +116,7 @@ static DEVICE_ATTR_READER(timing_show, dev, buf)
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: lost (%4d,%4d) : ",
xbus->ticker.cycle,
@@ -146,10 +146,10 @@ static DEVICE_ATTR_READER(samples_show, dev, buf)
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]);
}
@@ -161,7 +161,7 @@ static DEVICE_ATTR_WRITER(samples_store, dev, buf, count)
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;
@@ -245,10 +245,10 @@ static DEVICE_ATTR_READER(driftinfo_show, dev, buf)
uframes_inaccuracy = di->sync_inaccuracy / 125;
len += snprintf(buf + len, PAGE_SIZE - len, "%-15s: %8d ",
"instability", speed_range + uframes_inaccuracy);
- if(xbus->sync_mode == SYNC_MODE_AB) {
+ if (xbus->sync_mode == SYNC_MODE_AB) {
buf[len++] = '-';
} else {
- for(i = 0; len < PAGE_SIZE - 1 && i < speed_range + uframes_inaccuracy; i++)
+ for (i = 0; len < PAGE_SIZE - 1 && i < speed_range + uframes_inaccuracy; i++)
buf[len++] = '#';
}
buf[len++] = '\n';
@@ -321,11 +321,11 @@ static int astribank_hotplug(struct device *dev, char **envp, int envnum, char *
{
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;
@@ -337,7 +337,7 @@ static int astribank_hotplug(struct device *dev, char **envp, int envnum, char *
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...) \
@@ -356,7 +356,7 @@ static int astribank_uevent(struct device *dev, char **envp, int num_envp, char
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);
@@ -378,7 +378,7 @@ static int astribank_uevent(struct device *dev, struct kobj_uevent_env *kenv)
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);
@@ -425,11 +425,11 @@ static void astribank_release(struct device *dev)
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();
@@ -491,7 +491,7 @@ static DEVICE_ATTR_READER(chipregs_show, dev, buf)
BUG_ON(!dev);
xpd = dev_to_xpd(dev);
- if(!xpd)
+ if (!xpd)
return -ENODEV;
spin_lock_irqsave(&xpd->lock, flags);
regs = &xpd->last_reply;
@@ -499,12 +499,12 @@ static DEVICE_ATTR_READER(chipregs_show, dev, buf)
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",
@@ -534,27 +534,27 @@ static DEVICE_ATTR_WRITER(chipregs_store, dev, buf, count)
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;
@@ -568,7 +568,7 @@ static DEVICE_ATTR_READER(blink_show, dev, buf)
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);
@@ -585,12 +585,12 @@ static DEVICE_ATTR_WRITER(blink_store, dev, buf, count)
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;
@@ -605,7 +605,7 @@ static DEVICE_ATTR_READER(span_show, dev, buf)
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) ? PHONEDEV(xpd).span.spanno : 0);
@@ -662,7 +662,7 @@ static DEVICE_ATTR_READER(type_show, dev, buf)
BUG_ON(!dev);
xpd = dev_to_xpd(dev);
- if(!xpd)
+ if (!xpd)
return -ENODEV;
len += sprintf(buf, "%s\n", xpd->type_name);
return len;
@@ -676,12 +676,12 @@ static DEVICE_ATTR_READER(offhook_show, dev, buf)
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");
@@ -696,7 +696,7 @@ static DEVICE_ATTR_READER(timing_priority_show, dev, buf)
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", PHONEDEV(xpd).timing_priority);
@@ -724,7 +724,7 @@ static int xpd_match(struct device *dev, struct device_driver *driver)
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;
@@ -757,7 +757,7 @@ int xpd_driver_register(struct device_driver *driver)
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",
__func__, driver->name, ret);
}
@@ -793,7 +793,7 @@ int xpd_device_register(xbus_t *xbus, xpd_t *xpd)
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", __func__, ret);
return ret;
}
@@ -809,7 +809,7 @@ void xpd_device_unregister(xpd_t *xpd)
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);
@@ -957,7 +957,7 @@ void xbus_sysfs_remove(xbus_t *xbus)
BUG_ON(!xbus);
XBUS_DBG(DEVICES, xbus, "\n");
astribank = &xbus->astribank;
- if(!dev_get_drvdata(astribank))
+ if (!dev_get_drvdata(astribank))
return;
BUG_ON(dev_get_drvdata(astribank) != xbus);
device_unregister(astribank);
@@ -978,7 +978,7 @@ int xbus_sysfs_create(xbus_t *xbus)
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", __func__, ret);
dev_set_drvdata(astribank, NULL);
}
@@ -990,17 +990,17 @@ int __init xpp_driver_init(void)
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",
__func__, toplevel_bus_type.name, ret);
goto failed_toplevel;
}
- if((ret = driver_register(&xpp_driver)) < 0) {
+ if ((ret = driver_register(&xpp_driver)) < 0) {
ERR("%s: driver_register(%s) failed. Error number %d",
__func__, 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",
__func__, xpd_type.name, ret);
goto failed_xpd_bus;
diff --git a/drivers/dahdi/xpp/xdefs.h b/drivers/dahdi/xpp/xdefs.h
index a97ee9b..aa39266 100644
--- a/drivers/dahdi/xpp/xdefs.h
+++ b/drivers/dahdi/xpp/xdefs.h
@@ -112,7 +112,7 @@ typedef unsigned char byte;
#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 @@ typedef unsigned char byte;
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)
diff --git a/drivers/dahdi/xpp/xframe_queue.c b/drivers/dahdi/xpp/xframe_queue.c
index ce71f86..ac5398a 100644
--- a/drivers/dahdi/xpp/xframe_queue.c
+++ b/drivers/dahdi/xpp/xframe_queue.c
@@ -50,11 +50,11 @@ static bool __xframe_enqueue(struct xframe_queue *q, xframe_t *xframe)
int ret = 1;
static int overflow_cnt;
- 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++;
if ((overflow_cnt++ % 1000) < 5) {
NOTICE("Overflow of %-15s: counts %3d, %3d, %3d worst %3d, overflows %3d worst_lag %02ld.%ld ms\n",
@@ -71,7 +71,7 @@ static bool __xframe_enqueue(struct xframe_queue *q, xframe_t *xframe)
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);
@@ -97,7 +97,7 @@ static xframe_t *__xframe_dequeue(struct xframe_queue *q)
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);
@@ -107,7 +107,7 @@ static xframe_t *__xframe_dequeue(struct xframe_queue *q)
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;
@@ -135,7 +135,7 @@ void xframe_queue_clear(struct xframe_queue *q)
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++;
}
@@ -157,17 +157,17 @@ static xframe_t *transport_alloc_xframe(xbus_t *xbus, gfp_t gfp_flags)
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", __func__, 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);
@@ -206,33 +206,33 @@ static bool xframe_queue_adjust(struct xframe_queue *q)
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;
}
@@ -254,10 +254,10 @@ xframe_t *get_xframe(struct xframe_queue *q)
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;
}
@@ -286,7 +286,7 @@ void put_xframe(struct xframe_queue *q, xframe_t *xframe)
BUG_ON(!xbus);
//XBUS_INFO(xbus, "%s\n", __func__);
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;
diff --git a/drivers/dahdi/xpp/xpd.h b/drivers/dahdi/xpp/xpd.h
index 8eaa8dd..fcf64f5 100644
--- a/drivers/dahdi/xpp/xpd.h
+++ b/drivers/dahdi/xpp/xpd.h
@@ -228,7 +228,7 @@ struct xpd {
unsigned int timer_count;
};
-#define for_each_line(xpd,i) for((i) = 0; (i) < PHONEDEV(xpd).channels; (i)++)
+#define for_each_line(xpd,i) for ((i) = 0; (i) < PHONEDEV(xpd).channels; (i)++)
#define IS_BRI(xpd) ((xpd)->type == XPD_TYPE_BRI)
#define TICK_TOLERANCE 500 /* usec */
@@ -243,7 +243,7 @@ static inline void *my_kzalloc(size_t size, gfp_t flags)
void *p;
p = kmalloc(size, flags);
- if(p)
+ if (p)
memset(p, 0, size);
return p;
}
diff --git a/drivers/dahdi/xpp/xpp_dahdi.c b/drivers/dahdi/xpp/xpp_dahdi.c
index a7d263a..9fd00d1 100644
--- a/drivers/dahdi/xpp/xpp_dahdi.c
+++ b/drivers/dahdi/xpp/xpp_dahdi.c
@@ -92,9 +92,9 @@ void xbus_flip_bit(xbus_t *xbus, unsigned int bitnum0, unsigned int bitnum1)
{
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);
@@ -150,8 +150,8 @@ void put_xpd(const char *msg, xpd_t *xpd)
static void xpd_proc_remove(xbus_t *xbus, xpd_t *xpd)
{
#ifdef CONFIG_PROC_FS
- if(xpd->proc_xpd_dir) {
- if(xpd->proc_xpd_summary) {
+ if (xpd->proc_xpd_dir) {
+ 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;
@@ -169,13 +169,13 @@ static int xpd_proc_create(xbus_t *xbus, xpd_t *xpd)
#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;
}
@@ -193,13 +193,13 @@ void xpd_free(xpd_t *xpd)
{
xbus_t *xbus = NULL;
- 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);
@@ -233,18 +233,18 @@ int create_xpd(xbus_t *xbus, const xproto_table_t *proto_table,
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;
@@ -269,7 +269,7 @@ static int xpd_read_proc(char *page, char **start, off_t off, int count, int *eo
xpd_t *xpd = data;
int i;
- if(!xpd)
+ if (!xpd)
goto out;
len += sprintf(page + len, "%s (%s, card %s, span %d)\n"
@@ -322,7 +322,7 @@ static int xpd_read_proc(char *page, char **start, off_t off, int count, int *eo
len += sprintf(page + len, "%d ", IS_SET(PHONEDEV(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);
@@ -332,22 +332,22 @@ static int xpd_read_proc(char *page, char **start, off_t off, int count, int *eo
byte *wp;
int j;
- if(IS_SET(PHONEDEV(xpd).digital_outputs, i))
+ if (IS_SET(PHONEDEV(xpd).digital_outputs, i))
continue;
- if(IS_SET(PHONEDEV(xpd).digital_inputs, i))
+ if (IS_SET(PHONEDEV(xpd).digital_inputs, i))
continue;
- if(IS_SET(PHONEDEV(xpd).digital_signalling, i))
+ if (IS_SET(PHONEDEV(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",
@@ -358,7 +358,7 @@ static int xpd_read_proc(char *page, char **start, off_t off, int count, int *eo
}
#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);
@@ -367,7 +367,7 @@ static int xpd_read_proc(char *page, char **start, off_t off, int count, int *eo
}
#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]);
}
@@ -389,7 +389,7 @@ out:
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";
@@ -404,13 +404,13 @@ bool xpd_setstate(xpd_t *xpd, enum xpd_state newstate)
XPD_DBG(DEVICES, xpd, "%s: %s (%d) -> %s (%d)\n", __func__,
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",
__func__, xpd_statename(newstate));
@@ -418,12 +418,12 @@ bool xpd_setstate(xpd_t *xpd, enum xpd_state newstate)
}
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;
@@ -511,13 +511,13 @@ __must_check xpd_t *xpd_alloc(xbus_t *xbus,
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",
__func__, 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",
__func__, type);
goto err;
@@ -534,7 +534,7 @@ __must_check xpd_t *xpd_alloc(xbus_t *xbus,
kref_init(&xpd->kref);
/* 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)) {
no_pcm = 0x7F | PHONEDEV(xpd).digital_outputs | PHONEDEV(xpd).digital_inputs;
XBUS_NOTICE(xbus, "max xframe size = %d, disabling some PCM channels. no_pcm=0x%04X\n",
MAX_SEND_SIZE(xbus), PHONEDEV(xpd).no_pcm);
@@ -542,7 +542,7 @@ __must_check xpd_t *xpd_alloc(xbus_t *xbus,
if (phonedev_init(xpd, proto_table, channels, no_pcm) < 0)
goto err;
xbus_xpd_bind(xbus, xpd, unit, subunit);
- if(xpd_proc_create(xbus, xpd) < 0)
+ if (xpd_proc_create(xbus, xpd) < 0)
goto err;
/*
* This makes sure the xbus cannot be removed before this xpd
@@ -552,7 +552,7 @@ __must_check xpd_t *xpd_alloc(xbus_t *xbus,
xproto_get(type); /* will be returned in xpd_free() */
return xpd;
err:
- if(xpd) {
+ if (xpd) {
xpd_proc_remove(xbus, xpd);
phonedev_cleanup(xpd);
KZFREE(xpd);
@@ -575,7 +575,7 @@ void update_xpd_status(xpd_t *xpd, int alarm_flag)
{
struct dahdi_span *span = &PHONEDEV(xpd).span;
- if(!SPAN_REGISTERED(xpd)) {
+ if (!SPAN_REGISTERED(xpd)) {
// XPD_NOTICE(xpd, "%s: XPD is not registered. Skipping.\n", __func__);
return;
}
@@ -587,7 +587,7 @@ void update_xpd_status(xpd_t *xpd, int alarm_flag)
// Nothing
break;
}
- if(span->alarms == alarm_flag)
+ if (span->alarms == alarm_flag)
return;
XPD_DBG(GENERAL, xpd, "Update XPD alarms: %s -> %02X\n", PHONEDEV(xpd).span.name, alarm_flag);
span->alarms = alarm_flag;
@@ -601,7 +601,7 @@ void update_xpd_status(xpd_t *xpd, int alarm_flag)
*/
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(PHONEDEV(xpd).oht_pcm_pass, pos);
} else {
@@ -616,7 +616,7 @@ void oht_pcm(xpd_t *xpd, int pos, bool pass)
*/
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(PHONEDEV(xpd).offhook_state, pos);
} else {
@@ -637,7 +637,7 @@ void notify_rxsig(xpd_t *xpd, int pos, enum dahdi_rxsig rxsig)
* 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);
}
@@ -650,7 +650,7 @@ void hookstate_changed(xpd_t *xpd, int pos, bool to_offhook)
{
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
@@ -695,7 +695,7 @@ int xpp_open(struct dahdi_chan *chan)
BUG();
}
pos = chan->chanpos - 1;
- if(!xpd->card_present) {
+ if (!xpd->card_present) {
LINE_NOTICE(xpd, pos, "Cannot open -- device not ready\n");
return -ENODEV;
}
@@ -705,7 +705,7 @@ int xpp_open(struct dahdi_chan *chan)
current->comm, current->pid,
atomic_read(&PHONEDEV(xpd).open_counter));
spin_unlock_irqrestore(&xbus->lock, flags);
- if(PHONE_METHOD(card_open, xpd))
+ if (PHONE_METHOD(card_open, xpd))
CALL_PHONE_METHOD(card_open, xpd, pos);
return 0;
}
@@ -719,7 +719,7 @@ int xpp_close(struct dahdi_chan *chan)
spin_lock_irqsave(&xbus->lock, flags);
spin_unlock_irqrestore(&xbus->lock, flags);
- if(PHONE_METHOD(card_close, xpd))
+ if (PHONE_METHOD(card_close, xpd))
CALL_PHONE_METHOD(card_close, xpd, pos);
LINE_DBG(DEVICES, xpd, pos, "%s[%d]: open_counter=%d\n",
current->comm, current->pid,
@@ -732,7 +732,7 @@ void report_bad_ioctl(const char *msg, xpd_t *xpd, int pos, unsigned int cmd)
{
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);
@@ -747,7 +747,7 @@ int xpp_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long arg)
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",
__func__, pos);
return -ENODEV;
@@ -770,12 +770,12 @@ int xpp_hooksig(struct dahdi_chan *chan, enum dahdi_txsig txsig)
xbus_t *xbus;
int pos = chan->chanpos - 1;
- if(!xpd) {
+ if (!xpd) {
ERR("%s: channel in pos %d, was already closed. Ignore.\n",
__func__, pos);
return -ENODEV;
}
- if(!PHONE_METHOD(card_hooksig, xpd)) {
+ if (!PHONE_METHOD(card_hooksig, xpd)) {
LINE_ERR(xpd, pos,
"%s: No hooksig method for this channel. Ignore.\n",
__func__);
@@ -803,7 +803,7 @@ int xpp_maint(struct dahdi_span *span, int cmd)
#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;
@@ -838,7 +838,7 @@ static int xpp_watchdog(struct dahdi_span *span, int cause)
{
static int rate_limit;
- if((rate_limit++ % 1000) == 0)
+ if ((rate_limit++ % 1000) == 0)
DBG(GENERAL, "\n");
return 0;
}
@@ -1067,7 +1067,7 @@ int xpd_dahdi_postregister(xpd_t *xpd)
* 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;
@@ -1086,10 +1086,10 @@ void xpd_dahdi_preunregister(xpd_t *xpd)
return;
XPD_DBG(DEVICES, xpd, "\n");
update_xpd_status(xpd, DAHDI_ALARM_NOTOPEN);
- if(xpd->card_present)
+ if (xpd->card_present)
CALL_PHONE_METHOD(card_dahdi_preregistration, xpd, 0);
/* Now notify dahdi */
- if(SPAN_REGISTERED(xpd)) {
+ if (SPAN_REGISTERED(xpd)) {
int j;
dahdi_alarm_notify(&PHONEDEV(xpd).span);
@@ -1106,7 +1106,7 @@ void xpd_dahdi_postunregister(xpd_t *xpd)
return;
atomic_dec(&PHONEDEV(xpd).dahdi_registered);
atomic_dec(&num_registered_spans);
- if(xpd->card_present)
+ if (xpd->card_present)
CALL_PHONE_METHOD(card_dahdi_postregistration, xpd, 0);
}
@@ -1115,7 +1115,7 @@ void xpd_dahdi_postunregister(xpd_t *xpd)
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;
@@ -1132,19 +1132,19 @@ static int __init xpp_dahdi_init(void)
MAX_XPDS, MAX_UNIT, MAX_SUBUNIT);
#ifdef CONFIG_PROC_FS
xpp_proc_toplevel = proc_mkdir(PROC_DIR, NULL);
- if(!xpp_proc_toplevel) {
+ if (!xpp_proc_toplevel) {
ret = -EIO;
goto err;
}
top = xpp_proc_toplevel;
#endif
ret = xbus_core_init();
- if(ret) {
+ if (ret) {
ERR("xbus_core_init failed (%d)\n", ret);
goto err;
}
ret = xbus_pcm_init(top);
- if(ret) {
+ if (ret) {
ERR("xbus_pcm_init failed (%d)\n", ret);
xbus_core_shutdown();
goto err;
diff --git a/drivers/dahdi/xpp/xpp_usb.c b/drivers/dahdi/xpp/xpp_usb.c
index 01b3bd8..39902b7 100644
--- a/drivers/dahdi/xpp/xpp_usb.c
+++ b/drivers/dahdi/xpp/xpp_usb.c
@@ -93,20 +93,20 @@ static DEF_PARM(uint, drop_pcm_after, 6, 0644, "Number of consecutive tx_sluggis
# 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
@@ -303,23 +303,23 @@ static xframe_t *alloc_xframe(xbus_t *xbus, gfp_t gfp_flags)
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_alloc_coherent(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;
@@ -362,10 +362,10 @@ static int do_send_xframe(xbus_t *xbus, xframe_t *xframe)
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;
@@ -374,10 +374,10 @@ static int do_send_xframe(xbus_t *xbus, xframe_t *xframe)
/*
* 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);
@@ -394,10 +394,10 @@ static int do_send_xframe(xbus_t *xbus, xframe_t *xframe)
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",
__func__, ret);
ret = -EBADF;
@@ -424,7 +424,7 @@ static int xframe_send_pcm(xbus_t *xbus, xframe_t *xframe)
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;
@@ -455,17 +455,17 @@ static bool xusb_listen(xusb_t *xusb)
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",
__func__, ret);
FREE_RECV_XFRAME(xbus, xframe);
@@ -570,10 +570,10 @@ static int check_usb1(struct usb_endpoint_descriptor *endpoint)
{
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;
@@ -601,13 +601,13 @@ static int set_endpoints(xusb_t *xusb, struct usb_host_interface *iface_desc, st
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];
@@ -616,7 +616,7 @@ static int set_endpoints(xusb_t *xusb, struct usb_host_interface *iface_desc, st
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];
@@ -666,12 +666,12 @@ static int xusb_probe(struct usb_interface *interface, const struct usb_device_i
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;
}
@@ -698,7 +698,7 @@ static int xusb_probe(struct usb_interface *interface, const struct usb_device_i
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;
}
@@ -733,7 +733,7 @@ static int xusb_probe(struct usb_interface *interface, const struct usb_device_i
/* 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;
}
@@ -744,19 +744,19 @@ static int xusb_probe(struct usb_interface *interface, const struct usb_device_i
udev->descriptor.idProduct,
udev->descriptor.bcdDevice);
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;
@@ -777,24 +777,24 @@ static int xusb_probe(struct usb_interface *interface, const struct usb_device_i
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 (xbus) {
#ifdef CONFIG_PROC_FS
- if(procsummary) {
+ 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;
@@ -834,15 +834,15 @@ static void xusb_disconnect(struct usb_interface *interface)
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);
}
@@ -873,7 +873,7 @@ static void xpp_send_callback(USB_PASS_CB(urb))
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;
}
@@ -882,18 +882,18 @@ static void xpp_send_callback(USB_PASS_CB(urb))
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);
@@ -906,7 +906,7 @@ static void xpp_send_callback(USB_PASS_CB(urb))
/* 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);
@@ -916,7 +916,7 @@ static void xpp_send_callback(USB_PASS_CB(urb))
} 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");
}
@@ -932,11 +932,11 @@ static void xpp_receive_callback(USB_PASS_CB(urb))
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;
}
- if(!xusb->present) {
+ if (!xusb->present) {
do_resubmit = 0;
goto err;
}
@@ -946,10 +946,10 @@ static void xpp_receive_callback(USB_PASS_CB(urb))
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;
@@ -963,7 +963,7 @@ static void xpp_receive_callback(USB_PASS_CB(urb))
/* Send UP */
xbus_receive_xframe(xbus, xframe);
end:
- if(do_resubmit)
+ if (do_resubmit)
xusb_listen(xusb);
return;
err:
@@ -976,7 +976,7 @@ err:
static void xpp_usb_cleanup(void)
{
- if(xusb_cache) {
+ if (xusb_cache) {
kmem_cache_destroy(xusb_cache);
xusb_cache = NULL;
}
@@ -999,7 +999,7 @@ static int __init xpp_usb_init(void)
NULL,
#endif
NULL);
- if(!xusb_cache) {
+ if (!xusb_cache) {
ret = -ENOMEM;
goto failure;
}
@@ -1039,7 +1039,7 @@ static int xusb_read_proc(char *page, char **start, off_t off, int count, int *e
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);
@@ -1070,10 +1070,10 @@ static int xusb_read_proc(char *page, char **start, off_t off, int count, int *e
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",
@@ -1081,7 +1081,7 @@ static int xusb_read_proc(char *page, char **start, off_t off, int count, int *e
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
diff --git a/drivers/dahdi/xpp/xproto.c b/drivers/dahdi/xpp/xproto.c
index d0c44e6..529bbef 100644
--- a/drivers/dahdi/xpp/xproto.c
+++ b/drivers/dahdi/xpp/xproto.c
@@ -70,7 +70,7 @@ xproto_handler_t xproto_global_handler(byte opcode)
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 *xproto_get(xpd_type_t cardtype)
{
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",
__func__, 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", __func__, xtable->name);
return NULL;
}
@@ -139,8 +139,8 @@ static int packet_process(xbus_t *xbus, xpacket_t *pack)
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",
__func__,
XPACKET_ADDR_UNIT(pack), XPACKET_ADDR_SUBUNIT(pack));
@@ -153,11 +153,11 @@ static int packet_process(xbus_t *xbus, xpacket_t *pack)
/* 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",
__func__,
XPACKET_ADDR_UNIT(pack), XPACKET_ADDR_SUBUNIT(pack), op);
@@ -166,16 +166,16 @@ static int packet_process(xbus_t *xbus, xpacket_t *pack)
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",
__func__,
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",
__func__,
xpd->type, op);
@@ -186,8 +186,8 @@ static int packet_process(xbus_t *xbus, xpacket_t *pack)
}
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",
__func__, XPACKET_LEN(pack), op);
dump_packet("packet_process -- wrong size", pack, debug);
@@ -211,7 +211,7 @@ static int xframe_receive_cmd(xbus_t *xbus, xframe_t *xframe)
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 @@ static int xframe_receive_cmd(xbus_t *xbus, xframe_t *xframe)
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 @@ static int xframe_receive_cmd(xbus_t *xbus, xframe_t *xframe)
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 @@ static int xframe_receive_cmd(xbus_t *xbus, xframe_t *xframe)
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 @@ int xframe_receive(xbus_t *xbus, xframe_t *xframe)
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 @@ int xframe_receive(xbus_t *xbus, xframe_t *xframe)
/*
* 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 @@ int xframe_receive(xbus_t *xbus, xframe_t *xframe)
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 @@ void dump_packet(const char *msg, const xpacket_t *packet, bool debug)
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 @@ void dump_packet(const char *msg, const xpacket_t *packet, bool debug)
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;
- 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",
__func__, 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",
__func__, limiter);
}
@@ -347,12 +347,12 @@ void dump_reg_cmd(const char msg[], bool writing, xbus_t *xbus,
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",
__func__, 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 @@ void dump_reg_cmd(const char msg[], bool writing, xbus_t *xbus,
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 @@ void dump_reg_cmd(const char msg[], bool writing, xbus_t *xbus,
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",
__func__, msg, regcmd->bytes);
return;
@@ -378,7 +378,7 @@ void dump_reg_cmd(const char msg[], bool writing, xbus_t *xbus,
(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 @@ void dump_reg_cmd(const char msg[], bool writing, xbus_t *xbus,
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,19 +409,19 @@ const char *xproto_name(xpd_type_t xpd_type)
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(xops, f) \
- if(!(xops)->f) { \
+ if (!(xops)->f) { \
ERR("%s: missing xmethod %s [%s (%d)]\n", __func__, #f, name, type); \
return -EINVAL; \
}
#define CHECK_PHONEOP(phoneops, f) \
- if(!(phoneops)->f) { \
+ if (!(phoneops)->f) { \
ERR("%s: missing phone method %s [%s (%d)]\n", __func__, #f, name, type); \
return -EINVAL; \
}
@@ -436,12 +436,12 @@ int xproto_register(const xproto_table_t *proto_table)
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", __func__, 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", __func__, name, type);
xops = proto_table->xops;
CHECK_XOP(xops, card_new);
@@ -476,11 +476,11 @@ void xproto_unregister(const xproto_table_t *proto_table)
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", __func__, name, type);
return;
}
- if(!xprotocol_tables[type])
+ if (!xprotocol_tables[type])
NOTICE("%s: xproto type %s (%d) is already unregistered\n", __func__, name, type);
xprotocol_tables[type] = NULL;
}
diff --git a/drivers/dahdi/xpp/xproto.h b/drivers/dahdi/xpp/xproto.h
index 92d7ab0..6eda25f 100644
--- a/drivers/dahdi/xpp/xproto.h
+++ b/drivers/dahdi/xpp/xproto.h
@@ -45,7 +45,7 @@ struct xpd_addr {
(p)->unit = (u); \
(p)->subunit = (s); \
(p)->sync_master = 0; \
- } while(0)
+ } while (0)
struct xpacket_header {
uint16_t packet_len:10;
@@ -142,23 +142,23 @@ bool valid_xpd_addr(const struct xpd_addr *addr);
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