Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Generate usb events on attach and detach.



details:   https://anonhg.NetBSD.org/src/rev/0b73886ac2a3
branches:  trunk
changeset: 481595:0b73886ac2a3
user:      augustss <augustss%NetBSD.org@localhost>
date:      Wed Feb 02 13:18:45 2000 +0000

description:
Generate usb events on attach and detach.

diffstat:

 sys/dev/usb/uaudio.c |   8 +++++++-
 sys/dev/usb/uhid.c   |  10 +++++++++-
 sys/dev/usb/uhub.c   |   7 +------
 sys/dev/usb/ukbd.c   |  11 ++++++++++-
 sys/dev/usb/ulpt.c   |   8 +++++++-
 sys/dev/usb/umass.c  |  10 +++++++++-
 sys/dev/usb/umodem.c |  15 +++++++++------
 sys/dev/usb/ums.c    |  11 ++++++++++-
 8 files changed, 62 insertions(+), 18 deletions(-)

diffs (truncated from 304 to 300 lines):

diff -r fed566edbbf3 -r 0b73886ac2a3 sys/dev/usb/uaudio.c
--- a/sys/dev/usb/uaudio.c      Wed Feb 02 13:06:15 2000 +0000
+++ b/sys/dev/usb/uaudio.c      Wed Feb 02 13:18:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uaudio.c,v 1.16 2000/01/16 09:32:56 augustss Exp $     */
+/*     $NetBSD: uaudio.c,v 1.17 2000/02/02 13:18:45 augustss Exp $     */
 
 /*
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -389,6 +389,9 @@
        DPRINTF(("uaudio_attach: doing audio_attach_mi\n"));
        sc->sc_audiodev = audio_attach_mi(&uaudio_hw_if, sc, &sc->sc_dev);
 
+       usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
+                          USBDEV(sc->sc_dev));
+
        USB_ATTACH_SUCCESS_RETURN;
 }
 
@@ -428,6 +431,9 @@
        if (sc->sc_audiodev != NULL)
                rv = config_detach(sc->sc_audiodev, flags);
 
+       usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
+                          USBDEV(sc->sc_dev));
+
        return (rv);
 }
 
diff -r fed566edbbf3 -r 0b73886ac2a3 sys/dev/usb/uhid.c
--- a/sys/dev/usb/uhid.c        Wed Feb 02 13:06:15 2000 +0000
+++ b/sys/dev/usb/uhid.c        Wed Feb 02 13:18:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhid.c,v 1.31 2000/01/19 00:23:58 augustss Exp $       */
+/*     $NetBSD: uhid.c,v 1.32 2000/02/02 13:18:45 augustss Exp $       */
 /*     $FreeBSD: src/sys/dev/usb/uhid.c,v 1.22 1999/11/17 22:33:43 n_hibma Exp $       */
 
 /*
@@ -83,6 +83,7 @@
 
 struct uhid_softc {
        USBBASEDEVICE sc_dev;                   /* base device */
+       usbd_device_handle sc_udev;
        usbd_interface_handle sc_iface; /* interface */
        usbd_pipe_handle sc_intrpipe;   /* interrupt pipe */
        int sc_ep_addr;
@@ -180,6 +181,7 @@
        usbd_status err;
        char devinfo[1024];
        
+       sc->sc_udev = uaa->device;
        sc->sc_iface = iface;
        id = usbd_get_interface_descriptor(iface);
        usbd_devinfo(uaa->device, 0, devinfo);
@@ -241,6 +243,9 @@
        }
 #endif
 
+       usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
+                          USBDEV(sc->sc_dev));
+
        USB_ATTACH_SUCCESS_RETURN;
 }
 
@@ -307,6 +312,9 @@
 
        free(sc->sc_repdesc, M_USBDEV);
 
+       usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
+                          USBDEV(sc->sc_dev));
+
        return (0);
 }
 
