[media] em28xx-dvb: stop URBs when stopping the streaming
authorGianluca Gennari <gennarone@gmail.com>
Thu, 22 Mar 2012 11:48:17 +0000 (08:48 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 10 Apr 2012 18:46:35 +0000 (15:46 -0300)
Stop the URBs in em28xx_stop_streaming(), so that em28xx_irq_callback()
cannot be called after the streaming has stopped.

This should eliminate the crashes reported by Antti Palosaari and the warnings
reported by Andy Furniss.

Signed-off-by: Gianluca Gennari <gennarone@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/em28xx/em28xx-core.c
drivers/media/video/em28xx/em28xx-dvb.c
drivers/media/video/em28xx/em28xx.h

index 53a9fb91e97ed893038c82db78714135816028b4..cbbe399bc77f1f827d42fd53fcd82135a1a72aac 100644 (file)
@@ -666,7 +666,6 @@ int em28xx_capture_start(struct em28xx *dev, int start)
 
        return rc;
 }
-EXPORT_SYMBOL_GPL(em28xx_capture_start);
 
 int em28xx_vbi_supported(struct em28xx *dev)
 {
@@ -1007,6 +1006,31 @@ void em28xx_uninit_isoc(struct em28xx *dev, enum em28xx_mode mode)
 }
 EXPORT_SYMBOL_GPL(em28xx_uninit_isoc);
 
+/*
+ * Stop URBs
+ */
+void em28xx_stop_urbs(struct em28xx *dev)
+{
+       int i;
+       struct urb *urb;
+       struct em28xx_usb_isoc_bufs *isoc_bufs = &dev->isoc_ctl.digital_bufs;
+
+       em28xx_isocdbg("em28xx: called em28xx_stop_urbs\n");
+
+       for (i = 0; i < isoc_bufs->num_bufs; i++) {
+               urb = isoc_bufs->urb[i];
+               if (urb) {
+                       if (!irqs_disabled())
+                               usb_kill_urb(urb);
+                       else
+                               usb_unlink_urb(urb);
+               }
+       }
+
+       em28xx_capture_start(dev, 0);
+}
+EXPORT_SYMBOL_GPL(em28xx_stop_urbs);
+
 /*
  * Allocate URBs
  */
index 503a8d5b5382b018ab1e3329569a401325608a27..2d73ee2abf7e8ba25a6b47b5c1c30db03f2382a1 100644 (file)
@@ -183,7 +183,7 @@ static int em28xx_stop_streaming(struct em28xx_dvb *dvb)
 {
        struct em28xx *dev = dvb->adapter.priv;
 
-       em28xx_capture_start(dev, 0);
+       em28xx_stop_urbs(dev);
 
        em28xx_set_mode(dev, EM28XX_SUSPEND);
 
index 2868b19f8b54e9646f12ecd09e55c592f397a5dc..286b9f8b0022d5372217b4faede4005899d1e038 100644 (file)
@@ -695,6 +695,7 @@ int em28xx_init_isoc(struct em28xx *dev, enum em28xx_mode mode,
                     int max_packets, int num_bufs, int max_pkt_size,
                     int (*isoc_copy) (struct em28xx *dev, struct urb *urb));
 void em28xx_uninit_isoc(struct em28xx *dev, enum em28xx_mode mode);
+void em28xx_stop_urbs(struct em28xx *dev);
 int em28xx_isoc_dvb_max_packetsize(struct em28xx *dev);
 int em28xx_set_mode(struct em28xx *dev, enum em28xx_mode set_mode);
 int em28xx_gpio_set(struct em28xx *dev, struct em28xx_reg_seq *gpio);