Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs...
[linux-block.git] / drivers / media / video / saa7164 / saa7164-cmd.c
index cd3af4d4364f2020af46698d9314db934269a58d..c45966edc0cf2f202ea4a38e158506390f145f46 100644 (file)
@@ -78,6 +78,43 @@ u32 saa7164_cmd_timeout_get(struct saa7164_dev *dev, u8 seqno)
        return ret;
 }
 
+/* Commands to the f/w get marshelled to/from this code then onto the PCI
+ * -bus/c running buffer. */
+int saa7164_irq_dequeue(struct saa7164_dev *dev)
+{
+       int ret = SAA_OK;
+       u32 timeout;
+       wait_queue_head_t *q = 0;
+       dprintk(DBGLVL_CMD, "%s()\n", __func__);
+
+       /* While any outstand message on the bus exists... */
+       do {
+
+               /* Peek the msg bus */
+               tmComResInfo_t tRsp = { 0, 0, 0, 0, 0, 0 };
+               ret = saa7164_bus_get(dev, &tRsp, NULL, 1);
+               if (ret != SAA_OK)
+                       break;
+
+               q = &dev->cmds[tRsp.seqno].wait;
+               timeout = saa7164_cmd_timeout_get(dev, tRsp.seqno);
+               dprintk(DBGLVL_CMD, "%s() timeout = %d\n", __func__, timeout);
+               if (!timeout) {
+                       dprintk(DBGLVL_CMD,
+                               "%s() signalled seqno(%d) (for dequeue)\n",
+                               __func__, tRsp.seqno);
+                       dev->cmds[tRsp.seqno].signalled = 1;
+                       wake_up(q);
+               } else {
+                       printk(KERN_ERR
+                               "%s() found timed out command on the bus\n",
+                                       __func__);
+               }
+       } while (0);
+
+       return ret;
+}
+
 /* Commands to the f/w get marshelled to/from this code then onto the PCI
  * -bus/c running buffer. */
 int saa7164_cmd_dequeue(struct saa7164_dev *dev)
@@ -213,7 +250,7 @@ int saa7164_cmd_wait(struct saa7164_dev *dev, u8 seqno)
        unsigned long stamp;
        int r;
 
-       if (debug >= 4)
+       if (saa_debug >= 4)
                saa7164_bus_dump(dev);
 
        dprintk(DBGLVL_CMD, "%s(seqno=%d)\n", __func__, seqno);