diff -r fed566edbbf3 -r 0b73886ac2a3 sys/dev/usb/uhub.c
--- a/sys/dev/usb/uhub.c        Wed Feb 02 13:06:15 2000 +0000
+++ b/sys/dev/usb/uhub.c        Wed Feb 02 13:18:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhub.c,v 1.37 2000/02/02 07:33:59 augustss Exp $       */
+/*     $NetBSD: uhub.c,v 1.38 2000/02/02 13:18:46 augustss Exp $       */
 /*     $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $       */
 
 /*
@@ -291,11 +291,6 @@
                /* First let the device go through a good power cycle, */
                usbd_delay_ms(dev, USB_PORT_POWER_DOWN_TIME);
 
-#if 0
-usbd_clear_hub_feature(dev, UHF_C_HUB_OVER_CURRENT);
-usbd_clear_port_feature(dev, port, UHF_C_PORT_OVER_CURRENT);
-#endif
-
                /* then turn the power on. */
                err = usbd_set_port_feature(dev, port, UHF_PORT_POWER);
                if (err)
diff -r fed566edbbf3 -r 0b73886ac2a3 sys/dev/usb/ukbd.c
--- a/sys/dev/usb/ukbd.c        Wed Feb 02 13:06:15 2000 +0000
+++ b/sys/dev/usb/ukbd.c        Wed Feb 02 13:18:45 2000 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: ukbd.c,v 1.54 2000/01/19 00:23:58 augustss Exp $        */
+/*      $NetBSD: ukbd.c,v 1.55 2000/02/02 13:18:46 augustss Exp $        */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -168,6 +168,7 @@
 
 struct ukbd_softc {
        USBBASEDEVICE   sc_dev;         /* base device */
+       usbd_device_handle sc_udev;
        usbd_interface_handle sc_iface; /* interface */
        usbd_pipe_handle sc_intrpipe;   /* interrupt pipe */
        int sc_ep_addr;
@@ -273,6 +274,7 @@
        int i;
 #endif
        
+       sc->sc_udev = uaa->device;
        sc->sc_iface = iface;
        id = usbd_get_interface_descriptor(iface);
        usbd_devinfo(uaa->device, 0, devinfo);
@@ -349,6 +351,9 @@
 
        sc->sc_wskbddev = config_found(self, &a, wskbddevprint);
 
+       usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
+                          USBDEV(sc->sc_dev));
+
        USB_ATTACH_SUCCESS_RETURN;
 }
 
@@ -447,6 +452,10 @@
        /* No need to do reference counting of ukbd, wskbd has all the goo. */
        if (sc->sc_wskbddev != NULL)
                rv = config_detach(sc->sc_wskbddev, flags);
+
+       usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
+                          USBDEV(sc->sc_dev));
+
        return (rv);
 }
 
diff -r fed566edbbf3 -r 0b73886ac2a3 sys/dev/usb/ulpt.c
--- a/sys/dev/usb/ulpt.c        Wed Feb 02 13:06:15 2000 +0000
+++ b/sys/dev/usb/ulpt.c        Wed Feb 02 13:18:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ulpt.c,v 1.30 1999/11/18 23:32:30 augustss Exp $       */
+/*     $NetBSD: ulpt.c,v 1.31 2000/02/02 13:18:47 augustss Exp $       */
 /*     $FreeBSD: src/sys/dev/usb/ulpt.c,v 1.24 1999/11/17 22:33:44 n_hibma Exp $       */
 
 /*
@@ -263,6 +263,9 @@
                UID_ROOT, GID_OPERATOR, 0644, "unlpt%d", device_get_unit(self));
 #endif
 
+       usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
+                          USBDEV(sc->sc_dev));
+
        USB_ATTACH_SUCCESS_RETURN;
 
  nobulk:
@@ -332,6 +335,9 @@
        destroy_dev(sc->dev_noprime);
 #endif
 
+       usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
+                          USBDEV(sc->sc_dev));
+
        return (0);
 }
 
diff -r fed566edbbf3 -r 0b73886ac2a3 sys/dev/usb/umass.c
--- a/sys/dev/usb/umass.c       Wed Feb 02 13:06:15 2000 +0000
+++ b/sys/dev/usb/umass.c       Wed Feb 02 13:18:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umass.c,v 1.23 1999/11/17 23:00:50 augustss Exp $      */
+/*     $NetBSD: umass.c,v 1.24 2000/02/02 13:18:47 augustss Exp $      */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -131,6 +131,7 @@
 
 typedef struct umass_softc {
        USBBASEDEVICE           sc_dev;         /* base device */
+       usbd_device_handle      sc_udev;
        usbd_interface_handle   sc_iface;       /* the interface we use */
 
        u_int8_t                sc_subclass;    /* our USB subclass */
@@ -251,6 +252,7 @@
        u_int8_t maxlun;
        const char *subclass, *protocol;
 
+       sc->sc_udev = uaa->device;
        sc->sc_iface = uaa->iface;
        sc->sc_bulkout_pipe = NULL;
        sc->sc_bulkin_pipe = NULL;
@@ -367,6 +369,9 @@
                USB_ATTACH_ERROR_RETURN;
        }
 
