Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb Teach usb_rem_task to return whether removed fro...



details:   https://anonhg.NetBSD.org/src/rev/0583d795fa87
branches:  trunk
changeset: 1007263:0583d795fa87
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Feb 12 15:59:30 2020 +0000

description:
Teach usb_rem_task to return whether removed from queue or not.

diffstat:

 sys/dev/usb/usb.c   |  14 +++++++++-----
 sys/dev/usb/usbdi.h |   4 ++--
 2 files changed, 11 insertions(+), 7 deletions(-)

diffs (69 lines):

diff -r c47acb03fa8d -r 0583d795fa87 sys/dev/usb/usb.c
--- a/sys/dev/usb/usb.c Wed Feb 12 09:43:19 2020 +0000
+++ b/sys/dev/usb/usb.c Wed Feb 12 15:59:30 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usb.c,v 1.180 2019/08/21 10:48:37 mrg Exp $    */
+/*     $NetBSD: usb.c,v 1.181 2020/02/12 15:59:30 riastradh Exp $      */
 
 /*
  * Copyright (c) 1998, 2002, 2008, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.180 2019/08/21 10:48:37 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.181 2020/02/12 15:59:30 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -431,14 +431,16 @@
 /*
  * usb_rem_task(dev, task)
  *
- *     If task is queued to run, remove it from the queue.
+ *     If task is queued to run, remove it from the queue.  Return
+ *     true if it successfully removed the task from the queue, false
+ *     if not.
  *
  *     Caller is _not_ guaranteed that the task is not running when
  *     this is done.
  *
  *     Never sleeps.
  */
-void
+bool
 usb_rem_task(struct usbd_device *dev, struct usb_task *task)
 {
        unsigned queue;
@@ -452,10 +454,12 @@
                        TAILQ_REMOVE(&taskq->tasks, task, next);
                        task->queue = USB_NUM_TASKQS;
                        mutex_exit(&taskq->lock);
-                       break;
+                       return true; /* removed from the queue */
                }
                mutex_exit(&taskq->lock);
        }
+
+       return false;           /* was not removed from the queue */
 }
 
 /*
diff -r c47acb03fa8d -r 0583d795fa87 sys/dev/usb/usbdi.h
--- a/sys/dev/usb/usbdi.h       Wed Feb 12 09:43:19 2020 +0000
+++ b/sys/dev/usb/usbdi.h       Wed Feb 12 15:59:30 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdi.h,v 1.98 2020/02/08 07:38:17 maxv Exp $  */
+/*     $NetBSD: usbdi.h,v 1.99 2020/02/12 15:59:30 riastradh Exp $     */
 /*     $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $      */
 
 /*
@@ -222,7 +222,7 @@
 #define        USB_TASKQ_MPSAFE        0x80
 
 void usb_add_task(struct usbd_device *, struct usb_task *, int);
-void usb_rem_task(struct usbd_device *, struct usb_task *);
+bool usb_rem_task(struct usbd_device *, struct usb_task *);
 bool usb_rem_task_wait(struct usbd_device *, struct usb_task *, int,
     kmutex_t *);
 #define usb_init_task(t, f, a, fl) ((t)->fun = (f), (t)->arg = (a), (t)->queue = USB_NUM_TASKQS, (t)->flags = (fl))



Home | Main Index | Thread Index | Old Index