From 7eb1d995c2442284e4d6bda3abb3a4381af35d60 Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Mon, 1 Mar 2010 08:14:22 +0000 Subject: wcte12xp: Increase a few timeouts, and cleanup on timeout. Also, check for good frames as the wctdm24xxp driver does now. git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@8178 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/wcte12xp/base.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c index 09978b1..27a44cf 100644 --- a/drivers/dahdi/wcte12xp/base.c +++ b/drivers/dahdi/wcte12xp/base.c @@ -575,8 +575,11 @@ static int t1_getreg(struct t1 *wc, int addr) cmd->data = 0x00; cmd->flags = __CMD_RD; submit_cmd(wc, cmd); - ret = wait_for_completion_timeout(&cmd->complete, HZ/5); + ret = wait_for_completion_timeout(&cmd->complete, HZ*2); if (unlikely(!ret)) { + spin_lock_bh(&wc->cmd_list_lock); + list_del(&cmd->node); + spin_unlock_bh(&wc->cmd_list_lock); if (printk_ratelimit()) { dev_warn(&wc->vb.pdev->dev, "Timeout in %s\n", __func__); @@ -615,8 +618,11 @@ static inline int t1_getpins(struct t1 *wc, int inisr) cmd->data = 0x00; cmd->flags = __CMD_PINS; submit_cmd(wc, cmd); - ret = wait_for_completion_timeout(&cmd->complete, HZ/5); + ret = wait_for_completion_timeout(&cmd->complete, HZ*2); if (unlikely(!ret)) { + spin_lock_bh(&wc->cmd_list_lock); + list_del(&cmd->node); + spin_unlock_bh(&wc->cmd_list_lock); if (printk_ratelimit()) { dev_warn(&wc->vb.pdev->dev, "Timeout in %s\n", __func__); @@ -1697,11 +1703,25 @@ static inline void t1_transmitprep(struct t1 *wc, u8 *writechunk) } } +/** + * is_good_frame() - Whether the SFRAME received was one sent. + * + */ +static inline bool is_good_frame(const u8 *sframe) +{ + const u8 a = sframe[0*(EFRAME_SIZE+EFRAME_GAP) + (EFRAME_SIZE+1)]; + const u8 b = sframe[1*(EFRAME_SIZE+EFRAME_GAP) + (EFRAME_SIZE+1)]; + return a != b; +} + static inline void t1_receiveprep(struct t1 *wc, const u8* readchunk) { int x,chan; unsigned char expected; + if (!is_good_frame(readchunk)) + return; + for (x = 0; x < DAHDI_CHUNKSIZE; x++) { if (likely(test_bit(INITIALIZED, &wc->bit_flags))) { for (chan = 0; chan < wc->span.channels; chan++) { -- cgit v1.2.3