summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjoe <joe@FreeBSD.org>2002-01-26 13:52:53 +0000
committerjoe <joe@FreeBSD.org>2002-01-26 13:52:53 +0000
commitcf2f6dd49e45aa788c704a2cb0cfed98f053d5c3 (patch)
tree8a7893afb22d229e899119767839a5f1064f8601 /sys
parente4b4e421581002ec9ef11e8936871aeee1ea4517 (diff)
downloadFreeBSD-src-cf2f6dd49e45aa788c704a2cb0cfed98f053d5c3.zip
FreeBSD-src-cf2f6dd49e45aa788c704a2cb0cfed98f053d5c3.tar.gz
Rearrange the code in USB_DETACH, so that it's like NetBSD's.
No functional change.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/usb/usb.c53
1 files changed, 39 insertions, 14 deletions
diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c
index 545d35c..8c8c7cc 100644
--- a/sys/dev/usb/usb.c
+++ b/sys/dev/usb/usb.c
@@ -1,4 +1,4 @@
-/* $NetBSD: usb.c,v 1.37 2000/01/24 18:35:51 thorpej Exp $ */
+/* $NetBSD: usb.c,v 1.38 2000/02/02 07:33:59 augustss Exp $ */
/* $FreeBSD$ */
/*
@@ -163,6 +163,7 @@ 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 *);
@@ -201,6 +202,7 @@ USB_ATTACH(usb)
usbd_device_handle dev;
usbd_status err;
int usbrev;
+ struct usb_event ue;
sc->sc_dev = self;
@@ -226,6 +228,9 @@ 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) {
@@ -631,13 +636,40 @@ usb_get_next_event(struct usb_event *ue)
}
void
-usbd_add_event(int type, usbd_device_handle dev)
+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)
{
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) {
@@ -655,18 +687,6 @@ usbd_add_event(int type, usbd_device_handle dev)
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);
@@ -713,6 +733,7 @@ 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"));
@@ -732,6 +753,10 @@ 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__)
OpenPOWER on IntegriCloud