[PATCH] bttv: fix dst i2c read/write timeout failure.
authorManu Abraham <manu@kromtek.com>
Thu, 5 May 2005 23:16:01 +0000 (16:16 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Thu, 5 May 2005 23:36:44 +0000 (16:36 -0700)
Attached is a patch to bttv which fixes the following problems.

Affected cards and problems:
~~~~~~~~~~~~~~~~~~~~~~~~
o VP-1020 (200103A) Tuning problems, device detection.
o VP-1020 (DST-MOT) Errors during tuning, device detection fails in a while.
o VP-1030 (DST-CI) Tuning sometimes fails after CI commands.
o VP-2031 (DCT-CI) Tuning problems

The timeout happens before the actual timeout occured in the MCU
on the board, and hence the problems.

Changes: (bttv-i2c.diff)
~~~~~~~~~~~~~~~~~~~~~~~~
o Changed the custom wait queue to wait_event_interruptible_timeout()
      - Suggestion by Johannes Stezenbach.

o Fixed the wait queue timeout problem
      - This fixes the timeout problem on various cards.
      - This problem was visible as many
          * Cannot tune to channels, when signal levels are very low.
          * app_info does not work in some conditions for CI based cards
      - Smaller values worked good for newer cards, but the older cards
suffered, settled down to the worst case values that could happen in any
eventuality.

Signed-off-by: Manu Abraham <manu@kromtek.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/media/video/bttv-i2c.c

index e42f1ec13f3e66900d1e08546d1e4f7b38d591f3..e3f477dff82782d865d2cd5173308a2381aae230 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/delay.h>
+#include <linux/jiffies.h>
 #include <asm/io.h>
 
 #include "bttvp.h"
@@ -130,17 +131,14 @@ static u32 functionality(struct i2c_adapter *adap)
 static int
 bttv_i2c_wait_done(struct bttv *btv)
 {
-       DECLARE_WAITQUEUE(wait, current);
        int rc = 0;
 
-       add_wait_queue(&btv->i2c_queue, &wait);
-       if (0 == btv->i2c_done)
-               msleep_interruptible(20);
-       remove_wait_queue(&btv->i2c_queue, &wait);
+       /* timeout */
+       if (wait_event_interruptible_timeout(btv->i2c_queue,
+               btv->i2c_done, msecs_to_jiffies(85)) == -ERESTARTSYS)
+
+       rc = -EIO;
 
-       if (0 == btv->i2c_done)
-               /* timeout */
-               rc = -EIO;
        if (btv->i2c_done & BT848_INT_RACK)
                rc = 1;
        btv->i2c_done = 0;