diff --git a/drivers/dahdi/wctdm24xxp/base.c b/drivers/dahdi/wctdm24xxp/base.c index df4b325..20e417d 100644 --- a/drivers/dahdi/wctdm24xxp/base.c +++ b/drivers/dahdi/wctdm24xxp/base.c @@ -1961,19 +1961,26 @@ wctdm_check_battery_lost(struct wctdm *wc, struct wctdm_module *const mod) battery present or unknown, debounce timer (going to battery lost) */ switch (fxo->battery_state) { + case BATTERY_DEBOUNCING_PRESENT_ALARM: + fxo->battery_state = BATTERY_DEBOUNCING_LOST_FROM_PRESENT_ALARM; + fxo->battdebounce_timer = wc->framecount + battdebounce; + break; 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_DEBOUNCING_PRESENT_FROM_LOST_ALARM: + fxo->battery_state = BATTERY_DEBOUNCING_LOST_ALARM; + fxo->battdebounce_timer = wc->framecount + + battalarm - battdebounce; + break; case BATTERY_UNKNOWN: mod_hooksig(wc, mod, DAHDI_RXSIG_ONHOOK); case BATTERY_PRESENT: fxo->battery_state = BATTERY_DEBOUNCING_LOST; fxo->battdebounce_timer = wc->framecount + battdebounce; break; - case BATTERY_DEBOUNCING_LOST: + case BATTERY_DEBOUNCING_LOST_FROM_PRESENT_ALARM: + case BATTERY_DEBOUNCING_LOST: /* Intentional drop through */ if (time_after(wc->framecount, fxo->battdebounce_timer)) { if (debug) { dev_info(&wc->vb.pdev->dev, @@ -2022,7 +2029,8 @@ wctdm_check_battery_present(struct wctdm *wc, struct wctdm_module *const mod) struct fxo *const fxo = &mod->mod.fxo; switch (fxo->battery_state) { - case BATTERY_DEBOUNCING_PRESENT: + case BATTERY_DEBOUNCING_PRESENT_FROM_LOST_ALARM: + case BATTERY_DEBOUNCING_PRESENT: /* intentional drop through */ if (time_after(wc->framecount, fxo->battdebounce_timer)) { if (debug) { dev_info(&wc->vb.pdev->dev, @@ -2061,10 +2069,16 @@ wctdm_check_battery_present(struct wctdm *wc, struct wctdm_module *const mod) break; 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_DEBOUNCING_PRESENT_FROM_LOST_ALARM; + fxo->battdebounce_timer = wc->framecount + battdebounce; + break; + case BATTERY_DEBOUNCING_LOST_FROM_PRESENT_ALARM: + fxo->battery_state = BATTERY_DEBOUNCING_PRESENT_ALARM; + fxo->battdebounce_timer = wc->framecount + + battalarm - battdebounce; + break; + case BATTERY_DEBOUNCING_LOST: fxo->battery_state = BATTERY_PRESENT; break; case BATTERY_UNKNOWN: diff --git a/drivers/dahdi/wctdm24xxp/wctdm24xxp.h b/drivers/dahdi/wctdm24xxp/wctdm24xxp.h index 78e555c..af30662 100644 --- a/drivers/dahdi/wctdm24xxp/wctdm24xxp.h +++ b/drivers/dahdi/wctdm24xxp/wctdm24xxp.h @@ -106,9 +106,11 @@ struct calregs { enum battery_state { BATTERY_UNKNOWN = 0, BATTERY_DEBOUNCING_PRESENT, + BATTERY_DEBOUNCING_PRESENT_FROM_LOST_ALARM, BATTERY_DEBOUNCING_PRESENT_ALARM, BATTERY_PRESENT, BATTERY_DEBOUNCING_LOST, + BATTERY_DEBOUNCING_LOST_FROM_PRESENT_ALARM, BATTERY_DEBOUNCING_LOST_ALARM, BATTERY_LOST, };