[PATCH] dvb: ttpci: fix timeout handling to be save with PREEMPT
[linux-2.6.git] / drivers / media / common / saa7146_core.c
index 77ff229..cd5828b 100644 (file)
@@ -62,13 +62,15 @@ void saa7146_setgpio(struct saa7146_dev *dev, int port, u32 data)
 int saa7146_wait_for_debi_done(struct saa7146_dev *dev, int nobusyloop)
 {
        unsigned long start;
+       int err;
 
        /* wait for registers to be programmed */
        start = jiffies;
        while (1) {
-                if (saa7146_read(dev, MC2) & 2)
-                        break;
-               if (time_after(jiffies, start + HZ/20)) {
+               err = time_after(jiffies, start + HZ/20);
+               if (saa7146_read(dev, MC2) & 2)
+                       break;
+               if (err) {
                        DEB_S(("timed out while waiting for registers getting programmed\n"));
                        return -ETIMEDOUT;
                }
@@ -79,10 +81,11 @@ int saa7146_wait_for_debi_done(struct saa7146_dev *dev, int nobusyloop)
        /* wait for transfer to complete */
        start = jiffies;
        while (1) {
+               err = time_after(jiffies, start + HZ/4);
                if (!(saa7146_read(dev, PSR) & SPCI_DEBI_S))
                        break;
                saa7146_read(dev, MC2);
-               if (time_after(jiffies, start + HZ/4)) {
+               if (err) {
                        DEB_S(("timed out while waiting for transfer completion\n"));
                        return -ETIMEDOUT;
                }