From 41639330a59ea683cca0f6215a207a59a93f95bd Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Thu, 24 Jan 2013 11:37:29 -0600 Subject: [PATCH] wctdm24xxp: Eliminate chance for channel to be stuck in RED alarm. There was a code patch where it was possible to get stuck in RED ALARM on a channel when debouncing the battery states. The state transitions would look like this: BATTERY_PRESENT -> BATTERY_DEBOUNCING_LOST -> BATTERY_DEBOUNCING_LOST_ALARM -- (send alarm up to asterisk) --> BATTERY_LOST -> BATTERY_DEBOUNCING_PRESENT -> BATTERY_DEBOUNCING_PRESENT_ALARM -> BATTERY_DEBOUNCING_LOST -> BATTERY_PRESENT In the above sequence there was never any transition from BATTERY_DEBOUNCING_PRESENT_ALARM to BATTERY_PRESENT so the alarm to Asterisk was never cleared and the channel stayed stuck. Now when you loose battery when in the BATTERY_DEBOUNCING_PRESENT_ALARM go all the way back to the BATTERY_LOST state instead of the BATTERY_DEBOUNCING_LOST state so that all the events are properly sent up. This fixes a regression introduced in 2.6.0 with commit (r10169 "wctdm24xxp: Use interval for debouncing FXO battery." 874b76bd223313e22a773725be63c1b4b64cb274). Internal-Issue-ID: DAHDI-1019 Signed-off-by: Shaun Ruffell (cherry picked from commit 8bf04348963b440b57e308fdec6cc57c64fcdd3f) --- drivers/dahdi/wctdm24xxp/base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dahdi/wctdm24xxp/base.c b/drivers/dahdi/wctdm24xxp/base.c index 1003448..b89e66d 100644 --- a/drivers/dahdi/wctdm24xxp/base.c +++ b/drivers/dahdi/wctdm24xxp/base.c @@ -1962,13 +1962,13 @@ wctdm_check_battery_lost(struct wctdm *wc, struct wctdm_module *const mod) */ switch (fxo->battery_state) { case BATTERY_DEBOUNCING_PRESENT: + case BATTERY_DEBOUNCING_PRESENT_ALARM: /* intentional drop through */ /* we were going to BATTERY_PRESENT, but * battery was lost again. */ fxo->battery_state = BATTERY_LOST; break; case BATTERY_UNKNOWN: mod_hooksig(wc, mod, DAHDI_RXSIG_ONHOOK); - case BATTERY_DEBOUNCING_PRESENT_ALARM: /* intentional drop through */ case BATTERY_PRESENT: fxo->battery_state = BATTERY_DEBOUNCING_LOST; fxo->battdebounce_timer = wc->framecount + battdebounce; @@ -2062,6 +2062,7 @@ wctdm_check_battery_present(struct wctdm *wc, struct wctdm_module *const mod) case BATTERY_PRESENT: break; case BATTERY_DEBOUNCING_LOST: + case BATTERY_DEBOUNCING_LOST_ALARM: /* we were going to BATTERY_LOST, but battery appeared again, * so clear the debounce timer */ fxo->battery_state = BATTERY_PRESENT; @@ -2069,7 +2070,6 @@ wctdm_check_battery_present(struct wctdm *wc, struct wctdm_module *const mod) case BATTERY_UNKNOWN: mod_hooksig(wc, mod, DAHDI_RXSIG_OFFHOOK); case BATTERY_LOST: /* intentional drop through */ - case BATTERY_DEBOUNCING_LOST_ALARM: fxo->battery_state = BATTERY_DEBOUNCING_PRESENT; fxo->battdebounce_timer = wc->framecount + battdebounce; break;