Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb New function usb_task_pending for diagnostic ass...



details:   https://anonhg.NetBSD.org/src/rev/0aeb164a42ba
branches:  trunk
changeset: 744763:0aeb164a42ba
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Feb 12 15:59:44 2020 +0000

description:
New function usb_task_pending for diagnostic assertions.

Usable only for negative diagnostic assertions:

        KASSERT(!usb_task_pending(dev, task))

If you can think of a better name for this than !usb_task_pending,
I'm all ears.

diffstat:

 sys/dev/usb/usb.c   |  21 +++++++++++++++++++--
 sys/dev/usb/usbdi.h |   3 ++-
 2 files changed, 21 insertions(+), 3 deletions(-)

diffs (59 lines):

diff -r 785d8ecb2eaa -r 0aeb164a42ba sys/dev/usb/usb.c
--- a/sys/dev/usb/usb.c Wed Feb 12 15:59:30 2020 +0000
+++ b/sys/dev/usb/usb.c Wed Feb 12 15:59:44 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usb.c,v 1.181 2020/02/12 15:59:30 riastradh Exp $      */
+/*     $NetBSD: usb.c,v 1.182 2020/02/12 15:59:44 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.181 2020/02/12 15:59:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.182 2020/02/12 15:59:44 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -530,6 +530,23 @@
        return removed;
 }
 
+/*
+ * usb_task_pending(dev, task)
+ *
+ *     True if task is queued, false if not.  Note that if task is
+ *     already running, it is not considered queued.
+ *
+ *     For _negative_ diagnostic assertions only:
+ *
+ *             KASSERT(!usb_task_pending(dev, task));
+ */
+bool
+usb_task_pending(struct usbd_device *dev, struct usb_task *task)
+{
+
+       return task->queue != USB_NUM_TASKQS;
+}
+
 void
 usb_event_thread(void *arg)
 {
diff -r 785d8ecb2eaa -r 0aeb164a42ba sys/dev/usb/usbdi.h
--- a/sys/dev/usb/usbdi.h       Wed Feb 12 15:59:30 2020 +0000
+++ b/sys/dev/usb/usbdi.h       Wed Feb 12 15:59:44 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdi.h,v 1.99 2020/02/12 15:59:30 riastradh Exp $     */
+/*     $NetBSD: usbdi.h,v 1.100 2020/02/12 15:59:44 riastradh Exp $    */
 /*     $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $      */
 
 /*
@@ -225,6 +225,7 @@
 bool usb_rem_task(struct usbd_device *, struct usb_task *);
 bool usb_rem_task_wait(struct usbd_device *, struct usb_task *, int,
     kmutex_t *);
+bool usb_task_pending(struct usbd_device *, struct usb_task *);
 #define usb_init_task(t, f, a, fl) ((t)->fun = (f), (t)->arg = (a), (t)->queue = USB_NUM_TASKQS, (t)->flags = (fl))
 
 struct usb_devno {



Home | Main Index | Thread Index | Old Index