Subject: USB ATM: robustify poll throttling

From: Duncan Sands <[email-masked]>
Date: Thu, 23 Jun 2005 09:23:10 +0200

No functional change, but less likely to break in the future.

Signed-off-by: Duncan Sands <[email-masked]>
Signed-off-by: Greg Kroah-Hartman <[email-masked]>

---
 drivers/usb/atm/speedtch.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

--- gregkh-2.6.orig/drivers/usb/atm/speedtch.c	2005-06-28 13:49:39.000000000 -0700
+++ gregkh-2.6/drivers/usb/atm/speedtch.c	2005-06-28 13:49:42.000000000 -0700
@@ -430,13 +430,11 @@
 	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]);