patch from Ian Abbott <abbotti@mev.co.uk>:
authorFrank Mori Hess <fmhess@speakeasy.net>
Thu, 17 Feb 2005 22:48:11 +0000 (22:48 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Thu, 17 Feb 2005 22:48:11 +0000 (22:48 +0000)
This patch improves the "early exit" test in the
i8253_cascade_ns_to_timer_2div function (comedi/drivers/8253.h) to take
account of a divisor of 65536 being represented by 0.

comedi/drivers/8253.h

index 734f7f77a8bb6e8fb20053d1c5a2ef90a4ff4e1c..97066b712839d0727e6a6fd31769e89fb26ddfde 100644 (file)
@@ -131,9 +131,11 @@ static inline void i8253_cascade_ns_to_timer_2div(int i8253_osc_base,
        /* exit early if everything is already correct (this can save time
         * since this function may be called repeatedly during command tests
         * and execution) */
-       if(*d1 * *d2 * i8253_osc_base == *nanosec &&
-               *d1 > 1 && *d1 < 0x10000 &&
-               *d2 > 1 && *d2 < 0x10000)
+       div1 = *d1 ? *d1 : 0x10000;
+       div2 = *d2 ? *d2 : 0x10000;
+       if(div1 * div2 * i8253_osc_base == *nanosec &&
+               div1 > 1 && div1 <= 0x10000 &&
+               div2 > 1 && div2 <= 0x10000)
        {
                return;
        }