diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2013-04-26 14:05:25 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2013-04-26 14:05:25 +0000 |
commit | 7a6b14da314b0633c70619ddf9610b1cdad7cba0 (patch) | |
tree | 02a63ce45c3d5fe9f1edff2abae7be2fc3c0d9a7 /sys/dev/usb | |
parent | c510b7bcbffb292d898d642ed97ccd4e6aacb410 (diff) |
Give back to usb(4) what is usb(4)'s. In other words use the usb_* prefix
for functions related to the usb(4) driver and keep usbd_* for generic
USB layer functions.
ok mglocker@
Diffstat (limited to 'sys/dev/usb')
-rw-r--r-- | sys/dev/usb/usb.c | 49 | ||||
-rw-r--r-- | sys/dev/usb/usbdi.c | 24 | ||||
-rw-r--r-- | sys/dev/usb/usbdivar.h | 7 |
3 files changed, 23 insertions, 57 deletions
diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c index 3c85e99fdc6..2ed661666d7 100644 --- a/sys/dev/usb/usb.c +++ b/sys/dev/usb/usb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usb.c,v 1.89 2013/04/19 19:07:45 mglocker Exp $ */ +/* $OpenBSD: usb.c,v 1.90 2013/04/26 14:05:24 mpi Exp $ */ /* $NetBSD: usb.c,v 1.77 2003/01/01 00:10:26 thorpej Exp $ */ /* @@ -54,6 +54,7 @@ #include <sys/selinfo.h> #include <sys/signalvar.h> #include <sys/time.h> +#include <sys/rwlock.h> #include <dev/usb/usb.h> #include <dev/usb/usbdi.h> @@ -97,11 +98,14 @@ struct usb_softc { struct timeval sc_ptime; }; +struct rwlock usbpalock; + TAILQ_HEAD(, usb_task) usb_abort_tasks; TAILQ_HEAD(, usb_task) usb_explore_tasks; TAILQ_HEAD(, usb_task) usb_generic_tasks; -int usb_run_tasks, usb_run_abort_tasks; +static int usb_nbuses = 0; +static int usb_run_tasks, usb_run_abort_tasks; int explore_pending; const char *usbrev_str[] = USBREV_STR; @@ -151,7 +155,16 @@ usb_attach(struct device *parent, struct device *self, void *aux) DPRINTF(("usbd_attach\n")); - usbd_init(); + if (usb_nbuses == 0) { + rw_init(&usbpalock, "usbpalock"); + TAILQ_INIT(&usb_abort_tasks); + TAILQ_INIT(&usb_explore_tasks); + TAILQ_INIT(&usb_generic_tasks); + usb_run_tasks = usb_run_abort_tasks = 1; + kthread_create_deferred(usb_create_task_threads, NULL); + } + usb_nbuses++; + sc->sc_bus = aux; sc->sc_bus->usbctl = self; sc->sc_port.power = USB_MAX_POWER; @@ -230,30 +243,6 @@ usb_attach(struct device *parent, struct device *self, void *aux) } } -/* - * Called by usbd_init when first usb is attached. - */ -void -usb_begin_tasks(void) -{ - TAILQ_INIT(&usb_abort_tasks); - TAILQ_INIT(&usb_explore_tasks); - TAILQ_INIT(&usb_generic_tasks); - usb_run_tasks = usb_run_abort_tasks = 1; - kthread_create_deferred(usb_create_task_threads, NULL); -} - -/* - * Called by usbd_finish when last usb is detached. - */ -void -usb_end_tasks(void) -{ - usb_run_tasks = usb_run_abort_tasks = 0; - wakeup(&usb_run_abort_tasks); - wakeup(&usb_run_tasks); -} - void usb_create_task_threads(void *arg) { @@ -912,7 +901,11 @@ usb_detach(struct device *self, int flags) usb_rem_wait_task(sc->sc_bus->root_hub, &sc->sc_explore_task); - usbd_finish(); + if (--usb_nbuses == 0) { + usb_run_tasks = usb_run_abort_tasks = 0; + wakeup(&usb_run_abort_tasks); + wakeup(&usb_run_tasks); + } } if (sc->sc_bus->soft != NULL) { diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c index 406300c21a5..7fdec250bf9 100644 --- a/sys/dev/usb/usbdi.c +++ b/sys/dev/usb/usbdi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usbdi.c,v 1.53 2013/04/26 13:46:40 mglocker Exp $ */ +/* $OpenBSD: usbdi.c,v 1.54 2013/04/26 14:05:24 mpi Exp $ */ /* $NetBSD: usbdi.c,v 1.103 2002/09/27 15:37:38 provos Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */ @@ -37,7 +37,6 @@ #include <sys/kernel.h> #include <sys/device.h> #include <sys/malloc.h> -#include <sys/rwlock.h> #include <machine/bus.h> @@ -62,27 +61,6 @@ void usbd_start_next(struct usbd_pipe *pipe); usbd_status usbd_open_pipe_ival(struct usbd_interface *, u_int8_t, u_int8_t, struct usbd_pipe **, int); -int usbd_nbuses = 0; - -struct rwlock usbpalock; - -void -usbd_init(void) -{ - if (usbd_nbuses == 0) { - rw_init(&usbpalock, "usbpalock"); - usb_begin_tasks(); - } - usbd_nbuses++; -} - -void -usbd_finish(void) -{ - if (--usbd_nbuses == 0) - usb_end_tasks(); -} - int usbd_is_dying(struct usbd_device *dev) { diff --git a/sys/dev/usb/usbdivar.h b/sys/dev/usb/usbdivar.h index 3e5da437858..619573fa2c3 100644 --- a/sys/dev/usb/usbdivar.h +++ b/sys/dev/usb/usbdivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: usbdivar.h,v 1.48 2013/04/19 08:58:53 mpi Exp $ */ +/* $OpenBSD: usbdivar.h,v 1.49 2013/04/26 14:05:24 mpi Exp $ */ /* $NetBSD: usbdivar.h,v 1.70 2002/07/11 21:14:36 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $ */ @@ -214,11 +214,6 @@ struct usbd_xfer { struct timeout timeout_handle; }; -void usbd_init(void); -void usbd_finish(void); -void usb_begin_tasks(void); -void usb_end_tasks(void); - #ifdef USB_DEBUG void usbd_dump_iface(struct usbd_interface *iface); void usbd_dump_device(struct usbd_device *dev); |