diff options
-rw-r--r-- | sys/dev/usb/usb.c | 53 |
1 files changed, 14 insertions, 39 deletions
diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c index 8c8c7cc..545d35c 100644 --- a/sys/dev/usb/usb.c +++ b/sys/dev/usb/usb.c @@ -1,4 +1,4 @@ -/* $NetBSD: usb.c,v 1.38 2000/02/02 07:33:59 augustss Exp $ */ +/* $NetBSD: usb.c,v 1.37 2000/01/24 18:35:51 thorpej Exp $ */ /* $FreeBSD$ */ /* @@ -163,7 +163,6 @@ Static int usb_nevents = 0; Static struct selinfo usb_selevent; Static struct proc *usb_async_proc; /* process that wants USB SIGIO */ Static int usb_dev_open = 0; -Static void usb_add_event(int, struct usb_event *); Static int usb_get_next_event(struct usb_event *); @@ -202,7 +201,6 @@ USB_ATTACH(usb) usbd_device_handle dev; usbd_status err; int usbrev; - struct usb_event ue; sc->sc_dev = self; @@ -228,9 +226,6 @@ USB_ATTACH(usb) if (cold) sc->sc_bus->use_polling++; - ue.u.ue_ctrlr.ue_bus = USBDEVUNIT(sc->sc_dev); - usb_add_event(USB_EVENT_CTRLR_ATTACH, &ue); - err = usbd_new_device(USBDEV(sc->sc_dev), sc->sc_bus, 0, 0, 0, &sc->sc_port); if (!err) { @@ -636,40 +631,13 @@ usb_get_next_event(struct usb_event *ue) } void -usbd_add_dev_event(int type, usbd_device_handle udev) -{ - struct usb_event ue; - - usbd_fill_deviceinfo(udev, &ue.u.ue_device); - usb_add_event(type, &ue); -} - -void -usbd_add_drv_event(int type, usbd_device_handle udev, device_ptr_t dev) -{ - struct usb_event ue; - - ue.u.ue_driver.ue_cookie = udev->cookie; - strncpy(ue.u.ue_driver.ue_devname, USBDEVPTRNAME(dev), - sizeof ue.u.ue_driver.ue_devname); - usb_add_event(type, &ue); -} - -void -usb_add_event(int type, struct usb_event *uep) +usbd_add_event(int type, usbd_device_handle dev) { struct usb_event_q *ueq, *ueq_next; struct usb_event ue; struct timeval thetime; int s; - microtime(&thetime); - /* Don't want to wait here inside splusb() */ - ueq = malloc(sizeof *ueq, M_USBDEV, M_WAITOK); - ueq->ue = *uep; - ueq->ue.ue_type = type; - TIMEVAL_TO_TIMESPEC(&thetime, &ueq->ue.ue_time); - s = splusb(); if (type == USB_EVENT_CTRLR_DETACH) { for (ueq = TAILQ_FIRST(&usb_events); ueq; ueq = ueq_next) { @@ -687,6 +655,18 @@ usb_add_event(int type, struct usb_event *uep) DPRINTF(("usb: event dropped\n")); (void)usb_get_next_event(&ue); } + /* Don't want to wait here inside splusb() */ + ueq = malloc(sizeof *ueq, M_USBDEV, M_NOWAIT); + if (ueq == NULL) { + printf("usb: no memory, event dropped\n"); + splx(s); + return; + } + ueq->ue.ue_type = type; + ueq->ue.u.ue_driver.ue_cookie = dev->cookie; + usbd_fill_deviceinfo(dev, &ueq->ue.u.ue_device, 0); + microtime(&thetime); + TIMEVAL_TO_TIMESPEC(&thetime, &ueq->ue.ue_time); TAILQ_INSERT_TAIL(&usb_events, ueq, next); usb_nevents++; wakeup(&usb_events); @@ -733,7 +713,6 @@ int usb_detach(device_ptr_t self, int flags) { struct usb_softc *sc = (struct usb_softc *)self; - struct usb_event ue; DPRINTF(("usb_detach: start\n")); @@ -753,10 +732,6 @@ usb_detach(device_ptr_t self, int flags) } usbd_finish(); - - ue.u.ue_ctrlr.ue_bus = USBDEVUNIT(sc->sc_dev); - usb_add_event(USB_EVENT_CTRLR_DETACH, &ue); - return (0); } #elif defined(__FreeBSD__) |