+       usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
+                          USBDEV(sc->sc_dev));
+
        USB_ATTACH_SUCCESS_RETURN;
 }
 
@@ -437,6 +442,9 @@
                sc->sc_bulkout_pipe = NULL;
        }
 
+       usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
+                          USBDEV(sc->sc_dev));
+
        return (rv);
 }
 
diff -r fed566edbbf3 -r 0b73886ac2a3 sys/dev/usb/umodem.c
--- a/sys/dev/usb/umodem.c      Wed Feb 02 13:06:15 2000 +0000
+++ b/sys/dev/usb/umodem.c      Wed Feb 02 13:18:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umodem.c,v 1.20 2000/01/25 08:12:58 augustss Exp $     */
+/*     $NetBSD: umodem.c,v 1.21 2000/02/02 13:18:47 augustss Exp $     */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -272,6 +272,9 @@
        DPRINTF(("umodem_attach: sc=%p\n", sc));
        sc->sc_subdev = config_found_sm(self, &uca, ucomprint, ucomsubmatch);
 
+       usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
+                          USBDEV(sc->sc_dev));
+
        USB_ATTACH_SUCCESS_RETURN;
 
  bad:
@@ -602,12 +605,9 @@
        return (rv);
 }
 
-int
-umodem_detach(self, flags)
-       device_ptr_t self;
-       int flags;
+USB_DETACH(umodem)
 {
-       struct umodem_softc *sc = (struct umodem_softc *)self;
+       USB_DETACH_START(umodem, sc);
        int rv = 0;
 
        DPRINTF(("umodem_detach: sc=%p flags=%d\n", sc, flags));
@@ -617,5 +617,8 @@
        if (sc->sc_subdev != NULL)
                rv = config_detach(sc->sc_subdev, flags);
 
+       usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
+                          USBDEV(sc->sc_dev));
+
        return (rv);
 }
diff -r fed566edbbf3 -r 0b73886ac2a3 sys/dev/usb/ums.c
--- a/sys/dev/usb/ums.c Wed Feb 02 13:06:15 2000 +0000
+++ b/sys/dev/usb/ums.c Wed Feb 02 13:18:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ums.c,v 1.39 2000/01/19 00:23:58 augustss Exp $        */
+/*     $NetBSD: ums.c,v 1.40 2000/02/02 13:18:48 augustss Exp $        */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -88,6 +88,7 @@
 
 struct ums_softc {
        USBBASEDEVICE sc_dev;           /* base device */
+       usbd_device_handle sc_udev;
        usbd_interface_handle sc_iface; /* interface */
        usbd_pipe_handle sc_intrpipe;   /* interrupt pipe */
        int sc_ep_addr;
@@ -175,6 +176,7 @@
        int i, wheel;
        struct hid_location loc_btn;
        
+       sc->sc_udev = uaa->device;
        sc->sc_iface = iface;
        id = usbd_get_interface_descriptor(iface);
        usbd_devinfo(uaa->device, 0, devinfo);
@@ -305,6 +307,9 @@
 
        sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint);
 
+       usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
+                          USBDEV(sc->sc_dev));
+
        USB_ATTACH_SUCCESS_RETURN;
 }
 
@@ -344,6 +349,10 @@
                free(sc->sc_loc_btn, M_USBDEV);
                free(sc->sc_ibuf, M_USBDEV);
        }
+
+       usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
+                          USBDEV(sc->sc_dev));



Home | Main Index | Thread Index | Old Index