V4L/DVB (13375): cx23885: Add support for Mygica X8558Pro DMB-TH
[safe/jmp/linux-2.6] / drivers / media / video / s2255drv.c
index f08939c..d0824f3 100644 (file)
@@ -48,6 +48,7 @@
 #include <linux/videodev2.h>
 #include <linux/version.h>
 #include <linux/mm.h>
+#include <linux/smp_lock.h>
 #include <media/videobuf-vmalloc.h>
 #include <media/v4l2-common.h>
 #include <media/v4l2-ioctl.h>
@@ -597,11 +598,6 @@ static int s2255_got_frame(struct s2255_dev *dev, int chn, int jpgsize)
        buf = list_entry(dma_q->active.next,
                         struct s2255_buffer, vb.queue);
 
-       if (!waitqueue_active(&buf->vb.done)) {
-               /* no one active */
-               rc = -1;
-               goto unlock;
-       }
        list_del(&buf->vb.queue);
        do_gettimeofday(&buf->vb.ts);
        dprintk(100, "[%p/%d] wakeup\n", buf, buf->vb.i);
@@ -1962,7 +1958,7 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
                                if (pdword[1] >= MAX_CHANNELS)
                                        break;
                                cc = G_chnmap[pdword[1]];
-                               if (!(cc >= 0 && cc < MAX_CHANNELS))
+                               if (cc >= MAX_CHANNELS)
                                        break;
                                switch (pdword[2]) {
                                case S2255_RESPONSE_SETMODE:
@@ -2281,8 +2277,10 @@ static void read_pipe_completion(struct urb *purb)
                return;
        }
        status = purb->status;
-       if (status != 0) {
-               dprintk(2, "read_pipe_completion: err\n");
+       /* if shutting down, do not resubmit, exit immediately */
+       if (status == -ESHUTDOWN) {
+               dprintk(2, "read_pipe_completion: err shutdown\n");
+               pipe_info->err_count++;
                return;
        }
 
@@ -2291,9 +2289,13 @@ static void read_pipe_completion(struct urb *purb)
                return;
        }
 
-       s2255_read_video_callback(dev, pipe_info);
+       if (status == 0)
+               s2255_read_video_callback(dev, pipe_info);
+       else {
+               pipe_info->err_count++;
+               dprintk(1, "s2255drv: failed URB %d\n", status);
+       }
 
-       pipe_info->err_count = 0;
        pipe = usb_rcvbulkpipe(dev->udev, dev->read_endpoint);
        /* reuse urb */
        usb_fill_bulk_urb(pipe_info->stream_urb, dev->udev,
@@ -2305,7 +2307,6 @@ static void read_pipe_completion(struct urb *purb)
        if (pipe_info->state != 0) {
                if (usb_submit_urb(pipe_info->stream_urb, GFP_KERNEL)) {
                        dev_err(&dev->udev->dev, "error submitting urb\n");
-                       usb_free_urb(pipe_info->stream_urb);
                }
        } else {
                dprintk(2, "read pipe complete state 0\n");