From a6be60359012260610f616cda20118988529433c Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Wed, 23 Jan 2013 17:16:07 -0600 Subject: [PATCH] wctdm24xxp: Use framecount and not jiffies when looking for battery present. The logic to check for battery lost and battery present were using different time bases. One was using jiffies and the other was using framecount. Since framecount is always in milliseconds, let's use that to stay consistent. Signed-off-by: Shaun Ruffell --- drivers/dahdi/wctdm24xxp/base.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/dahdi/wctdm24xxp/base.c b/drivers/dahdi/wctdm24xxp/base.c index 4c539b3..c782119 100644 --- a/drivers/dahdi/wctdm24xxp/base.c +++ b/drivers/dahdi/wctdm24xxp/base.c @@ -2023,7 +2023,7 @@ wctdm_check_battery_present(struct wctdm *wc, struct wctdm_module *const mod) switch (fxo->battery_state) { case BATTERY_DEBOUNCING_PRESENT: - if (time_after(jiffies, fxo->battdebounce_timer)) { + if (time_after(wc->framecount, fxo->battdebounce_timer)) { if (debug) { dev_info(&wc->vb.pdev->dev, "BATTERY on %d/%d (%s)!\n", @@ -2048,12 +2048,12 @@ wctdm_check_battery_present(struct wctdm *wc, struct wctdm_module *const mod) * of its time period has already passed while * debouncing occurred */ fxo->battery_state = BATTERY_DEBOUNCING_PRESENT_ALARM; - fxo->battdebounce_timer = jiffies + - msecs_to_jiffies(battalarm - battdebounce); + fxo->battdebounce_timer = wc->framecount + + battalarm - battdebounce; } break; case BATTERY_DEBOUNCING_PRESENT_ALARM: - if (time_after(jiffies, fxo->battdebounce_timer)) { + if (time_after(wc->framecount, fxo->battdebounce_timer)) { fxo->battery_state = BATTERY_PRESENT; dahdi_alarm_channel(get_dahdi_chan(wc, mod), DAHDI_ALARM_NONE); @@ -2071,8 +2071,7 @@ wctdm_check_battery_present(struct wctdm *wc, struct wctdm_module *const mod) case BATTERY_LOST: /* intentional drop through */ case BATTERY_DEBOUNCING_LOST_ALARM: fxo->battery_state = BATTERY_DEBOUNCING_PRESENT; - fxo->battdebounce_timer = jiffies + - msecs_to_jiffies(battdebounce); + fxo->battdebounce_timer = wc->framecount + battdebounce; break; } }