Thu Mar 5 21:13:48 2015 UTC ()
Write the loops the same way, leaving i containing the number of tries
left. Also break early in the hot case.


(christos)
diff -r1.12 -r1.13 src/sys/external/bsd/drm2/dist/drm/i915/intel_i2c.c

cvs diff -r1.12 -r1.13 src/sys/external/bsd/drm2/dist/drm/i915/Attic/intel_i2c.c (expand / switch to context diff)
--- src/sys/external/bsd/drm2/dist/drm/i915/Attic/intel_i2c.c 2015/03/02 23:05:03 1.12
+++ src/sys/external/bsd/drm2/dist/drm/i915/Attic/intel_i2c.c 2015/03/05 21:13:48 1.13
@@ -287,14 +287,15 @@
 #ifdef __NetBSD__
 	if (cold) {
 		i = 50;
-		while (gmbus2 = I915_READ_NOTRACE(GMBUS2 + reg_offset),
-		    !ISSET(gmbus2, (GMBUS_SATOER | gmbus2_status))) {
-			if (i-- == 0)
+		do {
+			gmbus2 = I915_READ_NOTRACE(GMBUS2 + reg_offset);
+			if (ISSET(gmbus2, (GMBUS_SATOER | gmbus2_status)))
 				break;
 			DELAY(1000);
-		}
+		} while (i-- > 0);
 	} else {
-		for (i = 0; i < mstohz(50); i++) {
+		i = mstohz(50);
+		do {
 			int ret;
 
 			spin_lock(&dev_priv->gmbus_wait_lock);
@@ -306,7 +307,9 @@
 				ISSET(gmbus2,
 				    (GMBUS_SATOER | gmbus2_status))));
 			spin_unlock(&dev_priv->gmbus_wait_lock);
-		}
+			if (ret)
+				break;
+		} while (i-- > 0);
 	}
 #else
 	for (i = 0; i < msecs_to_jiffies_timeout(50); i++) {