[PATCH] USB ATM: robustify poll throttling
authorDuncan Sands <duncan.sands@math.u-psud.fr>
Thu, 23 Jun 2005 07:23:10 +0000 (09:23 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 12 Jul 2005 18:52:55 +0000 (11:52 -0700)
No functional change, but less likely to break in the future.

Signed-off-by: Duncan Sands <baldrick@free.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/atm/speedtch.c

index 992db1c16838ae4c8e53d7cdf46eb2d2e302beca..03a0e99a426722c2f153e980ca2ffadedf1f868f 100644 (file)
@@ -430,13 +430,11 @@ static void speedtch_check_status(struct speedtch_instance_data *instance)
        ret = speedtch_read_status(instance);
        if (ret < 0) {
                atm_warn(usbatm, "error %d fetching device status\n", ret);
-               if (instance->poll_delay < MAX_POLL_DELAY)
-                       instance->poll_delay *= 2;
+               instance->poll_delay = min(2 * instance->poll_delay, MAX_POLL_DELAY);
                return;
        }
 
-       if (instance->poll_delay > MIN_POLL_DELAY)
-               instance->poll_delay /= 2;
+       instance->poll_delay = max(instance->poll_delay / 2, MIN_POLL_DELAY);
 
        atm_dbg(usbatm, "%s: line state %02x\n", __func__, buf[OFFSET_7]);