treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157
[sfrench/cifs-2.6.git] / drivers / media / usb / gspca / gspca.c
index ac70b36d67b7bf9001eb64378b7e4721a8c21d77..a7ed5257cdba3afcf36287caf1c845ff3da76bc4 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Main USB camera driver
  *
@@ -5,16 +6,6 @@
  *
  * Camera button input handling by Márton Németh
  * Copyright (C) 2009-2010 Márton Németh <nm127@freemail.hu>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * for more details.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -294,7 +285,7 @@ static void fill_frame(struct gspca_dev *gspca_dev,
                /* check the packet status and length */
                st = urb->iso_frame_desc[i].status;
                if (st) {
-                       pr_err("ISOC data error: [%d] len=%d, status=%d\n",
+                       gspca_dbg(gspca_dev, D_PACK, "ISOC data error: [%d] len=%d, status=%d\n",
                               i, len, st);
                        gspca_dev->last_packet_type = DISCARD_PACKET;
                        continue;
@@ -314,6 +305,8 @@ static void fill_frame(struct gspca_dev *gspca_dev,
        }
 
 resubmit:
+       if (!gspca_dev->streaming)
+               return;
        /* resubmit the URB */
        st = usb_submit_urb(urb, GFP_ATOMIC);
        if (st < 0)
@@ -330,7 +323,7 @@ static void isoc_irq(struct urb *urb)
        struct gspca_dev *gspca_dev = (struct gspca_dev *) urb->context;
 
        gspca_dbg(gspca_dev, D_PACK, "isoc irq\n");
-       if (!vb2_start_streaming_called(&gspca_dev->queue))
+       if (!gspca_dev->streaming)
                return;
        fill_frame(gspca_dev, urb);
 }
@@ -344,7 +337,7 @@ static void bulk_irq(struct urb *urb)
        int st;
 
        gspca_dbg(gspca_dev, D_PACK, "bulk irq\n");
-       if (!vb2_start_streaming_called(&gspca_dev->queue))
+       if (!gspca_dev->streaming)
                return;
        switch (urb->status) {
        case 0:
@@ -367,6 +360,8 @@ static void bulk_irq(struct urb *urb)
                                urb->actual_length);
 
 resubmit:
+       if (!gspca_dev->streaming)
+               return;
        /* resubmit the URB */
        if (gspca_dev->cam.bulk_nurbs != 0) {
                st = usb_submit_urb(urb, GFP_ATOMIC);
@@ -1638,6 +1633,8 @@ void gspca_disconnect(struct usb_interface *intf)
 
        mutex_lock(&gspca_dev->usb_lock);
        gspca_dev->present = false;
+       destroy_urbs(gspca_dev);
+       gspca_input_destroy_urb(gspca_dev);
 
        vb2_queue_error(&gspca_dev->queue);