diff options
author | Tzafrir Cohen <tzafrir.cohen@xorcom.com> | 2012-01-11 15:22:46 +0000 |
---|---|---|
committer | Tzafrir Cohen <tzafrir.cohen@xorcom.com> | 2012-01-11 15:22:46 +0000 |
commit | dc228a61f57f12f036ae8b993aa3dc286493de67 (patch) | |
tree | 23c098b100a3b7b2a1630fc08e5790ae97060f00 /drivers/dahdi/xpp/card_bri.c | |
parent | f968cd418bf89bd1c5e97bb2655b76c74f45541c (diff) |
xpp: style - Run Lindent
* Here it is:
KERNEL_STYLE="-npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cp1"
TYPEDEFS='
-T gfp_t
-T __user
-T u_char
-T __u8
-T byte
-T bool
-T charp
-T xusb_t
-T xbus_t
-T xpd_t
-T xproto_table_t
-T xproto_entry_t
-T xframe_t
-T xpacket_t
-T reg_cmd_t
'
indent $TYPEDEFS $KERNEL_STYLE \
--ignore-newlines \
--indent-label0 \
--no-space-after-function-call-names \
"$@"
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@10428 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/xpp/card_bri.c')
-rw-r--r-- | drivers/dahdi/xpp/card_bri.c | 991 |
1 files changed, 516 insertions, 475 deletions
diff --git a/drivers/dahdi/xpp/card_bri.c b/drivers/dahdi/xpp/card_bri.c index f4addc3..30598f2 100644 --- a/drivers/dahdi/xpp/card_bri.c +++ b/drivers/dahdi/xpp/card_bri.c @@ -40,30 +40,32 @@ static const char rcsid[] = "$Id$"; #endif static DEF_PARM(int, debug, 0, 0644, "Print DBG statements"); /* must be before dahdi_debug.h */ -static DEF_PARM(uint, poll_interval, 500, 0644, "Poll channel state interval in milliseconds (0 - disable)"); -static DEF_PARM_BOOL(nt_keepalive, 1, 0644, "Force BRI_NT to keep trying connection"); +static DEF_PARM(uint, poll_interval, 500, 0644, + "Poll channel state interval in milliseconds (0 - disable)"); +static DEF_PARM_BOOL(nt_keepalive, 1, 0644, + "Force BRI_NT to keep trying connection"); enum xhfc_states { - ST_RESET = 0, /* G/F0 */ + ST_RESET = 0, /* G/F0 */ /* TE */ - ST_TE_SENSING = 2, /* F2 */ - ST_TE_DEACTIVATED = 3, /* F3 */ - ST_TE_SIGWAIT = 4, /* F4 */ - ST_TE_IDENT = 5, /* F5 */ - ST_TE_SYNCED = 6, /* F6 */ - ST_TE_ACTIVATED = 7, /* F7 */ - ST_TE_LOST_FRAMING = 8, /* F8 */ + ST_TE_SENSING = 2, /* F2 */ + ST_TE_DEACTIVATED = 3, /* F3 */ + ST_TE_SIGWAIT = 4, /* F4 */ + ST_TE_IDENT = 5, /* F5 */ + ST_TE_SYNCED = 6, /* F6 */ + ST_TE_ACTIVATED = 7, /* F7 */ + ST_TE_LOST_FRAMING = 8, /* F8 */ /* NT */ - ST_NT_DEACTIVATED = 1, /* G1 */ - ST_NT_ACTIVATING = 2, /* G2 */ - ST_NT_ACTIVATED = 3, /* G3 */ - ST_NT_DEACTIVTING = 4, /* G4 */ + ST_NT_DEACTIVATED = 1, /* G1 */ + ST_NT_ACTIVATING = 2, /* G2 */ + ST_NT_ACTIVATED = 3, /* G3 */ + ST_NT_DEACTIVTING = 4, /* G4 */ }; #ifdef CONFIG_PROC_FS static const char *xhfc_state_name(bool is_nt, enum xhfc_states state) { - const char *p; + const char *p; #define _E(x) [ST_ ## x] = #x static const char *te_names[] = { @@ -111,9 +113,9 @@ static const char *xhfc_state_name(bool is_nt, enum xhfc_states state) #define HFC_TIMER_T3 8000 /* 8s activation timer T3 */ #define HFC_TIMER_OFF -1 /* timer disabled */ -#define A_SU_WR_STA 0x30 /* ST/Up state machine register */ +#define A_SU_WR_STA 0x30 /* ST/Up state machine register */ #define V_SU_LD_STA 0x10 -#define V_SU_ACT 0x60 /* start activation/deactivation */ +#define V_SU_ACT 0x60 /* start activation/deactivation */ #define STA_DEACTIVATE 0x40 /* start deactivation in A_SU_WR_STA */ #define STA_ACTIVATE 0x60 /* start activation in A_SU_WR_STA */ #define V_SU_SET_G2_G3 0x80 @@ -121,13 +123,13 @@ static const char *xhfc_state_name(bool is_nt, enum xhfc_states state) #define A_SU_RD_STA 0x30 typedef union { struct { - __u8 v_su_sta:4; - __u8 v_su_fr_sync:1; - __u8 v_su_t2_exp:1; - __u8 v_su_info0:1; - __u8 v_g2_g3:1; + __u8 v_su_sta:4; + __u8 v_su_fr_sync:1; + __u8 v_su_t2_exp:1; + __u8 v_su_info0:1; + __u8 v_g2_g3:1; } bits; - __u8 reg; + __u8 reg; } su_rd_sta_t; #define REG30_LOST 3 /* in polls */ @@ -149,7 +151,8 @@ static int write_state_register(xpd_t *xpd, __u8 value); static bool bri_packet_is_valid(xpacket_t *pack); static void bri_packet_dump(const char *msg, xpacket_t *pack); #ifdef CONFIG_PROC_FS -static int proc_bri_info_read(char *page, char **start, off_t off, int count, int *eof, void *data); +static int proc_bri_info_read(char *page, char **start, off_t off, int count, + int *eof, void *data); #endif static int bri_spanconfig(struct file *file, struct dahdi_span *span, struct dahdi_lineconfig *lc); @@ -162,29 +165,28 @@ static int bri_shutdown(struct dahdi_span *span); #define PROC_BRI_INFO_FNAME "bri_info" enum led_state { - BRI_LED_OFF = 0x0, - BRI_LED_ON = 0x1, + BRI_LED_OFF = 0x0, + BRI_LED_ON = 0x1, /* * We blink by software from driver, so that * if the driver malfunction that blink would stop. */ - // BRI_LED_BLINK_SLOW = 0x2, /* 1/2 a second blink cycle */ - // BRI_LED_BLINK_FAST = 0x3 /* 1/4 a second blink cycle */ + // BRI_LED_BLINK_SLOW = 0x2, /* 1/2 a second blink cycle */ + // BRI_LED_BLINK_FAST = 0x3 /* 1/4 a second blink cycle */ }; enum bri_led_names { - GREEN_LED = 0, - RED_LED = 1 + GREEN_LED = 0, + RED_LED = 1 }; #define NUM_LEDS 2 #define LED_TICKS 100 - struct bri_leds { - __u8 state:2; - __u8 led_sel:1; /* 0 - GREEN, 1 - RED */ - __u8 reserved:5; + __u8 state:2; + __u8 led_sel:1; /* 0 - GREEN, 1 - RED */ + __u8 reserved:5; }; #ifndef MAX_DFRAME_LEN_L1 @@ -194,42 +196,41 @@ struct bri_leds { #define DCHAN_BUFSIZE MAX_DFRAME_LEN_L1 struct BRI_priv_data { - struct proc_dir_entry *bri_info; - su_rd_sta_t state_register; - bool initialized; - int t1; /* timer 1 for NT deactivation */ - int t3; /* timer 3 for TE activation */ - ulong l1_flags; - bool reg30_good; - uint reg30_ticks; - bool layer1_up; + struct proc_dir_entry *bri_info; + su_rd_sta_t state_register; + bool initialized; + int t1; /* timer 1 for NT deactivation */ + int t3; /* timer 3 for TE activation */ + ulong l1_flags; + bool reg30_good; + uint reg30_ticks; + bool layer1_up; /* * D-Chan: buffers + extra state info. */ - atomic_t hdlc_pending; - bool txframe_begin; - - uint tick_counter; - uint poll_counter; - uint dchan_tx_counter; - uint dchan_rx_counter; - uint dchan_rx_drops; - bool dchan_alive; - uint dchan_alive_ticks; - uint dchan_notx_ticks; - uint dchan_norx_ticks; - enum led_state ledstate[NUM_LEDS]; + atomic_t hdlc_pending; + bool txframe_begin; + + uint tick_counter; + uint poll_counter; + uint dchan_tx_counter; + uint dchan_rx_counter; + uint dchan_rx_drops; + bool dchan_alive; + uint dchan_alive_ticks; + uint dchan_notx_ticks; + uint dchan_norx_ticks; + enum led_state ledstate[NUM_LEDS]; }; -static xproto_table_t PROTO_TABLE(BRI); - +static xproto_table_t PROTO_TABLE(BRI); DEF_RPACKET_DATA(BRI, SET_LED, /* Set one of the LED's */ - struct bri_leds bri_leds; - ); + struct bri_leds bri_leds;); -static /* 0x33 */ DECLARE_CMD(BRI, SET_LED, enum bri_led_names which_led, enum led_state to_led_state); +static /* 0x33 */ DECLARE_CMD(BRI, SET_LED, enum bri_led_names which_led, + enum led_state to_led_state); #define DO_LED(xpd, which, tostate) \ CALL_PROTO(BRI, SET_LED, (xpd)->xbus, (xpd), (which), (tostate)) @@ -237,24 +238,25 @@ static /* 0x33 */ DECLARE_CMD(BRI, SET_LED, enum bri_led_names which_led, enum l #define DEBUG_BUF_SIZE (100) static void dump_hex_buf(xpd_t *xpd, char *msg, __u8 *buf, size_t len) { - char debug_buf[DEBUG_BUF_SIZE + 1]; - int i; - int n = 0; + char debug_buf[DEBUG_BUF_SIZE + 1]; + int i; + int n = 0; debug_buf[0] = '\0'; 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)?"...":""); + 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) ? "..." : ""); } static void dump_dchan_packet(xpd_t *xpd, bool transmit, __u8 *buf, int len) { - struct BRI_priv_data *priv; - char msgbuf[MAX_PROC_WRITE]; - char ftype = '?'; - char *direction; - int frame_begin; + struct BRI_priv_data *priv; + char msgbuf[MAX_PROC_WRITE]; + char ftype = '?'; + char *direction; + int frame_begin; priv = xpd->priv; BUG_ON(!priv); @@ -275,14 +277,16 @@ static void dump_dchan_packet(xpd_t *xpd, bool transmit, __u8 *buf, int len) else XPD_NOTICE(xpd, "Unknown frame type 0x%X\n", buf[0]); - snprintf(msgbuf, MAX_PROC_WRITE, "D-Chan %s = (%c) ", direction, ftype); + snprintf(msgbuf, MAX_PROC_WRITE, "D-Chan %s = (%c) ", direction, + ftype); } else { snprintf(msgbuf, MAX_PROC_WRITE, "D-Chan %s = ", direction); } dump_hex_buf(xpd, msgbuf, buf, len); } -static void set_bri_timer(xpd_t *xpd, const char *name, int *bri_timer, int value) +static void set_bri_timer(xpd_t *xpd, const char *name, int *bri_timer, + int value) { if (value == HFC_TIMER_OFF) XPD_DBG(SIGNAL, xpd, "Timer %s DISABLE\n", name); @@ -293,7 +297,7 @@ static void set_bri_timer(xpd_t *xpd, const char *name, int *bri_timer, int valu static void dchan_state(xpd_t *xpd, bool up) { - struct BRI_priv_data *priv; + struct BRI_priv_data *priv; BUG_ON(!xpd); priv = xpd->priv; @@ -305,7 +309,8 @@ static void dchan_state(xpd_t *xpd, bool up) priv->dchan_alive = 1; } else { XPD_DBG(SIGNAL, xpd, "STATE CHANGE: D-Channel STOPPED\n"); - priv->dchan_rx_counter = priv->dchan_tx_counter = priv->dchan_rx_drops = 0; + priv->dchan_rx_counter = priv->dchan_tx_counter = + priv->dchan_rx_drops = 0; priv->dchan_alive = 0; priv->dchan_alive_ticks = 0; } @@ -313,7 +318,7 @@ static void dchan_state(xpd_t *xpd, bool up) static void layer1_state(xpd_t *xpd, bool up) { - struct BRI_priv_data *priv; + struct BRI_priv_data *priv; BUG_ON(!xpd); priv = xpd->priv; @@ -321,21 +326,21 @@ static void layer1_state(xpd_t *xpd, bool up) if (priv->layer1_up == up) return; priv->layer1_up = up; - XPD_DBG(SIGNAL, xpd, "STATE CHANGE: Layer1 %s\n", (up)?"UP":"DOWN"); + XPD_DBG(SIGNAL, xpd, "STATE CHANGE: Layer1 %s\n", (up) ? "UP" : "DOWN"); if (!up) dchan_state(xpd, 0); } static void te_activation(xpd_t *xpd, bool on) { - struct BRI_priv_data *priv; - __u8 curr_state; + struct BRI_priv_data *priv; + __u8 curr_state; BUG_ON(!xpd); priv = xpd->priv; BUG_ON(!priv); curr_state = priv->state_register.bits.v_su_sta; - XPD_DBG(SIGNAL, xpd, "%s\n", (on)?"ON":"OFF"); + XPD_DBG(SIGNAL, xpd, "%s\n", (on) ? "ON" : "OFF"); if (on) { if (curr_state == ST_TE_DEACTIVATED) { XPD_DBG(SIGNAL, xpd, "HFC_L1_ACTIVATE_TE\n"); @@ -347,84 +352,84 @@ static void te_activation(xpd_t *xpd, bool on) "HFC_L1_ACTIVATE_TE (state %d, ignored)\n", curr_state); } - } else { /* happen only because of T3 expiry */ + } else { /* happen only because of T3 expiry */ switch (curr_state) { - case ST_TE_DEACTIVATED: /* F3 */ - case ST_TE_SYNCED: /* F6 */ - case ST_TE_ACTIVATED: /* F7 */ - XPD_DBG(SIGNAL, xpd, - "HFC_L1_FORCE_DEACTIVATE_TE (state %d, ignored)\n", - curr_state); - break; - case ST_TE_SIGWAIT: /* F4 */ - case ST_TE_IDENT: /* F5 */ - case ST_TE_LOST_FRAMING: /* F8 */ - XPD_DBG(SIGNAL, xpd, "HFC_L1_FORCE_DEACTIVATE_TE\n"); - write_state_register(xpd, STA_DEACTIVATE); - break; - default: - XPD_NOTICE(xpd, "Bad TE state: %d\n", curr_state); - break; + case ST_TE_DEACTIVATED: /* F3 */ + case ST_TE_SYNCED: /* F6 */ + case ST_TE_ACTIVATED: /* F7 */ + XPD_DBG(SIGNAL, xpd, + "HFC_L1_FORCE_DEACTIVATE_TE (state %d, ignored)\n", + curr_state); + break; + case ST_TE_SIGWAIT: /* F4 */ + case ST_TE_IDENT: /* F5 */ + case ST_TE_LOST_FRAMING: /* F8 */ + XPD_DBG(SIGNAL, xpd, "HFC_L1_FORCE_DEACTIVATE_TE\n"); + write_state_register(xpd, STA_DEACTIVATE); + break; + default: + XPD_NOTICE(xpd, "Bad TE state: %d\n", curr_state); + break; } } } static void nt_activation(xpd_t *xpd, bool on) { - struct BRI_priv_data *priv; - __u8 curr_state; + struct BRI_priv_data *priv; + __u8 curr_state; BUG_ON(!xpd); priv = xpd->priv; BUG_ON(!priv); curr_state = priv->state_register.bits.v_su_sta; - XPD_DBG(SIGNAL, xpd, "%s\n", (on)?"ON":"OFF"); + XPD_DBG(SIGNAL, xpd, "%s\n", (on) ? "ON" : "OFF"); if (on) { switch (curr_state) { - case ST_RESET: /* F/G 0 */ - case ST_NT_DEACTIVATED: /* G1 */ - case ST_NT_DEACTIVTING: /* G4 */ - XPD_DBG(SIGNAL, xpd, "HFC_L1_ACTIVATE_NT\n"); - set_bri_timer(xpd, "T1", &priv->t1, HFC_TIMER_T1); - set_bit(HFC_L1_ACTIVATING, &priv->l1_flags); - write_state_register(xpd, STA_ACTIVATE); - break; - case ST_NT_ACTIVATING: /* G2 */ - case ST_NT_ACTIVATED: /* G3 */ - XPD_DBG(SIGNAL, xpd, - "HFC_L1_ACTIVATE_NT (in state %d, ignored)\n", - curr_state); - break; + case ST_RESET: /* F/G 0 */ + case ST_NT_DEACTIVATED: /* G1 */ + case ST_NT_DEACTIVTING: /* G4 */ + XPD_DBG(SIGNAL, xpd, "HFC_L1_ACTIVATE_NT\n"); + set_bri_timer(xpd, "T1", &priv->t1, HFC_TIMER_T1); + set_bit(HFC_L1_ACTIVATING, &priv->l1_flags); + write_state_register(xpd, STA_ACTIVATE); + break; + case ST_NT_ACTIVATING: /* G2 */ + case ST_NT_ACTIVATED: /* G3 */ + XPD_DBG(SIGNAL, xpd, + "HFC_L1_ACTIVATE_NT (in state %d, ignored)\n", + curr_state); + break; } } else { switch (curr_state) { - case ST_RESET: /* F/G 0 */ - case ST_NT_DEACTIVATED: /* G1 */ - case ST_NT_DEACTIVTING: /* G4 */ - XPD_DBG(SIGNAL, xpd, - "HFC_L1_DEACTIVATE_NT (in state %d, ignored)\n", - curr_state); - break; - case ST_NT_ACTIVATING: /* G2 */ - case ST_NT_ACTIVATED: /* G3 */ - XPD_DBG(SIGNAL, xpd, "HFC_L1_DEACTIVATE_NT\n"); - write_state_register(xpd, STA_DEACTIVATE); - break; - default: - XPD_NOTICE(xpd, "Bad NT state: %d\n", curr_state); - break; + case ST_RESET: /* F/G 0 */ + case ST_NT_DEACTIVATED: /* G1 */ + case ST_NT_DEACTIVTING: /* G4 */ + XPD_DBG(SIGNAL, xpd, + "HFC_L1_DEACTIVATE_NT (in state %d, ignored)\n", + curr_state); + break; + case ST_NT_ACTIVATING: /* G2 */ + case ST_NT_ACTIVATED: /* G3 */ + XPD_DBG(SIGNAL, xpd, "HFC_L1_DEACTIVATE_NT\n"); + write_state_register(xpd, STA_DEACTIVATE); + break; + default: + XPD_NOTICE(xpd, "Bad NT state: %d\n", curr_state); + break; } } } - /* * D-Chan receive */ -static int bri_check_stat(xpd_t *xpd, struct dahdi_chan *dchan, __u8 *buf, int len) +static int bri_check_stat(xpd_t *xpd, struct dahdi_chan *dchan, __u8 *buf, + int len) { - struct BRI_priv_data *priv; - __u8 status; + struct BRI_priv_data *priv; + __u8 status; priv = xpd->priv; BUG_ON(!priv); @@ -433,9 +438,9 @@ static int bri_check_stat(xpd_t *xpd, struct dahdi_chan *dchan, __u8 *buf, int l dahdi_hdlc_abort(dchan, DAHDI_EVENT_ABORT); return -EPROTO; } - status = buf[len-1]; + status = buf[len - 1]; if (status) { - int event = DAHDI_EVENT_ABORT; + int event = DAHDI_EVENT_ABORT; if (status == 0xFF) { XPD_NOTICE(xpd, "D-Chan RX DROP: ABORT: %d\n", status); @@ -452,19 +457,19 @@ static int bri_check_stat(xpd_t *xpd, struct dahdi_chan *dchan, __u8 *buf, int l static int rx_dchan(xpd_t *xpd, reg_cmd_t *regcmd) { - struct BRI_priv_data *priv; - __u8 *src; - struct dahdi_chan *dchan; - uint len; - bool eoframe; - int ret = 0; + struct BRI_priv_data *priv; + __u8 *src; + struct dahdi_chan *dchan; + uint len; + bool eoframe; + int ret = 0; src = REG_XDATA(regcmd); len = regcmd->bytes; eoframe = regcmd->eoframe; 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; @@ -501,9 +506,9 @@ out: /* DAHDI calls this when it has data it wants to send to the HDLC controller */ static void bri_hdlc_hard_xmit(struct dahdi_chan *chan) { - xpd_t *xpd = chan->pvt; - struct dahdi_chan *dchan; - struct BRI_priv_data *priv; + xpd_t *xpd = chan->pvt; + struct dahdi_chan *dchan; + struct BRI_priv_data *priv; priv = xpd->priv; BUG_ON(!priv); @@ -521,8 +526,9 @@ static int send_dchan_frame(xpd_t *xpd, xframe_t *xframe, bool is_eof) XPD_DBG(COMMANDS, xpd, "eoframe=%d\n", is_eof); priv = xpd->priv; if (!test_bit(HFC_L1_ACTIVATED, &priv->l1_flags) - && !test_bit(HFC_L1_ACTIVATING, &priv->l1_flags)) { - XPD_DBG(SIGNAL, xpd, "Want to transmit: Kick D-Channel transmiter\n"); + && !test_bit(HFC_L1_ACTIVATING, &priv->l1_flags)) { + XPD_DBG(SIGNAL, xpd, + "Want to transmit: Kick D-Channel transmiter\n"); if (!IS_NT(xpd)) te_activation(xpd, 1); else @@ -545,8 +551,8 @@ static int send_dchan_frame(xpd_t *xpd, xframe_t *xframe, bool is_eof) /* * Fill a single multibyte REGISTER_REQUEST */ -static void fill_multibyte(xpd_t *xpd, xpacket_t *pack, bool eoframe, - char *buf, int len) +static void fill_multibyte(xpd_t *xpd, xpacket_t *pack, bool eoframe, char *buf, + int len) { reg_cmd_t *reg_cmd; char *p; @@ -587,14 +593,14 @@ static int tx_dchan(xpd_t *xpd) BUG_ON(!priv); if (atomic_read(&priv->hdlc_pending) == 0) return 0; - if (!SPAN_REGISTERED(xpd) || - !(PHONEDEV(xpd).span.flags & DAHDI_FLAG_RUNNING)) + if (!SPAN_REGISTERED(xpd) + || !(PHONEDEV(xpd).span.flags & DAHDI_FLAG_RUNNING)) return 0; /* Allocate frame */ xframe = ALLOC_SEND_XFRAME(xpd->xbus); if (!xframe) { XPD_NOTICE(xpd, "%s: failed to allocate new xframe\n", - __func__); + __func__); return -ENOMEM; } for (packet_count = 0, eoframe = 0; !eoframe; packet_count++) { @@ -609,9 +615,8 @@ static int tx_dchan(xpd_t *xpd) /* * A split. Send what we currently have. */ - XPD_NOTICE(xpd, - "%s: xframe is full (%d packets)\n", - __func__, packet_count); + XPD_NOTICE(xpd, "%s: xframe is full (%d packets)\n", + __func__, packet_count); break; } /* Get data from DAHDI */ @@ -639,7 +644,7 @@ static int tx_dchan(xpd_t *xpd) static void bri_proc_remove(xbus_t *xbus, xpd_t *xpd) { - struct BRI_priv_data *priv; + struct BRI_priv_data *priv; BUG_ON(!xpd); priv = xpd->priv; @@ -654,16 +659,19 @@ static void bri_proc_remove(xbus_t *xbus, xpd_t *xpd) static int bri_proc_create(xbus_t *xbus, xpd_t *xpd) { - struct BRI_priv_data *priv; + struct BRI_priv_data *priv; BUG_ON(!xpd); priv = xpd->priv; XPD_DBG(PROC, xpd, "\n"); #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); + 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) { - XPD_ERR(xpd, "Failed to create proc file '%s'\n", PROC_BRI_INFO_FNAME); + XPD_ERR(xpd, "Failed to create proc file '%s'\n", + PROC_BRI_INFO_FNAME); bri_proc_remove(xbus, xpd); return -EINVAL; } @@ -672,18 +680,21 @@ static int bri_proc_create(xbus_t *xbus, xpd_t *xpd) return 0; } -static xpd_t *BRI_card_new(xbus_t *xbus, int unit, int subunit, const xproto_table_t *proto_table, - __u8 subtype, int subunits, int subunit_ports, bool to_phone) +static xpd_t *BRI_card_new(xbus_t *xbus, int unit, int subunit, + const xproto_table_t *proto_table, __u8 subtype, + int subunits, int subunit_ports, bool to_phone) { - xpd_t *xpd = NULL; - int channels = min(3, CHANNELS_PERXPD); + xpd_t *xpd = NULL; + int channels = min(3, CHANNELS_PERXPD); 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); + xpd = + xpd_alloc(xbus, unit, subunit, subtype, subunits, + sizeof(struct BRI_priv_data), proto_table, channels); if (!xpd) return NULL; PHONEDEV(xpd).direction = (to_phone) ? TO_PHONE : TO_PSTN; @@ -698,7 +709,7 @@ err: static int BRI_card_init(xbus_t *xbus, xpd_t *xpd) { - struct BRI_priv_data *priv; + struct BRI_priv_data *priv; BUG_ON(!xpd); XPD_DBG(GENERAL, xpd, "\n"); @@ -744,15 +755,15 @@ static const struct dahdi_span_ops BRI_span_ops = { static int BRI_card_dahdi_preregistration(xpd_t *xpd, bool on) { - xbus_t *xbus; - struct BRI_priv_data *priv; - int i; + xbus_t *xbus; + struct BRI_priv_data *priv; + int i; BUG_ON(!xpd); xbus = xpd->xbus; priv = xpd->priv; BUG_ON(!xbus); - XPD_DBG(GENERAL, xpd, "%s\n", (on)?"on":"off"); + XPD_DBG(GENERAL, xpd, "%s\n", (on) ? "on" : "off"); if (!on) { /* Nothing to do yet */ return 0; @@ -762,12 +773,12 @@ static int BRI_card_dahdi_preregistration(xpd_t *xpd, bool on) PHONEDEV(xpd).span.deflaw = DAHDI_LAW_ALAW; BIT_SET(PHONEDEV(xpd).digital_signalling, 2); /* D-Channel */ for_each_line(xpd, i) { - struct dahdi_chan *cur_chan = XPD_CHAN(xpd, i); + struct dahdi_chan *cur_chan = XPD_CHAN(xpd, i); XPD_DBG(GENERAL, xpd, "setting BRI channel %d\n", i); snprintf(cur_chan->name, MAX_CHANNAME, "XPP_%s/%02d/%1d%1d/%d", - xpd->type_name, xbus->num, - xpd->addr.unit, xpd->addr.subunit, i); + xpd->type_name, xbus->num, xpd->addr.unit, + xpd->addr.subunit, i); cur_chan->chanpos = i + 1; cur_chan->pvt = xpd; if (i == 2) { /* D-CHAN */ @@ -786,13 +797,13 @@ static int BRI_card_dahdi_preregistration(xpd_t *xpd, bool on) static int BRI_card_dahdi_postregistration(xpd_t *xpd, bool on) { - xbus_t *xbus; + xbus_t *xbus; BUG_ON(!xpd); xbus = xpd->xbus; BUG_ON(!xbus); - XPD_DBG(GENERAL, xpd, "%s\n", (on)?"on":"off"); - return(0); + XPD_DBG(GENERAL, xpd, "%s\n", (on) ? "on" : "off"); + return (0); } static int BRI_card_hooksig(xpd_t *xpd, int pos, enum dahdi_txsig txsig) @@ -809,11 +820,11 @@ static int BRI_card_hooksig(xpd_t *xpd, int pos, enum dahdi_txsig txsig) */ static void handle_leds(xbus_t *xbus, xpd_t *xpd) { - struct BRI_priv_data *priv; - unsigned int timer_count; - int which_led; - int other_led; - int mod; + struct BRI_priv_data *priv; + unsigned int timer_count; + int which_led; + int other_led; + int mod; BUG_ON(!xpd); if (IS_NT(xpd)) { @@ -844,24 +855,24 @@ static void handle_leds(xbus_t *xbus, xpd_t *xpd) if (priv->dchan_alive) { mod = timer_count % 1000; switch (mod) { - case 0: - DO_LED(xpd, which_led, BRI_LED_ON); - break; - case 500: - DO_LED(xpd, which_led, BRI_LED_OFF); - break; + case 0: + DO_LED(xpd, which_led, BRI_LED_ON); + break; + case 500: + DO_LED(xpd, which_led, BRI_LED_OFF); + break; } } else if (priv->layer1_up) { mod = timer_count % 1000; switch (mod) { - case 0: - case 100: - DO_LED(xpd, which_led, BRI_LED_ON); - break; - case 50: - case 150: - DO_LED(xpd, which_led, BRI_LED_OFF); - break; + case 0: + case 100: + DO_LED(xpd, which_led, BRI_LED_ON); + break; + case 50: + case 150: + DO_LED(xpd, which_led, BRI_LED_OFF); + break; } } else { if (priv->ledstate[which_led] != BRI_LED_ON) @@ -871,7 +882,7 @@ static void handle_leds(xbus_t *xbus, xpd_t *xpd) static void handle_bri_timers(xpd_t *xpd) { - struct BRI_priv_data *priv; + struct BRI_priv_data *priv; BUG_ON(!xpd); priv = xpd->priv; @@ -879,16 +890,20 @@ static void handle_bri_timers(xpd_t *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); + 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 */ - XPD_DBG(SIGNAL, xpd, "T1 Expired. Deactivate NT\n"); - clear_bit(HFC_L1_ACTIVATING, &priv->l1_flags); + XPD_DBG(SIGNAL, xpd, + "T1 Expired. Deactivate NT\n"); + clear_bit(HFC_L1_ACTIVATING, + &priv->l1_flags); nt_activation(xpd, 0); /* Deactivate NT */ } else XPD_DBG(SIGNAL, xpd, "T1 Expired. (state %d, ignored)\n", - priv->state_register.bits.v_su_sta); + priv->state_register. + bits.v_su_sta); } } } @@ -896,10 +911,12 @@ static void handle_bri_timers(xpd_t *xpd) if (priv->t3 > HFC_TIMER_OFF) { /* timer expired ? */ if (--priv->t3 == 0) { - XPD_DBG(SIGNAL, xpd, "T3 expired. Deactivate TE\n"); - set_bri_timer(xpd, "T3", &priv->t3, HFC_TIMER_OFF); + XPD_DBG(SIGNAL, xpd, + "T3 expired. Deactivate TE\n"); + set_bri_timer(xpd, "T3", &priv->t3, + HFC_TIMER_OFF); clear_bit(HFC_L1_ACTIVATING, &priv->l1_flags); - te_activation(xpd, 0); /* Deactivate TE */ + te_activation(xpd, 0); /* Deactivate TE */ } } } @@ -910,7 +927,7 @@ static void handle_bri_timers(xpd_t *xpd) */ static int BRI_card_tick(xbus_t *xbus, xpd_t *xpd) { - struct BRI_priv_data *priv; + struct BRI_priv_data *priv; BUG_ON(!xpd); priv = xpd->priv; @@ -920,21 +937,20 @@ static int BRI_card_tick(xbus_t *xbus, xpd_t *xpd) 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, - BRI_PORT(xpd), /* portno */ - 0, /* writing */ - A_SU_RD_STA, /* regnum */ - 0, /* do_subreg */ - 0, /* subreg */ - 0, /* data_low */ - 0, /* do_datah */ - 0, /* data_high */ - 0 /* should_reply */ - ); - - if (IS_NT(xpd) && nt_keepalive && - !test_bit(HFC_L1_ACTIVATED, &priv->l1_flags) && - !test_bit(HFC_L1_ACTIVATING, &priv->l1_flags)) { + xpp_register_request(xbus, xpd, BRI_PORT(xpd), /* portno */ + 0, /* writing */ + A_SU_RD_STA, /* regnum */ + 0, /* do_subreg */ + 0, /* subreg */ + 0, /* data_low */ + 0, /* do_datah */ + 0, /* data_high */ + 0 /* should_reply */ + ); + + 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"); nt_activation(xpd, 1); } @@ -943,20 +959,23 @@ 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) { + } 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) { /* No reply for 1/2 a second */ - XPD_ERR(xpd, "Lost state tracking for %d ticks\n", priv->reg30_ticks); + XPD_ERR(xpd, "Lost state tracking for %d ticks\n", + priv->reg30_ticks); priv->reg30_good = 0; layer1_state(xpd, 0); } @@ -968,22 +987,23 @@ static int BRI_card_tick(xbus_t *xbus, xpd_t *xpd) return 0; } -static int BRI_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long arg) +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)) return -ENODEV; switch (cmd) { - case DAHDI_TONEDETECT: - /* - * Asterisk call all span types with this (FXS specific) - * call. Silently ignore it. - */ - LINE_DBG(SIGNAL, xpd, pos, "BRI: Starting a call\n"); - return -ENOTTY; - default: - report_bad_ioctl(THIS_MODULE->name, xpd, pos, cmd); - return -ENOTTY; + case DAHDI_TONEDETECT: + /* + * Asterisk call all span types with this (FXS specific) + * call. Silently ignore it. + */ + LINE_DBG(SIGNAL, xpd, pos, "BRI: Starting a call\n"); + return -ENOTTY; + default: + report_bad_ioctl(THIS_MODULE->name, xpd, pos, cmd); + return -ENOTTY; } return 0; } @@ -1020,11 +1040,11 @@ static int BRI_card_close(xpd_t *xpd, lineno_t pos) static int bri_spanconfig(struct file *file, struct dahdi_span *span, struct dahdi_lineconfig *lc) { - struct phonedev *phonedev = container_of(span, struct phonedev, span); - xpd_t *xpd = container_of(phonedev, struct xpd, phonedev); - const char *framingstr = ""; - const char *codingstr = ""; - const char *crcstr = ""; + struct phonedev *phonedev = container_of(span, struct phonedev, span); + xpd_t *xpd = container_of(phonedev, struct xpd, phonedev); + const char *framingstr = ""; + const char *codingstr = ""; + const char *crcstr = ""; /* framing first */ if (lc->lineconfig & DAHDI_CONFIG_B8ZS) @@ -1043,14 +1063,10 @@ static int bri_spanconfig(struct file *file, struct dahdi_span *span, /* E1's can enable CRC checking */ if (lc->lineconfig & DAHDI_CONFIG_CRC4) crcstr = "CRC4"; - XPD_DBG(GENERAL, xpd, "[%s]: span=%d (%s) lbo=%d lineconfig=%s/%s/%s (0x%X) sync=%d\n", - IS_NT(xpd)?"NT":"TE", - lc->span, - lc->name, - lc->lbo, - framingstr, codingstr, crcstr, - lc->lineconfig, - lc->sync); + XPD_DBG(GENERAL, xpd, + "[%s]: span=%d (%s) lbo=%d lineconfig=%s/%s/%s (0x%X) sync=%d\n", + IS_NT(xpd) ? "NT" : "TE", lc->span, lc->name, lc->lbo, + framingstr, codingstr, crcstr, lc->lineconfig, lc->sync); PHONEDEV(xpd).timing_priority = lc->sync; elect_syncer("BRI-spanconfig"); /* @@ -1068,7 +1084,8 @@ static int bri_spanconfig(struct file *file, struct dahdi_span *span, static int bri_chanconfig(struct file *file, struct dahdi_chan *chan, int sigtype) { - DBG(GENERAL, "channel %d (%s) -> %s\n", chan->channo, chan->name, sig2str(sigtype)); + DBG(GENERAL, "channel %d (%s) -> %s\n", chan->channo, chan->name, + sig2str(sigtype)); // FIXME: sanity checks: // - should be supported (within the sigcap) // - should not replace fxs <->fxo ??? (covered by previous?) @@ -1080,16 +1097,17 @@ static int bri_chanconfig(struct file *file, struct dahdi_chan *chan, */ static int bri_startup(struct file *file, struct dahdi_span *span) { - struct phonedev *phonedev = container_of(span, struct phonedev, span); - xpd_t *xpd = container_of(phonedev, struct xpd, phonedev); - struct BRI_priv_data *priv; - struct dahdi_chan *dchan; + struct phonedev *phonedev = container_of(span, struct phonedev, span); + xpd_t *xpd = container_of(phonedev, struct xpd, phonedev); + struct BRI_priv_data *priv; + struct dahdi_chan *dchan; BUG_ON(!xpd); priv = xpd->priv; BUG_ON(!priv); if (!XBUS_IS(xpd->xbus, READY)) { - XPD_DBG(GENERAL, xpd, "Startup called by dahdi. No Hardware. Ignored\n"); + XPD_DBG(GENERAL, xpd, + "Startup called by dahdi. No Hardware. Ignored\n"); return -ENODEV; } XPD_DBG(GENERAL, xpd, "STARTUP\n"); @@ -1114,15 +1132,16 @@ static int bri_startup(struct file *file, struct dahdi_span *span) */ static int bri_shutdown(struct dahdi_span *span) { - struct phonedev *phonedev = container_of(span, struct phonedev, span); - xpd_t *xpd = container_of(phonedev, struct xpd, phonedev); - struct BRI_priv_data *priv; + struct phonedev *phonedev = container_of(span, struct phonedev, span); + xpd_t *xpd = container_of(phonedev, struct xpd, phonedev); + struct BRI_priv_data *priv; BUG_ON(!xpd); priv = xpd->priv; BUG_ON(!priv); if (!XBUS_IS(xpd->xbus, READY)) { - XPD_DBG(GENERAL, xpd, "Shutdown called by dahdi. No Hardware. Ignored\n"); + XPD_DBG(GENERAL, xpd, + "Shutdown called by dahdi. No Hardware. Ignored\n"); return -ENODEV; } XPD_DBG(GENERAL, xpd, "SHUTDOWN\n"); @@ -1131,20 +1150,20 @@ static int bri_shutdown(struct dahdi_span *span) return 0; } -static void BRI_card_pcm_recompute(xpd_t *xpd, - xpp_line_t dont_care) +static void BRI_card_pcm_recompute(xpd_t *xpd, xpp_line_t dont_care) { - int i; - int line_count; - xpp_line_t pcm_mask; - uint pcm_len; - xpd_t *main_xpd; - unsigned long flags; + int i; + int line_count; + xpp_line_t pcm_mask; + uint pcm_len; + xpd_t *main_xpd; + unsigned long flags; BUG_ON(!xpd); main_xpd = xpd_byaddr(xpd->xbus, xpd->addr.unit, 0); if (!main_xpd) { - XPD_DBG(DEVICES, xpd, "Unit 0 is already gone. Ignore request\n"); + XPD_DBG(DEVICES, xpd, + "Unit 0 is already gone. Ignore request\n"); return; } /* @@ -1155,11 +1174,13 @@ static void BRI_card_pcm_recompute(xpd_t *xpd, line_count = 0; pcm_mask = 0; for (i = 0; i < MAX_SUBUNIT; i++) { - xpd_t *sub_xpd = xpd_byaddr(xpd->xbus, main_xpd->addr.unit, i); + xpd_t *sub_xpd = xpd_byaddr(xpd->xbus, main_xpd->addr.unit, i); if (sub_xpd) { - xpp_line_t lines = - PHONEDEV(sub_xpd).offhook_state & ~(PHONEDEV(sub_xpd).digital_signalling); + xpp_line_t lines = + PHONEDEV(sub_xpd). + offhook_state & ~(PHONEDEV(sub_xpd). + digital_signalling); if (lines) { pcm_mask |= PCM_SHIFT(lines, i); @@ -1183,27 +1204,26 @@ static void BRI_card_pcm_recompute(xpd_t *xpd, * The main unit account for all subunits (pcm_len and wanted_pcm_mask). */ pcm_len = (line_count) - ? RPACKET_HEADERSIZE + sizeof(xpp_line_t) + line_count * DAHDI_CHUNKSIZE - : 0L; + ? RPACKET_HEADERSIZE + sizeof(xpp_line_t) + + line_count * DAHDI_CHUNKSIZE : 0L; update_wanted_pcm_mask(main_xpd, pcm_mask, pcm_len); spin_unlock_irqrestore(&PHONEDEV(main_xpd).lock_recompute_pcm, flags); } static void BRI_card_pcm_fromspan(xpd_t *xpd, xpacket_t *pack) { - __u8 *pcm; - unsigned long flags; - int i; - int subunit; - xpp_line_t pcm_mask = 0; - xpp_line_t wanted_lines; - + __u8 *pcm; + unsigned long flags; + int i; + int subunit; + xpp_line_t pcm_mask = 0; + xpp_line_t wanted_lines; BUG_ON(!xpd); BUG_ON(!pack); pcm = RPACKET_FIELD(pack, GLOBAL, PCM_WRITE, pcm); for (subunit = 0; subunit < MAX_SUBUNIT; subunit++) { - xpd_t *tmp_xpd; + xpd_t *tmp_xpd; tmp_xpd = xpd_byaddr(xpd->xbus, xpd->addr.unit, subunit); if (!tmp_xpd || !tmp_xpd->card_present) @@ -1211,20 +1231,24 @@ static void BRI_card_pcm_fromspan(xpd_t *xpd, xpacket_t *pack) 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); + struct dahdi_chan *chan = XPD_CHAN(tmp_xpd, i); if (IS_SET(wanted_lines, i)) { if (SPAN_REGISTERED(tmp_xpd)) { #ifdef DEBUG_PCMTX - int channo = chan->channo; + int channo = chan->channo; if (pcmtx >= 0 && pcmtx_chan == channo) - memset((u_char *)pcm, pcmtx, DAHDI_CHUNKSIZE); + memset((u_char *)pcm, pcmtx, + DAHDI_CHUNKSIZE); else #endif - memcpy((u_char *)pcm, chan->writechunk, DAHDI_CHUNKSIZE); + memcpy((u_char *)pcm, + chan->writechunk, + DAHDI_CHUNKSIZE); } else - memset((u_char *)pcm, 0x7F, DAHDI_CHUNKSIZE); + memset((u_char *)pcm, 0x7F, + DAHDI_CHUNKSIZE); pcm += DAHDI_CHUNKSIZE; } } @@ -1237,11 +1261,11 @@ static void BRI_card_pcm_fromspan(xpd_t *xpd, xpacket_t *pack) static void BRI_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack) { - __u8 *pcm; - xpp_line_t pcm_mask; - unsigned long flags; - int subunit; - int i; + __u8 *pcm; + xpp_line_t pcm_mask; + unsigned long flags; + int subunit; + int i; /* * Subunit 0 handle all other subunits @@ -1252,22 +1276,24 @@ static void BRI_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack) 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) { - xpd_t *tmp_xpd; + for (subunit = 0; subunit < MAX_SUBUNIT; + subunit++, pcm_mask >>= SUBUNIT_PCM_SHIFT) { + xpd_t *tmp_xpd; 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; + xpp_line_t tmp_mask = pcm_mask & (BIT(0) | BIT(1)); + volatile u_char *r; if (IS_SET(tmp_mask, i)) { r = XPD_CHAN(tmp_xpd, i)->readchunk; - // memset((u_char *)r, 0x5A, DAHDI_CHUNKSIZE); // DEBUG + // memset((u_char *)r, 0x5A, DAHDI_CHUNKSIZE); // DEBUG memcpy((u_char *)r, pcm, DAHDI_CHUNKSIZE); pcm += DAHDI_CHUNKSIZE; } @@ -1279,7 +1305,7 @@ static void BRI_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack) static int BRI_timing_priority(xpd_t *xpd) { - struct BRI_priv_data *priv; + struct BRI_priv_data *priv; priv = xpd->priv; BUG_ON(!priv); @@ -1296,7 +1322,7 @@ int BRI_echocancel_timeslot(xpd_t *xpd, int pos) static int BRI_echocancel_setmask(xpd_t *xpd, xpp_line_t ec_mask) { - struct BRI_priv_data *priv; + struct BRI_priv_data *priv; int i; BUG_ON(!xpd); @@ -1305,11 +1331,11 @@ static int BRI_echocancel_setmask(xpd_t *xpd, xpp_line_t ec_mask) XPD_DBG(GENERAL, xpd, "0x%8X\n", ec_mask); if (!ECHOOPS(xpd->xbus)) { XPD_DBG(GENERAL, xpd, - "No echo canceller in XBUS: Doing nothing.\n"); + "No echo canceller in XBUS: Doing nothing.\n"); return -EINVAL; } for (i = 0; i < PHONEDEV(xpd).channels - 1; i++) { - int on = BIT(i) & ec_mask; + int on = BIT(i) & ec_mask; CALL_EC_METHOD(ec_set, xpd->xbus, xpd, i, on); } @@ -1319,19 +1345,19 @@ static int BRI_echocancel_setmask(xpd_t *xpd, xpp_line_t ec_mask) /*---------------- BRI: HOST COMMANDS -------------------------------------*/ -static /* 0x33 */ HOSTCMD(BRI, SET_LED, enum bri_led_names which_led, enum led_state to_led_state) +static /* 0x33 */ HOSTCMD(BRI, SET_LED, enum bri_led_names which_led, + enum led_state to_led_state) { - int ret = 0; - xframe_t *xframe; - xpacket_t *pack; - struct bri_leds *bri_leds; - struct BRI_priv_data *priv; + int ret = 0; + xframe_t *xframe; + xpacket_t *pack; + struct bri_leds *bri_leds; + struct BRI_priv_data *priv; BUG_ON(!xbus); priv = xpd->priv; BUG_ON(!priv); - XPD_DBG(LEDS, xpd, "%s -> %d\n", - (which_led)?"RED":"GREEN", + XPD_DBG(LEDS, xpd, "%s -> %d\n", (which_led) ? "RED" : "GREEN", to_led_state); XFRAME_NEW_CMD(xframe, pack, xbus, BRI, SET_LED, xpd->xbus_idx); bri_leds = &RPACKET_FIELD(pack, BRI, SET_LED, bri_leds); @@ -1345,28 +1371,27 @@ static /* 0x33 */ HOSTCMD(BRI, SET_LED, enum bri_led_names which_led, enum led_s static int write_state_register(xpd_t *xpd, __u8 value) { - int ret; + int ret; XPD_DBG(REGS, xpd, "value = 0x%02X\n", value); - ret = xpp_register_request(xpd->xbus, xpd, - BRI_PORT(xpd), /* portno */ - 1, /* writing */ - A_SU_WR_STA, /* regnum */ - 0, /* do_subreg */ - 0, /* subreg */ - value, /* data_low */ - 0, /* do_datah */ - 0, /* data_high */ - 0 /* should_reply */ - ); + ret = xpp_register_request(xpd->xbus, xpd, BRI_PORT(xpd), /* portno */ + 1, /* writing */ + A_SU_WR_STA, /* regnum */ + 0, /* do_subreg */ + 0, /* subreg */ + value, /* data_low */ + 0, /* do_datah */ + 0, /* data_high */ + 0 /* should_reply */ + ); return ret; } /*---------------- BRI: Astribank Reply Handlers --------------------------*/ static void su_new_state(xpd_t *xpd, __u8 reg_x30) { - struct BRI_priv_data *priv; - su_rd_sta_t new_state; + struct BRI_priv_data *priv; + su_rd_sta_t new_state; BUG_ON(!xpd); priv = xpd->priv; @@ -1382,79 +1407,78 @@ static void su_new_state(xpd_t *xpd, __u8 reg_x30) priv->reg30_ticks = 0; priv->reg30_good = 1; if (priv->state_register.bits.v_su_sta == new_state.bits.v_su_sta) - return; /* same same */ + return; /* same same */ XPD_DBG(SIGNAL, xpd, "%02X ---> %02X (info0=%d) (%s%i)\n", - priv->state_register.reg, - reg_x30, - new_state.bits.v_su_info0, - IS_NT(xpd)?"G":"F", - new_state.bits.v_su_sta); + priv->state_register.reg, reg_x30, new_state.bits.v_su_info0, + IS_NT(xpd) ? "G" : "F", new_state.bits.v_su_sta); 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"); - clear_bit(HFC_L1_ACTIVATED, &priv->l1_flags); - layer1_state(xpd, 0); - break; - case ST_TE_SIGWAIT: /* F4 */ - XPD_DBG(SIGNAL, xpd, "State ST_TE_SIGWAIT (F4)\n"); - layer1_state(xpd, 0); - break; - case ST_TE_IDENT: /* F5 */ - XPD_DBG(SIGNAL, xpd, "State ST_TE_IDENT (F5)\n"); - layer1_state(xpd, 0); - break; - case ST_TE_SYNCED: /* F6 */ - XPD_DBG(SIGNAL, xpd, "State ST_TE_SYNCED (F6)\n"); - layer1_state(xpd, 0); - break; - case ST_TE_ACTIVATED: /* F7 */ - XPD_DBG(SIGNAL, xpd, "State ST_TE_ACTIVATED (F7)\n"); - set_bri_timer(xpd, "T3", &priv->t3, HFC_TIMER_OFF); - clear_bit(HFC_L1_ACTIVATING, &priv->l1_flags); - set_bit(HFC_L1_ACTIVATED, &priv->l1_flags); - layer1_state(xpd, 1); - update_xpd_status(xpd, DAHDI_ALARM_NONE); - break; - case ST_TE_LOST_FRAMING: /* F8 */ - XPD_DBG(SIGNAL, xpd, "State ST_TE_LOST_FRAMING (F8)\n"); - layer1_state(xpd, 0); - break; - default: - XPD_NOTICE(xpd, "Bad TE state: %d\n", new_state.bits.v_su_sta); - break; + case ST_TE_DEACTIVATED: /* F3 */ + XPD_DBG(SIGNAL, xpd, "State ST_TE_DEACTIVATED (F3)\n"); + clear_bit(HFC_L1_ACTIVATED, &priv->l1_flags); + layer1_state(xpd, 0); + break; + case ST_TE_SIGWAIT: /* F4 */ + XPD_DBG(SIGNAL, xpd, "State ST_TE_SIGWAIT (F4)\n"); + layer1_state(xpd, 0); + break; + case ST_TE_IDENT: /* F5 */ + XPD_DBG(SIGNAL, xpd, "State ST_TE_IDENT (F5)\n"); + layer1_state(xpd, 0); + break; + case ST_TE_SYNCED: /* F6 */ + XPD_DBG(SIGNAL, xpd, "State ST_TE_SYNCED (F6)\n"); + layer1_state(xpd, 0); + break; + case ST_TE_ACTIVATED: /* F7 */ + XPD_DBG(SIGNAL, xpd, "State ST_TE_ACTIVATED (F7)\n"); + set_bri_timer(xpd, "T3", &priv->t3, HFC_TIMER_OFF); + clear_bit(HFC_L1_ACTIVATING, &priv->l1_flags); + set_bit(HFC_L1_ACTIVATED, &priv->l1_flags); + layer1_state(xpd, 1); + update_xpd_status(xpd, DAHDI_ALARM_NONE); + break; + case ST_TE_LOST_FRAMING: /* F8 */ + XPD_DBG(SIGNAL, xpd, "State ST_TE_LOST_FRAMING (F8)\n"); + layer1_state(xpd, 0); + break; + default: + XPD_NOTICE(xpd, "Bad TE state: %d\n", + new_state.bits.v_su_sta); + break; } } else { switch (new_state.bits.v_su_sta) { - case ST_NT_DEACTIVATED: /* G1 */ - XPD_DBG(SIGNAL, xpd, "State ST_NT_DEACTIVATED (G1)\n"); - clear_bit(HFC_L1_ACTIVATED, &priv->l1_flags); - set_bri_timer(xpd, "T1", &priv->t1, HFC_TIMER_OFF); - layer1_state(xpd, 0); - break; - 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)) - nt_activation(xpd, 1); - break; - case ST_NT_ACTIVATED: /* G3 */ - XPD_DBG(SIGNAL, xpd, "State ST_NT_ACTIVATED (G3)\n"); - clear_bit(HFC_L1_ACTIVATING, &priv->l1_flags); - set_bit(HFC_L1_ACTIVATED, &priv->l1_flags); - set_bri_timer(xpd, "T1", &priv->t1, HFC_TIMER_OFF); - layer1_state(xpd, 1); - update_xpd_status(xpd, DAHDI_ALARM_NONE); - break; - case ST_NT_DEACTIVTING: /* G4 */ - XPD_DBG(SIGNAL, xpd, "State ST_NT_DEACTIVTING (G4)\n"); - set_bri_timer(xpd, "T1", &priv->t1, HFC_TIMER_OFF); - layer1_state(xpd, 0); - break; - default: - XPD_NOTICE(xpd, "Bad NT state: %d\n", new_state.bits.v_su_sta); - break; + case ST_NT_DEACTIVATED: /* G1 */ + XPD_DBG(SIGNAL, xpd, "State ST_NT_DEACTIVATED (G1)\n"); + clear_bit(HFC_L1_ACTIVATED, &priv->l1_flags); + set_bri_timer(xpd, "T1", &priv->t1, HFC_TIMER_OFF); + layer1_state(xpd, 0); + break; + 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)) + nt_activation(xpd, 1); + break; + case ST_NT_ACTIVATED: /* G3 */ + XPD_DBG(SIGNAL, xpd, "State ST_NT_ACTIVATED (G3)\n"); + clear_bit(HFC_L1_ACTIVATING, &priv->l1_flags); + set_bit(HFC_L1_ACTIVATED, &priv->l1_flags); + set_bri_timer(xpd, "T1", &priv->t1, HFC_TIMER_OFF); + layer1_state(xpd, 1); + update_xpd_status(xpd, DAHDI_ALARM_NONE); + break; + case ST_NT_DEACTIVTING: /* G4 */ + XPD_DBG(SIGNAL, xpd, "State ST_NT_DEACTIVTING (G4)\n"); + set_bri_timer(xpd, "T1", &priv->t1, HFC_TIMER_OFF); + layer1_state(xpd, 0); + break; + default: + XPD_NOTICE(xpd, "Bad NT state: %d\n", + new_state.bits.v_su_sta); + break; } } priv->state_register.reg = new_state.reg; @@ -1462,11 +1486,11 @@ static void su_new_state(xpd_t *xpd, __u8 reg_x30) static int BRI_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info) { - unsigned long flags; - struct BRI_priv_data *priv; - struct xpd_addr addr; - xpd_t *orig_xpd; - int ret; + unsigned long flags; + struct BRI_priv_data *priv; + struct xpd_addr addr; + xpd_t *orig_xpd; + int ret; /* Map UNIT + PORTNUM to XPD */ orig_xpd = xpd; @@ -1474,10 +1498,10 @@ static int BRI_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info) addr.subunit = info->portnum; xpd = xpd_byaddr(xbus, addr.unit, addr.subunit); if (!xpd) { - static int rate_limit; + static int rate_limit; if ((rate_limit++ % 1003) < 5) - notify_bad_xpd(__func__, xbus, addr , orig_xpd->xpdname); + notify_bad_xpd(__func__, xbus, addr, orig_xpd->xpdname); return -EPROTO; } spin_lock_irqsave(&xpd->lock, flags); @@ -1485,23 +1509,26 @@ static int BRI_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info) BUG_ON(!priv); 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)); + REG_FIELD(info, regnum), REG_FIELD(info, subreg), + REG_FIELD(info, data_low)); } else { if (REG_FIELD(info, regnum) != A_SU_RD_STA) XPD_DBG(REGS, xpd, "RD %02X %02X\n", - REG_FIELD(info, regnum), REG_FIELD(info, data_low)); + REG_FIELD(info, regnum), REG_FIELD(info, + data_low)); else XPD_DBG(REGS, xpd, "Got SU_RD_STA=%02X\n", - REG_FIELD(info, data_low)); + REG_FIELD(info, data_low)); } if (info->is_multibyte) { XPD_DBG(REGS, xpd, "Got Multibyte: %d bytes, eoframe: %d\n", - info->bytes, info->eoframe); + info->bytes, info->eoframe); ret = rx_dchan(xpd, info); if (ret < 0) { priv->dchan_rx_drops++; if (atomic_read(&PHONEDEV(xpd).open_counter) > 0) - XPD_NOTICE(xpd, "Multibyte Drop: errno=%d\n", ret); + XPD_NOTICE(xpd, "Multibyte Drop: errno=%d\n", + ret); } goto end; } @@ -1510,10 +1537,11 @@ static int BRI_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info) } /* Update /proc info only if reply relate to the last slic read request */ - 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)) { + 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)) { xpd->last_reply = *info; } @@ -1524,14 +1552,14 @@ end: static int BRI_card_state(xpd_t *xpd, bool on) { - struct BRI_priv_data *priv; + struct BRI_priv_data *priv; BUG_ON(!xpd); priv = xpd->priv; - XPD_DBG(GENERAL, xpd, "%s\n", (on)?"ON":"OFF"); + 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 (!IS_NT(xpd)) te_activation(xpd, 1); else nt_activation(xpd, 1); @@ -1541,47 +1569,41 @@ static int BRI_card_state(xpd_t *xpd, bool on) return 0; } -static const struct xops bri_xops = { - .card_new = BRI_card_new, - .card_init = BRI_card_init, - .card_remove = BRI_card_remove, - .card_tick = BRI_card_tick, - .card_register_reply = BRI_card_register_reply, +static const struct xops bri_xops = { + .card_new = BRI_card_new, + .card_init = BRI_card_init, + .card_remove = BRI_card_remove, + .card_tick = BRI_card_tick, + .card_register_reply = BRI_card_register_reply, }; -static const struct phoneops bri_phoneops = { - .card_dahdi_preregistration = BRI_card_dahdi_preregistration, - .card_dahdi_postregistration = BRI_card_dahdi_postregistration, - .card_hooksig = BRI_card_hooksig, - .card_pcm_recompute = BRI_card_pcm_recompute, - .card_pcm_fromspan = BRI_card_pcm_fromspan, - .card_pcm_tospan = BRI_card_pcm_tospan, - .card_timing_priority = BRI_timing_priority, - .echocancel_timeslot = BRI_echocancel_timeslot, - .echocancel_setmask = BRI_echocancel_setmask, - .card_ioctl = BRI_card_ioctl, - .card_open = BRI_card_open, - .card_close = BRI_card_close, - .card_state = BRI_card_state, +static const struct phoneops bri_phoneops = { + .card_dahdi_preregistration = BRI_card_dahdi_preregistration, + .card_dahdi_postregistration = BRI_card_dahdi_postregistration, + .card_hooksig = BRI_card_hooksig, + .card_pcm_recompute = BRI_card_pcm_recompute, + .card_pcm_fromspan = BRI_card_pcm_fromspan, + .card_pcm_tospan = BRI_card_pcm_tospan, + .card_timing_priority = BRI_timing_priority, + .echocancel_timeslot = BRI_echocancel_timeslot, + .echocancel_setmask = BRI_echocancel_setmask, + .card_ioctl = BRI_card_ioctl, + .card_open = BRI_card_open, + .card_close = BRI_card_close, + .card_state = BRI_card_state, }; static xproto_table_t PROTO_TABLE(BRI) = { - .owner = THIS_MODULE, - .entries = { - /* Table Card Opcode */ - }, - .name = "BRI", /* protocol name */ - .ports_per_subunit = 1, - .type = XPD_TYPE_BRI, - .xops = &bri_xops, - .phoneops = &bri_phoneops, - .packet_is_valid = bri_packet_is_valid, - .packet_dump = bri_packet_dump, -}; + .owner = THIS_MODULE,.entries = { + /* Table Card Opcode */ + },.name = "BRI", /* protocol name */ +.ports_per_subunit = 1,.type = XPD_TYPE_BRI,.xops = + &bri_xops,.phoneops = &bri_phoneops,.packet_is_valid = + bri_packet_is_valid,.packet_dump = bri_packet_dump,}; static bool bri_packet_is_valid(xpacket_t *pack) { - const xproto_entry_t *xe = NULL; + const xproto_entry_t *xe = NULL; // DBG(GENERAL, "\n"); xe = xproto_card_entry(&PROTO_TABLE(BRI), XPACKET_OP(pack)); return xe != NULL; @@ -1591,15 +1613,17 @@ static void bri_packet_dump(const char *msg, xpacket_t *pack) { DBG(GENERAL, "%s\n", msg); } + /*------------------------- REGISTER Handling --------------------------*/ #ifdef CONFIG_PROC_FS -static int proc_bri_info_read(char *page, char **start, off_t off, int count, int *eof, void *data) +static int proc_bri_info_read(char *page, char **start, off_t off, int count, + int *eof, void *data) { - int len = 0; - unsigned long flags; - xpd_t *xpd = data; - struct BRI_priv_data *priv; + int len = 0; + unsigned long flags; + xpd_t *xpd = data; + struct BRI_priv_data *priv; DBG(PROC, "\n"); if (!xpd) @@ -1609,15 +1633,20 @@ static int proc_bri_info_read(char *page, char **start, off_t off, int count, in BUG_ON(!priv); len += sprintf(page + len, "%05d Layer 1: ", priv->poll_counter); 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', - priv->state_register.bits.v_su_sta, - xhfc_state_name(IS_NT(xpd), priv->state_register.bits.v_su_sta), - priv->state_register.bits.v_su_fr_sync, - priv->state_register.bits.v_su_t2_exp, - priv->state_register.bits.v_su_info0, - priv->state_register.bits.v_g2_g3); + 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', + priv->state_register.bits.v_su_sta, + xhfc_state_name(IS_NT(xpd), + priv->state_register.bits.v_su_sta), + priv->state_register.bits.v_su_fr_sync, + priv->state_register.bits.v_su_t2_exp, + priv->state_register.bits.v_su_info0, + priv->state_register.bits.v_g2_g3); } else len += sprintf(page + len, "Unknown\n"); if (IS_NT(xpd)) { @@ -1626,24 +1655,37 @@ static int proc_bri_info_read(char *page, char **start, off_t off, int count, in len += sprintf(page + len, "T3 Timer: %d\n", priv->t3); } len += sprintf(page + len, "Tick Counter: %d\n", priv->tick_counter); - len += sprintf(page + len, "Last Poll Reply: %d ticks ago\n", priv->reg30_ticks); + len += + sprintf(page + len, "Last Poll Reply: %d ticks ago\n", + priv->reg30_ticks); 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); + 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) { - len += sprintf(page + len, "(alive %d K-ticks)\n", - priv->dchan_alive_ticks/1000); + len += + sprintf(page + len, "(alive %d K-ticks)\n", + priv->dchan_alive_ticks / 1000); } else { len += sprintf(page + len, "(dead)\n"); } - len += sprintf(page + len, "dchan_notx_ticks: %d\n", priv->dchan_notx_ticks); - len += sprintf(page + len, "dchan_norx_ticks: %d\n", priv->dchan_norx_ticks); - len += sprintf(page + len, "LED: %-10s = %d\n", "GREEN", priv->ledstate[GREEN_LED]); - len += sprintf(page + len, "LED: %-10s = %d\n", "RED", priv->ledstate[RED_LED]); + len += + sprintf(page + len, "dchan_notx_ticks: %d\n", + priv->dchan_notx_ticks); + len += + sprintf(page + len, "dchan_norx_ticks: %d\n", + priv->dchan_norx_ticks); + len += + sprintf(page + len, "LED: %-10s = %d\n", "GREEN", + priv->ledstate[GREEN_LED]); + len += + sprintf(page + len, "LED: %-10s = %d\n", "RED", + priv->ledstate[RED_LED]); len += sprintf(page + len, "\nDCHAN:\n"); len += sprintf(page + len, "\n"); spin_unlock_irqrestore(&xpd->lock, flags); - if (len <= off+count) + if (len <= off + count) *eof = 1; *start = page + off; len -= off; @@ -1657,13 +1699,13 @@ static int proc_bri_info_read(char *page, char **start, off_t off, int count, in static int bri_xpd_probe(struct device *dev) { - xpd_t *xpd; + xpd_t *xpd; xpd = dev_to_xpd(dev); /* Is it our device? */ if (xpd->type != XPD_TYPE_BRI) { - XPD_ERR(xpd, "drop suggestion for %s (%d)\n", - dev_name(dev), xpd->type); + XPD_ERR(xpd, "drop suggestion for %s (%d)\n", dev_name(dev), + xpd->type); return -EINVAL; } XPD_DBG(DEVICES, xpd, "SYSFS\n"); @@ -1672,28 +1714,27 @@ static int bri_xpd_probe(struct device *dev) static int bri_xpd_remove(struct device *dev) { - xpd_t *xpd; + xpd_t *xpd; xpd = dev_to_xpd(dev); XPD_DBG(DEVICES, xpd, "SYSFS\n"); return 0; } -static struct xpd_driver bri_driver = { - .type = XPD_TYPE_BRI, - .driver = { - .name = "bri", +static struct xpd_driver bri_driver = { + .type = XPD_TYPE_BRI, + .driver = { + .name = "bri", #ifndef OLD_HOTPLUG_SUPPORT - .owner = THIS_MODULE, + .owner = THIS_MODULE, #endif - .probe = bri_xpd_probe, - .remove = bri_xpd_remove - } + .probe = bri_xpd_probe, + .remove = bri_xpd_remove} }; static int __init card_bri_startup(void) { - int ret; + int ret; if ((ret = xpd_driver_register(&bri_driver.driver)) < 0) return ret; |