wctdm24xxp: Use framecount and not jiffies when looking for battery present.
authorShaun Ruffell <sruffell@digium.com>
Wed, 23 Jan 2013 23:16:07 +0000 (17:16 -0600)
committerRuss Meyerriecks <rmeyerriecks@digium.com>
Fri, 25 Jan 2013 19:12:50 +0000 (13:12 -0600)
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 <sruffell@digium.com>
(cherry picked from commit a6be60359012260610f616cda20118988529433c)

drivers/dahdi/wctdm24xxp/base.c

index ddf45ef..1003448 100644 (file)
@@ -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;
        }
 }