viafb: returns 0 two too early
authorRoel Kluin <roel.kluin@gmail.com>
Tue, 31 Mar 2009 22:25:36 +0000 (15:25 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 1 Apr 2009 15:59:32 +0000 (08:59 -0700)
Otherwise this will already return 0 if iteration MAXLOOP-2 occurs in the
first loop.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Cc: Joseph Chan <josephchan@via.com.tw>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/video/via/accel.c

index 632523f..45c54bf 100644 (file)
@@ -267,13 +267,17 @@ int viafb_wait_engine_idle(void)
        int loop = 0;
 
        while (!(readl(viaparinfo->io_virt + VIA_REG_STATUS) &
-                       VIA_VR_QUEUE_BUSY) && (loop++ < MAXLOOP))
+                       VIA_VR_QUEUE_BUSY) && (loop < MAXLOOP)) {
+               loop++;
                cpu_relax();
+       }
 
        while ((readl(viaparinfo->io_virt + VIA_REG_STATUS) &
                    (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY | VIA_3D_ENG_BUSY)) &&
-                   (loop++ < MAXLOOP))
+                   (loop < MAXLOOP)) {
+               loop++;
                cpu_relax();
+       }
 
        return loop >= MAXLOOP;
 }