Nuke USB_MATCH*, USB_ATTACH* and USB_DETACH* macros.
authorHasso Tepper <hasso@dragonflybsd.org>
Sun, 1 Jul 2007 21:24:04 +0000 (21:24 +0000)
committerHasso Tepper <hasso@dragonflybsd.org>
Sun, 1 Jul 2007 21:24:04 +0000 (21:24 +0000)
27 files changed:
sys/bus/usb/uhub.c
sys/bus/usb/usb.c
sys/dev/netif/aue/if_aue.c
sys/dev/netif/axe/if_axe.c
sys/dev/netif/cue/if_cue.c
sys/dev/netif/kue/if_kue.c
sys/dev/netif/rue/if_rue.c
sys/dev/netif/rum/if_rum.c
sys/dev/netif/ural/if_ural.c
sys/dev/sound/usb/uaudio.c
sys/dev/usbmisc/ubsa/ubsa.c
sys/dev/usbmisc/udbp/udbp.c
sys/dev/usbmisc/ufm/ufm.c
sys/dev/usbmisc/uftdi/uftdi.c
sys/dev/usbmisc/ugen/ugen.c
sys/dev/usbmisc/uhid/uhid.c
sys/dev/usbmisc/ukbd/ukbd.c
sys/dev/usbmisc/ulpt/ulpt.c
sys/dev/usbmisc/umass/umass.c
sys/dev/usbmisc/umct/umct.c
sys/dev/usbmisc/umodem/umodem.c
sys/dev/usbmisc/ums/ums.c
sys/dev/usbmisc/uplcom/uplcom.c
sys/dev/usbmisc/urio/urio.c
sys/dev/usbmisc/uscanner/uscanner.c
sys/dev/usbmisc/uvisor/uvisor.c
sys/dev/usbmisc/uvscom/uvscom.c

index 7333eb6..3f47ad6 100644 (file)
@@ -1,6 +1,6 @@
 /*     $NetBSD: uhub.c,v 1.68 2004/06/29 06:30:05 mycroft Exp $        */
 /*     $FreeBSD: src/sys/dev/usb/uhub.c,v 1.69.2.1 2005/12/18 15:51:31 iedowse Exp $   */
-/*     $DragonFly: src/sys/bus/usb/uhub.c,v 1.16 2007/06/28 13:55:12 hasso Exp $       */
+/*     $DragonFly: src/sys/bus/usb/uhub.c,v 1.17 2007/07/01 21:24:02 hasso Exp $       */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -130,9 +130,10 @@ static     driver_t uhubroot_driver = {
        sizeof(struct uhub_softc)
 };
 
-USB_MATCH(uhub)
+static int
+uhub_match(device_t self)
 {
-       USB_MATCH_START(uhub, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usb_device_descriptor_t *dd = usbd_get_device_descriptor(uaa->device);
 
        DPRINTFN(5,("uhub_match, dd=%p\n", dd));
@@ -145,9 +146,11 @@ USB_MATCH(uhub)
        return (UMATCH_NONE);
 }
 
-USB_ATTACH(uhub)
+static int
+uhub_attach(device_t self)
 {
-       USB_ATTACH_START(uhub, sc, uaa);
+       struct uhub_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usbd_device_handle dev = uaa->device;
        char *devinfo;
        usbd_status err;
@@ -163,7 +166,8 @@ USB_ATTACH(uhub)
        DPRINTFN(1,("uhub_attach\n"));
        sc->sc_hub = dev;
        usbd_devinfo(dev, 1, devinfo);
-       USB_ATTACH_SETUP;
+       sc->sc_dev = self;
+       device_set_desc_copy(self, devinfo);
 
        if (dev->depth > 0 && UHUB_IS_HIGH_SPEED(sc)) {
                kprintf("%s: %s transaction translator%s\n",
@@ -176,14 +180,14 @@ USB_ATTACH(uhub)
                DPRINTF(("%s: configuration failed, error=%s\n",
                         device_get_nameunit(sc->sc_dev), usbd_errstr(err)));
                kfree(devinfo, M_TEMP);
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        if (dev->depth > USB_HUB_MAX_DEPTH) {
                kprintf("%s: hub depth (%d) exceeded, hub ignored\n",
                       device_get_nameunit(sc->sc_dev), USB_HUB_MAX_DEPTH);
                kfree(devinfo, M_TEMP);
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        /* Get hub descriptor. */
@@ -203,7 +207,7 @@ USB_ATTACH(uhub)
                DPRINTF(("%s: getting hub descriptor failed, error=%s\n",
                         device_get_nameunit(sc->sc_dev), usbd_errstr(err)));
                kfree(devinfo, M_TEMP);
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        for (nremov = 0, port = 1; port <= nports; port++)
@@ -338,14 +342,14 @@ USB_ATTACH(uhub)
 
        sc->sc_running = 1;
 
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 
  bad:
        if (hub)
                kfree(hub, M_USBDEV);
        kfree(devinfo, M_TEMP);
        dev->hub = NULL;
-       USB_ATTACH_ERROR_RETURN;
+       return ENXIO;
 }
 
 usbd_status
@@ -530,9 +534,10 @@ uhub_explore(usbd_device_handle dev)
  * Called from process context when the hub is gone.
  * Detach all devices on active ports.
  */
-USB_DETACH(uhub)
+static int
+uhub_detach(device_t self)
 {
-       USB_DETACH_START(uhub, sc);
+       struct uhub_softc *sc = device_get_softc(self);
        struct usbd_hub *hub = sc->sc_hub->hub;
        struct usbd_port *rup;
        int port, nports;
index 806427f..efb6a9b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * $NetBSD: usb.c,v 1.68 2002/02/20 20:30:12 christos Exp $
  * $FreeBSD: src/sys/dev/usb/usb.c,v 1.106 2005/03/27 15:31:23 iedowse Exp $
- * $DragonFly: src/sys/bus/usb/usb.c,v 1.35 2007/06/30 20:39:22 hasso Exp $
+ * $DragonFly: src/sys/bus/usb/usb.c,v 1.36 2007/07/01 21:24:02 hasso Exp $
  */
 
 /* Also already merged from NetBSD:
@@ -183,13 +183,15 @@ USB_DECLARE_DRIVER_INIT(usb,
 
 MODULE_VERSION(usb, 1);
 
-USB_MATCH(usb)
+static int
+usb_match(device_t self)
 {
        DPRINTF(("usbd_match\n"));
        return (UMATCH_GENERIC);
 }
 
-USB_ATTACH(usb)
+static int
+usb_attach(device_t self)
 {
        struct usb_softc *sc = device_get_softc(self);
        void *aux = device_get_ivars(self);
@@ -223,7 +225,7 @@ USB_ATTACH(usb)
        default:
                kprintf(", not supported\n");
                sc->sc_dying = 1;
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
        kprintf("\n");
 
@@ -244,7 +246,7 @@ USB_ATTACH(usb)
        if (sc->sc_bus->soft == NULL) {
                kprintf("%s: can't register softintr\n", device_get_nameunit(sc->sc_dev));
                sc->sc_dying = 1;
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 #else
        callout_init(&sc->sc_bus->softi);
@@ -259,7 +261,7 @@ USB_ATTACH(usb)
                        sc->sc_dying = 1;
                        kprintf("%s: root device is not a hub\n",
                               device_get_nameunit(sc->sc_dev));
-                       USB_ATTACH_ERROR_RETURN;
+                       return ENXIO;
                }
                sc->sc_bus->root_hub = dev;
 #if 1
@@ -305,7 +307,7 @@ USB_ATTACH(usb)
                usb_dev = reference_dev(tmp_dev);
        }
 
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 }
 
 static const char *taskq_names[] = USB_TASKQ_NAMES;
@@ -836,9 +838,10 @@ usb_schedsoftintr(usbd_bus_handle bus)
 #endif /* USB_USE_SOFTINTR */
 }
 
-USB_DETACH(usb)
+static int
+usb_detach(device_t self)
 {
-       USB_DETACH_START(usb, sc);
+       struct usb_softc *sc = device_get_softc(self);
        struct usb_event ue;
 
        DPRINTF(("usb_detach: start\n"));
index 4208b86..f2f128b 100644 (file)
@@ -30,7 +30,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/usb/if_aue.c,v 1.78 2003/12/17 14:23:07 sanpei Exp $
- * $DragonFly: src/sys/dev/netif/aue/if_aue.c,v 1.32 2007/06/28 06:32:31 hasso Exp $
+ * $DragonFly: src/sys/dev/netif/aue/if_aue.c,v 1.33 2007/07/01 21:24:02 hasso Exp $
  */
 
 /*
@@ -600,9 +600,10 @@ aue_reset(struct aue_softc *sc)
 /*
  * Probe for a Pegasus chip.
  */
-USB_MATCH(aue)
+static int
+aue_match(device_t self)
 {
-       USB_MATCH_START(aue, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
 
        if (uaa->iface != NULL)
                return (UMATCH_NONE);
@@ -615,9 +616,11 @@ USB_MATCH(aue)
  * Attach the interface. Allocate softc structures, do ifmedia
  * setup and ethernet/BPF attach.
  */
-USB_ATTACH(aue)
+static int
+aue_attach(device_t self)
 {
-       USB_ATTACH_START(aue, sc, uaa);
+       struct aue_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        char                    devinfo[1024];
        u_char                  eaddr[ETHER_ADDR_LEN];
        struct ifnet            *ifp;
@@ -635,13 +638,13 @@ USB_ATTACH(aue)
        if (usbd_set_config_no(sc->aue_udev, AUE_CONFIG_NO, 0)) {
                device_printf(self, "setting config no %d failed\n",
                              AUE_CONFIG_NO);
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        err = usbd_device2interface_handle(uaa->device, AUE_IFACE_IDX, &iface);
        if (err) {
                device_printf(self, "getting interface handle failed\n");
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        sc->aue_iface = iface;
@@ -661,7 +664,7 @@ USB_ATTACH(aue)
                ed = usbd_interface2endpoint_descriptor(iface, i);
                if (ed == NULL) {
                        device_printf(self, "couldn't get ep %d\n", i);
-                       USB_ATTACH_ERROR_RETURN;
+                       return ENXIO;
                }
                if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
                    UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
@@ -716,7 +719,7 @@ USB_ATTACH(aue)
            aue_ifmedia_upd, aue_ifmedia_sts)) {
                device_printf(self, "MII without any PHY!\n");
                AUE_UNLOCK(sc);
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        /*
@@ -727,7 +730,7 @@ USB_ATTACH(aue)
        sc->aue_dying = 0;
 
        AUE_UNLOCK(sc);
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 }
 
 static int
index 206614f..dd00111 100644 (file)
@@ -30,7 +30,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/usb/if_axe.c,v 1.10 2003/12/08 07:54:14 obrien Exp $
- * $DragonFly: src/sys/dev/netif/axe/if_axe.c,v 1.22 2007/06/28 06:32:31 hasso Exp $
+ * $DragonFly: src/sys/dev/netif/axe/if_axe.c,v 1.23 2007/07/01 21:24:02 hasso Exp $
  */
 /*
  * ASIX Electronics AX88172 USB 2.0 ethernet driver. Used in the
@@ -368,9 +368,10 @@ axe_reset(struct axe_softc *sc)
 /*
  * Probe for a AX88172 chip.
  */
-USB_MATCH(axe)
+static int
+axe_match(device_t self)
 {
-       USB_MATCH_START(axe, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        struct axe_type                 *t;
 
        if (!uaa->iface)
@@ -392,9 +393,11 @@ USB_MATCH(axe)
  * Attach the interface. Allocate softc structures, do ifmedia
  * setup and ethernet/BPF attach.
  */
-USB_ATTACH(axe)
+static int
+axe_attach(device_t self)
 {
-       USB_ATTACH_START(axe, sc, uaa);
+       struct axe_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        char                    devinfo[1024];
        u_char                  eaddr[ETHER_ADDR_LEN];
        struct ifnet            *ifp;
@@ -408,13 +411,13 @@ USB_ATTACH(axe)
        if (usbd_set_config_no(sc->axe_udev, AXE_CONFIG_NO, 1)) {
                device_printf(self, "setting config no %d failed\n",
                    AXE_CONFIG_NO);
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        if (usbd_device2interface_handle(uaa->device,
            AXE_IFACE_IDX, &sc->axe_iface)) {
                device_printf(self, "getting interface handle failed\n");
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        id = usbd_get_interface_descriptor(sc->axe_iface);
@@ -428,7 +431,7 @@ USB_ATTACH(axe)
                ed = usbd_interface2endpoint_descriptor(sc->axe_iface, i);
                if (!ed) {
                        device_printf(self, "couldn't get ep %d\n", i);
-                       USB_ATTACH_ERROR_RETURN;
+                       return ENXIO;
                }
                if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
                    UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
@@ -475,7 +478,7 @@ USB_ATTACH(axe)
        if (mii_phy_probe(self, &sc->axe_miibus,
            axe_ifmedia_upd, axe_ifmedia_sts)) {
                device_printf(self, "MII without any PHY!\n");
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        /*
@@ -488,7 +491,7 @@ USB_ATTACH(axe)
 
        usb_register_netisr();
 
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 }
 
 static int
index cdc64be..3fe8170 100644 (file)
@@ -30,7 +30,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/usb/if_cue.c,v 1.45 2003/12/08 07:54:14 obrien Exp $
- * $DragonFly: src/sys/dev/netif/cue/if_cue.c,v 1.27 2007/06/28 06:32:32 hasso Exp $
+ * $DragonFly: src/sys/dev/netif/cue/if_cue.c,v 1.28 2007/07/01 21:24:02 hasso Exp $
  */
 
 /*
@@ -392,9 +392,10 @@ cue_reset(struct cue_softc *sc)
 /*
  * Probe for a Pegasus chip.
  */
-USB_MATCH(cue)
+static int
+cue_match(device_t self)
 {
-       USB_MATCH_START(cue, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        struct cue_type                 *t;
 
        if (!uaa->iface)
@@ -416,9 +417,11 @@ USB_MATCH(cue)
  * Attach the interface. Allocate softc structures, do ifmedia
  * setup and ethernet/BPF attach.
  */
-USB_ATTACH(cue)
+static int
+cue_attach(device_t self)
 {
-       USB_ATTACH_START(cue, sc, uaa);
+       struct cue_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        char                    devinfo[1024];
        u_char                  eaddr[ETHER_ADDR_LEN];
        struct ifnet            *ifp;
@@ -433,7 +436,7 @@ USB_ATTACH(cue)
        if (usbd_set_config_no(sc->cue_udev, CUE_CONFIG_NO, 0)) {
                device_printf(self, "setting config no %d failed\n",
                              CUE_CONFIG_NO);
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        id = usbd_get_interface_descriptor(uaa->iface);
@@ -447,7 +450,7 @@ USB_ATTACH(cue)
                ed = usbd_interface2endpoint_descriptor(uaa->iface, i);
                if (!ed) {
                        device_printf(self, "couldn't get ep %d\n", i);
-                       USB_ATTACH_ERROR_RETURN;
+                       return ENXIO;
                }
                if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
                    UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
@@ -494,7 +497,7 @@ USB_ATTACH(cue)
        sc->cue_dying = 0;
 
        CUE_UNLOCK(sc);
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 }
 
 static int
index 8b0bf7c..1cf2a0e 100644 (file)
@@ -30,7 +30,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/usb/if_kue.c,v 1.17.2.9 2003/04/13 02:39:25 murray Exp $
- * $DragonFly: src/sys/dev/netif/kue/if_kue.c,v 1.24 2007/06/28 06:32:32 hasso Exp $
+ * $DragonFly: src/sys/dev/netif/kue/if_kue.c,v 1.25 2007/07/01 21:24:02 hasso Exp $
  */
 
 /*
@@ -380,9 +380,10 @@ kue_reset(struct kue_softc *sc)
 /*
  * Probe for a KLSI chip.
  */
-USB_MATCH(kue)
+static int
+kue_match(device_t self)
 {
-       USB_MATCH_START(kue, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        struct kue_type                 *t;
 
        if (!uaa->iface)
@@ -404,9 +405,11 @@ USB_MATCH(kue)
  * Attach the interface. Allocate softc structures, do
  * setup and ethernet/BPF attach.
  */
-USB_ATTACH(kue)
+static int
+kue_attach(device_t self)
 {
-       USB_ATTACH_START(kue, sc, uaa);
+       struct kue_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        char                    devinfo[1024];
        struct ifnet            *ifp;
        usbd_status             err;
@@ -430,7 +433,7 @@ USB_ATTACH(kue)
                if (!ed) {
                        kprintf("kue%d: couldn't get ep %d\n",
                            sc->kue_unit, i);
-                       USB_ATTACH_ERROR_RETURN;
+                       return ENXIO;
                }
                if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
                    UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
@@ -456,7 +459,7 @@ USB_ATTACH(kue)
 #if defined(__FreeBSD__) && __FreeBSD_version >= 500000
                mtx_destroy(&sc->kue_mtx);
 #endif
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        /* Reset the adapter. */
@@ -491,7 +494,7 @@ USB_ATTACH(kue)
 
        KUE_UNLOCK(sc);
 
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 }
 
 static int
index dc241a5..96a9338 100644 (file)
@@ -55,7 +55,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/usb/if_rue.c,v 1.14 2004/06/09 14:34:03 naddy Exp $
- * $DragonFly: src/sys/dev/netif/rue/if_rue.c,v 1.8 2007/06/28 06:32:32 hasso Exp $
+ * $DragonFly: src/sys/dev/netif/rue/if_rue.c,v 1.9 2007/07/01 21:24:02 hasso Exp $
  */
 
 /*
@@ -508,9 +508,10 @@ rue_reset(struct rue_softc *sc)
  * Probe for a RTL8150 chip.
  */
 
-USB_MATCH(rue)
+static int
+rue_match(device_t self)
 {
-       USB_MATCH_START(rue, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        struct rue_type *t;
 
        if (uaa->iface == NULL)
@@ -533,9 +534,11 @@ USB_MATCH(rue)
  * setup and ethernet/BPF attach.
  */
 
-USB_ATTACH(rue)
+static int
+rue_attach(device_t self)
 {
-       USB_ATTACH_START(rue, sc, uaa);
+       struct rue_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        char                            devinfo[1024];
        uint8_t                         eaddr[ETHER_ADDR_LEN];
        struct ifnet                    *ifp;
@@ -548,13 +551,13 @@ USB_ATTACH(rue)
        if (usbd_set_config_no(sc->rue_udev, RUE_CONFIG_NO, 0)) {
                device_printf(self, "setting config no %d failed\n",
                              RUE_CONFIG_NO);
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        if (usbd_device2interface_handle(uaa->device, RUE_IFACE_IDX,
                                         &sc->rue_iface)) {
                device_printf(self, "getting interface handle failed\n");
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        id = usbd_get_interface_descriptor(sc->rue_iface);
@@ -568,7 +571,7 @@ USB_ATTACH(rue)
                ed = usbd_interface2endpoint_descriptor(sc->rue_iface, i);
                if (ed == NULL) {
                        device_printf(self, "couldn't get ep %d\n", i);
-                       USB_ATTACH_ERROR_RETURN;
+                       return ENXIO;
                }
                if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
                    UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
@@ -591,7 +594,7 @@ USB_ATTACH(rue)
        /* Get station address from the EEPROM */
        if (rue_read_mem(sc, RUE_EEPROM_IDR0, eaddr, ETHER_ADDR_LEN)) {
                device_printf(self, "couldn't get station address\n");
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        ifp->if_softc = sc;
@@ -609,7 +612,7 @@ USB_ATTACH(rue)
        if (mii_phy_probe(self, &sc->rue_miibus,
                          rue_ifmedia_upd, rue_ifmedia_sts)) {
                device_printf(self, "MII without any PHY!\n");
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        /* Call MI attach routine */
@@ -620,7 +623,7 @@ USB_ATTACH(rue)
 
        usb_register_netisr();
 
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 }
 
 static int
index 7481c95..69160c9 100644 (file)
@@ -1,5 +1,5 @@
 /*     $OpenBSD: if_rum.c,v 1.40 2006/09/18 16:20:20 damien Exp $      */
-/*     $DragonFly: src/sys/dev/netif/rum/if_rum.c,v 1.15 2007/06/28 13:55:12 hasso Exp $       */
+/*     $DragonFly: src/sys/dev/netif/rum/if_rum.c,v 1.16 2007/07/01 21:24:02 hasso Exp $       */
 
 /*-
  * Copyright (c) 2005, 2006 Damien Bergamini <damien.bergamini@free.fr>
@@ -219,9 +219,10 @@ static const struct rfprog {
 USB_DECLARE_DRIVER(rum);
 DRIVER_MODULE(rum, uhub, rum_driver, rum_devclass, usbd_driver_load, 0);
 
-USB_MATCH(rum)
+static int
+rum_match(device_t self)
 {
-       USB_MATCH_START(rum, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
 
        if (uaa->iface != NULL)
                return UMATCH_NONE;
@@ -230,9 +231,11 @@ USB_MATCH(rum)
            UMATCH_VENDOR_PRODUCT : UMATCH_NONE;
 }
 
-USB_ATTACH(rum)
+static int
+rum_attach(device_t self)
 {
-       USB_ATTACH_START(rum, sc, uaa);
+       struct rum_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        struct ieee80211com *ic = &sc->sc_ic;
        struct ifnet *ifp = &ic->ic_if;
        usb_interface_descriptor_t *id;
@@ -245,12 +248,13 @@ USB_ATTACH(rum)
        sc->sc_udev = uaa->device;
 
        usbd_devinfo(uaa->device, 0, devinfo);
-       USB_ATTACH_SETUP;
+       sc->sc_dev = self;
+       device_set_desc_copy(self, devinfo);
 
        if (usbd_set_config_no(sc->sc_udev, RT2573_CONFIG_NO, 0) != 0) {
                kprintf("%s: could not set configuration no\n",
                    device_get_nameunit(sc->sc_dev));
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        /* get the first interface handle */
@@ -259,7 +263,7 @@ USB_ATTACH(rum)
        if (error != 0) {
                kprintf("%s: could not get interface handle\n",
                    device_get_nameunit(sc->sc_dev));
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        /*
@@ -273,7 +277,7 @@ USB_ATTACH(rum)
                if (ed == NULL) {
                        kprintf("%s: no endpoint descriptor for iface %d\n",
                            device_get_nameunit(sc->sc_dev), i);
-                       USB_ATTACH_ERROR_RETURN;
+                       return ENXIO;
                }
 
                if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
@@ -285,7 +289,7 @@ USB_ATTACH(rum)
        }
        if (sc->sc_rx_no == -1 || sc->sc_tx_no == -1) {
                kprintf("%s: missing endpoint\n", device_get_nameunit(sc->sc_dev));
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        usb_init_task(&sc->sc_task, rum_task, sc);
@@ -302,7 +306,7 @@ USB_ATTACH(rum)
        if (ntries == 1000) {
                kprintf("%s: timeout waiting for chip to settle\n",
                    device_get_nameunit(sc->sc_dev));
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        /* retrieve MAC address and various other things from EEPROM */
@@ -315,7 +319,7 @@ USB_ATTACH(rum)
        error = rum_load_microcode(sc, rt2573, sizeof(rt2573));
        if (error != 0) {
                device_printf(self, "can't load microcode\n");
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        ic->ic_phytype = IEEE80211_T_OFDM;      /* not only, but not used */
@@ -419,12 +423,13 @@ USB_ATTACH(rum)
        if (bootverbose)
                ieee80211_announce(ic);
 
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 }
 
-USB_DETACH(rum)
+static int
+rum_detach(device_t self)
 {
-       USB_DETACH_START(rum, sc);
+       struct rum_softc *sc = device_get_softc(self);
        struct ifnet *ifp = &sc->sc_ic.ic_if;
 #ifdef INVARIANTS
        int i;
index ca025c0..3ede561 100644 (file)
@@ -1,5 +1,5 @@
 /*     $FreeBSD: src/sys/dev/usb/if_ural.c,v 1.10.2.8 2006/07/08 07:48:43 maxim Exp $  */
-/*     $DragonFly: src/sys/dev/netif/ural/if_ural.c,v 1.15 2007/06/28 13:55:12 hasso Exp $     */
+/*     $DragonFly: src/sys/dev/netif/ural/if_ural.c,v 1.16 2007/07/01 21:24:02 hasso Exp $     */
 
 /*-
  * Copyright (c) 2005, 2006
@@ -343,9 +343,10 @@ static const struct {
 
 USB_DECLARE_DRIVER(ural);
 
-USB_MATCH(ural)
+static int
+ural_match(device_t self)
 {
-       USB_MATCH_START(ural, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
 
        if (uaa->iface != NULL)
                return UMATCH_NONE;
@@ -354,9 +355,11 @@ USB_MATCH(ural)
            UMATCH_VENDOR_PRODUCT : UMATCH_NONE;
 }
 
-USB_ATTACH(ural)
+static int
+ural_attach(device_t self)
 {
-       USB_ATTACH_START(ural, sc, uaa);
+       struct ural_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        struct ifnet *ifp;
        struct ieee80211com *ic = &sc->sc_ic;
        usb_interface_descriptor_t *id;
@@ -369,12 +372,13 @@ USB_ATTACH(ural)
        sc->sc_tx_retries = 7;  /* TODO tunable/sysctl */
 
        usbd_devinfo(sc->sc_udev, 0, devinfo);
-       USB_ATTACH_SETUP;
+       sc->sc_dev = self;
+       device_set_desc_copy(self, devinfo);
 
        if (usbd_set_config_no(sc->sc_udev, RAL_CONFIG_NO, 0) != 0) {
                kprintf("%s: could not set configuration no\n",
                    device_get_nameunit(sc->sc_dev));
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        /* get the first interface handle */
@@ -383,7 +387,7 @@ USB_ATTACH(ural)
        if (error != 0) {
                kprintf("%s: could not get interface handle\n",
                    device_get_nameunit(sc->sc_dev));
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        /*
@@ -397,7 +401,7 @@ USB_ATTACH(ural)
                if (ed == NULL) {
                        kprintf("%s: no endpoint descriptor for %d\n",
                            device_get_nameunit(sc->sc_dev), i);
-                       USB_ATTACH_ERROR_RETURN;
+                       return ENXIO;
                }
 
                if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
@@ -409,7 +413,7 @@ USB_ATTACH(ural)
        }
        if (sc->sc_rx_no == -1 || sc->sc_tx_no == -1) {
                kprintf("%s: missing endpoint\n", device_get_nameunit(sc->sc_dev));
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        usb_init_task(&sc->sc_task, ural_task, sc);
@@ -521,12 +525,13 @@ USB_ATTACH(ural)
        if (bootverbose)
                ieee80211_announce(ic);
 
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 }
 
-USB_DETACH(ural)
+static int
+ural_detach(device_t self)
 {
-       USB_DETACH_START(ural, sc);
+       struct ural_softc *sc = device_get_softc(self);
        struct ieee80211com *ic = &sc->sc_ic;
        struct ifnet *ifp = &ic->ic_if;
 #ifdef INVARIANTS
index cfe7bab..67735b1 100644 (file)
@@ -1,6 +1,6 @@
 /*     $NetBSD: uaudio.c,v 1.91 2004/11/05 17:46:14 kent Exp $ */
 /*     $FreeBSD: src/sys/dev/sound/usb/uaudio.c,v 1.14.2.2 2006/04/04 17:34:10 ariff Exp $ */
-/*     $DragonFly: src/sys/dev/sound/usb/uaudio.c,v 1.14 2007/06/28 13:55:12 hasso Exp $: */
+/*     $DragonFly: src/sys/dev/sound/usb/uaudio.c,v 1.15 2007/07/01 21:24:02 hasso Exp $: */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -496,9 +496,10 @@ USB_DECLARE_DRIVER_INIT(uaudio,
 #endif
 
 
-USB_MATCH(uaudio)
+static int
+uaudio_match(device_t self)
 {
-       USB_MATCH_START(uaudio, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usb_interface_descriptor_t *id;
 
        if (uaa->iface == NULL)
@@ -515,9 +516,11 @@ USB_MATCH(uaudio)
        return UMATCH_IFACECLASS_IFACESUBCLASS;
 }
 
-USB_ATTACH(uaudio)
+static int
+uaudio_attach(device_t self)
 {
-       USB_ATTACH_START(uaudio, sc, uaa);
+       struct uaudio_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usb_interface_descriptor_t *id;
        usb_config_descriptor_t *cdesc;
        char devinfo[1024];
@@ -526,7 +529,8 @@ USB_ATTACH(uaudio)
 
 #if defined(__FreeBSD__) || defined(__DragonFly__)
        usbd_devinfo(uaa->device, 0, devinfo);
-       USB_ATTACH_SETUP;
+       sc->sc_dev = self;
+       device_set_desc_copy(self, devinfo);
 #else
        usbd_devinfo(uaa->device, 0, devinfo, sizeof(devinfo));
        kprintf(": %s\n", devinfo);
@@ -538,14 +542,14 @@ USB_ATTACH(uaudio)
        if (cdesc == NULL) {
                kprintf("%s: failed to get configuration descriptor\n",
                       device_get_nameunit(sc->sc_dev));
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        err = uaudio_identify(sc, cdesc);
        if (err) {
                kprintf("%s: audio descriptors make no sense, error=%d\n",
                       device_get_nameunit(sc->sc_dev), err);
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        sc->sc_ac_ifaceh = uaa->iface;
@@ -572,7 +576,7 @@ USB_ATTACH(uaudio)
                if (sc->sc_alts[j].ifaceh == NULL) {
                        kprintf("%s: alt %d missing AS interface(s)\n",
                            device_get_nameunit(sc->sc_dev), j);
-                       USB_ATTACH_ERROR_RETURN;
+                       return ENXIO;
                }
        }
 
@@ -606,11 +610,11 @@ USB_ATTACH(uaudio)
        sc->sc_dying = 0;
        if (audio_attach_mi(sc->sc_dev)) {
                kprintf("audio_attach_mi failed\n");
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 #endif
 
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 }
 
 #if defined(__NetBSD__) || defined(__OpenBSD__)
@@ -658,9 +662,10 @@ uaudio_detach(device_t self, int flags)
 }
 #elif defined(__FreeBSD__) || defined(__DragonFly__)
 
-USB_DETACH(uaudio)
+static int
+uaudio_detach(device_t self)
 {
-       USB_DETACH_START(uaudio, sc);
+       struct uaudio_softc *sc = device_get_softc(self);
 
        sbuf_delete(&(sc->uaudio_sndstat));
        sc->uaudio_sndstat_flag = 0;
index 5add93a..dcdce94 100644 (file)
@@ -60,7 +60,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/usb/ubsa.c,v 1.11 2003/11/16 12:13:39 akiyama Exp $
- * $DragonFly: src/sys/dev/usbmisc/ubsa/ubsa.c,v 1.12 2007/06/28 13:55:12 hasso Exp $
+ * $DragonFly: src/sys/dev/usbmisc/ubsa/ubsa.c,v 1.13 2007/07/01 21:24:03 hasso Exp $
  */
 
 #include <sys/param.h>
@@ -246,9 +246,10 @@ MODULE_DEPEND(ubsa, usb, 1, 1, 1);
 MODULE_DEPEND(ubsa, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER);
 MODULE_VERSION(ubsa, UBSA_MODVER);
 
-USB_MATCH(ubsa)
+static int
+ubsa_match(device_t self)
 {
-       USB_MATCH_START(ubsa, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        int i;
 
        if (uaa->iface != NULL)
@@ -263,9 +264,11 @@ USB_MATCH(ubsa)
        return (UMATCH_NONE);
 }
 
-USB_ATTACH(ubsa)
+static int
+ubsa_attach(device_t self)
 {
-       USB_ATTACH_START(ubsa, sc, uaa);
+       struct ubsa_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usbd_device_handle dev;
        struct ucom_softc *ucom;
        usb_config_descriptor_t *cdesc;
@@ -290,10 +293,8 @@ USB_ATTACH(ubsa)
        sc->sc_rts = -1;
 
        usbd_devinfo(dev, 0, devinfo);
-       /* USB_ATTACH_SETUP; */
        ucom->sc_dev = self;
        device_set_desc_copy(self, devinfo);
-       /* USB_ATTACH_SETUP; */
 
        ucom->sc_udev = dev;
        ucom->sc_iface = uaa->iface;
@@ -403,16 +404,17 @@ USB_ATTACH(ubsa)
        ucom_attach(ucom);
 
        kfree(devinfo, M_USBDEV);
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 
 error:
        kfree(devinfo, M_USBDEV);
-       USB_ATTACH_ERROR_RETURN;
+       return ENXIO;
 }
 
-USB_DETACH(ubsa)
+static int
+ubsa_detach(device_t self)
 {
-       USB_DETACH_START(ubsa, sc);
+       struct ubsa_softc *sc = device_get_softc(self);
        int rv;
 
 
index e1a2eba..c27730a 100644 (file)
@@ -27,7 +27,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/usb/udbp.c,v 1.24 2003/08/24 17:55:55 obrien Exp $
- * $DragonFly: src/sys/dev/usbmisc/udbp/Attic/udbp.c,v 1.13 2007/06/28 13:55:12 hasso Exp $
+ * $DragonFly: src/sys/dev/usbmisc/udbp/Attic/udbp.c,v 1.14 2007/07/01 21:24:03 hasso Exp $
  */
 
 /* Driver for arbitrary double bulk pipe devices.
@@ -218,9 +218,10 @@ static void udbp_out_transfer_cb   (usbd_xfer_handle xfer,
 
 USB_DECLARE_DRIVER(udbp);
 
-USB_MATCH(udbp)
+static int
+udbp_match(device_t self)
 {
-       USB_MATCH_START(udbp, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usb_interface_descriptor_t *id;
        if (!uaa->iface)
          return (UMATCH_NONE);
@@ -250,9 +251,11 @@ USB_MATCH(udbp)
        return (UMATCH_NONE);
 }
 
-USB_ATTACH(udbp)
+static int
+udbp_attach(device_t self)
 {
-       USB_ATTACH_START(udbp, sc, uaa);
+       struct udbp_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usbd_interface_handle iface = uaa->iface;
        usb_interface_descriptor_t *id;
        usb_endpoint_descriptor_t *ed, *ed_bulkin = NULL, *ed_bulkout = NULL;
@@ -266,7 +269,8 @@ USB_ATTACH(udbp)
        (void) usbd_device2interface_handle(uaa->device, 0, &iface);
        id = usbd_get_interface_descriptor(iface);
        usbd_devinfo(uaa->device, 0, devinfo);
-       USB_ATTACH_SETUP;
+       sc->sc_dev = self;
+       device_set_desc_copy(self, devinfo);
        kprintf("%s: %s, iclass %d/%d\n", device_get_nameunit(sc->sc_dev),
               devinfo, id->bInterfaceClass, id->bInterfaceSubClass);
 
@@ -276,7 +280,7 @@ USB_ATTACH(udbp)
                if (!ed) {
                        kprintf("%s: could not read endpoint descriptor\n",
                               device_get_nameunit(sc->sc_dev));
-                       USB_ATTACH_ERROR_RETURN;
+                       return ENXIO;
                }
 
                if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN
@@ -295,7 +299,7 @@ USB_ATTACH(udbp)
        if (ed_bulkin == NULL || ed_bulkout == NULL) {
                kprintf("%s: bulk-in and/or bulk-out endpoint not found\n",
                        device_get_nameunit(sc->sc_dev));
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        if (ed_bulkin->wMaxPacketSize[0] != ed_bulkout->wMaxPacketSize[0] ||
@@ -306,7 +310,7 @@ USB_ATTACH(udbp)
                       ed_bulkout->wMaxPacketSize[0],
                       ed_bulkin->wMaxPacketSize[1],
                       ed_bulkout->wMaxPacketSize[1]);
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        sc->sc_bulkin = ed_bulkin->bEndpointAddress;
@@ -389,7 +393,7 @@ USB_ATTACH(udbp)
        if (err) {
                goto bad;
        }
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 bad:
 #if 0 /* probably done in udbp_detach() */
                if (sc->sc_bulkout_buffer) {
@@ -406,13 +410,14 @@ bad:
                }
 #endif
                udbp_detach(self);
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
 }
 
 
-USB_DETACH(udbp)
+static int
+udbp_detach(device_t self)
 {
-       USB_DETACH_START(udbp, sc);
+       struct udbp_softc *sc = device_get_softc(self);
 
        sc->flags |= DISCONNECTED;
 
index 48e4c8f..8cf8a72 100644 (file)
@@ -30,7 +30,7 @@
 
 /*
  * $FreeBSD: src/sys/dev/usb/ufm.c,v 1.16 2003/10/04 21:41:01 joe Exp $
- * $DragonFly: src/sys/dev/usbmisc/ufm/ufm.c,v 1.16 2007/06/28 13:55:12 hasso Exp $
+ * $DragonFly: src/sys/dev/usbmisc/ufm/ufm.c,v 1.17 2007/07/01 21:24:03 hasso Exp $
  */
 
 #include <sys/param.h>
@@ -104,9 +104,10 @@ struct ufm_softc {
 
 USB_DECLARE_DRIVER(ufm);
 
-USB_MATCH(ufm)
+static int
+ufm_match(device_t self)
 {
-       USB_MATCH_START(ufm, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usb_device_descriptor_t *dd;
 
        DPRINTFN(10,("ufm_match\n"));
@@ -123,9 +124,11 @@ USB_MATCH(ufm)
                return UMATCH_NONE;
 }
 
-USB_ATTACH(ufm)
+static int
+ufm_attach(device_t self)
 {
-       USB_ATTACH_START(ufm, sc, uaa);
+       struct ufm_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        char devinfo[1024];
        usb_endpoint_descriptor_t *edesc;
        usbd_device_handle udev;
@@ -136,7 +139,8 @@ USB_ATTACH(ufm)
 
        DPRINTFN(10,("ufm_attach: sc=%p\n", sc));
        usbd_devinfo(uaa->device, 0, devinfo);
-       USB_ATTACH_SETUP;
+       sc->sc_dev = self;
+       device_set_desc_copy(self, devinfo);
        kprintf("%s: %s\n", device_get_nameunit(sc->sc_dev), devinfo);
 
        sc->sc_udev = udev = uaa->device;
@@ -170,11 +174,11 @@ USB_ATTACH(ufm)
 
        DPRINTFN(10, ("ufm_attach: %p\n", sc->sc_udev));
 
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 
  nobulk:
        kprintf("%s: could not find %s\n", device_get_nameunit(sc->sc_dev),ermsg);
-       USB_ATTACH_ERROR_RETURN;
+       return ENXIO;
 }
 
 
index 89b6b6f..acf009e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * $NetBSD: uftdi.c,v 1.13 2002/09/23 05:51:23 simonb Exp $
  * $FreeBSD: src/sys/dev/usb/uftdi.c,v 1.10 2003/08/24 17:55:55 obrien Exp $
- * $DragonFly: src/sys/dev/usbmisc/uftdi/uftdi.c,v 1.13 2007/06/28 13:55:12 hasso Exp $
+ * $DragonFly: src/sys/dev/usbmisc/uftdi/uftdi.c,v 1.14 2007/07/01 21:24:03 hasso Exp $
  */
 
 /*
@@ -137,9 +137,10 @@ struct ucom_callback uftdi_callback = {
        uftdi_write,
 };
 
-USB_MATCH(uftdi)
+static int
+uftdi_match(device_t self)
 {
-       USB_MATCH_START(uftdi, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
 
        if (uaa->iface != NULL)
                return (UMATCH_NONE);
@@ -155,9 +156,11 @@ USB_MATCH(uftdi)
        return (UMATCH_NONE);
 }
 
-USB_ATTACH(uftdi)
+static int
+uftdi_attach(device_t self)
 {
-       USB_ATTACH_START(uftdi, sc, uaa);
+       struct uftdi_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usbd_device_handle dev = uaa->device;
        usbd_interface_handle iface;
        usb_interface_descriptor_t *id;
@@ -262,14 +265,14 @@ USB_ATTACH(uftdi)
        ucom_attach(&sc->sc_ucom);
        kfree(devinfo, M_USBDEV);
 
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 
 bad:
        DPRINTF(("uftdi_attach: ATTACH ERROR\n"));
        ucom->sc_dying = 1;
        kfree(devinfo, M_USBDEV);
 
-       USB_ATTACH_ERROR_RETURN;
+       return ENXIO;
 }
 #if 0
 int
@@ -292,9 +295,10 @@ uftdi_activate(device_t self, enum devact act)
 }
 #endif
 #if 1
-USB_DETACH(uftdi)
+static int
+uftdi_detach(device_t self)
 {
-       USB_DETACH_START(uftdi, sc);
+       struct uftdi_softc *sc = device_get_softc(self);
 
        int rv = 0;
 
index b82fed2..5969a60 100644 (file)
@@ -2,7 +2,7 @@
  * $NetBSD: ugen.c,v 1.27 1999/10/28 12:08:38 augustss Exp $
  * $NetBSD: ugen.c,v 1.59 2002/07/11 21:14:28 augustss Exp $
  * $FreeBSD: src/sys/dev/usb/ugen.c,v 1.81 2003/11/09 09:17:22 tanimura Exp $
- * $DragonFly: src/sys/dev/usbmisc/ugen/ugen.c,v 1.28 2007/06/30 20:39:22 hasso Exp $
+ * $DragonFly: src/sys/dev/usbmisc/ugen/ugen.c,v 1.29 2007/07/01 21:24:03 hasso Exp $
  */
 
 /* 
@@ -177,9 +177,10 @@ static int ugen_get_alt_index(struct ugen_softc *sc, int ifaceidx);
 
 USB_DECLARE_DRIVER(ugen);
 
-USB_MATCH(ugen)
+static int
+ugen_match(device_t self)
 {
-       USB_MATCH_START(ugen, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
 
 #if 0
        if (uaa->matchlvl)
@@ -191,16 +192,19 @@ USB_MATCH(ugen)
                return (UMATCH_NONE);
 }
 
-USB_ATTACH(ugen)
+static int
+ugen_attach(device_t self)
 {
-       USB_ATTACH_START(ugen, sc, uaa);
+       struct ugen_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usbd_device_handle udev;
        char devinfo[1024];
        usbd_status err;
        int conf;
 
        usbd_devinfo(uaa->device, 0, devinfo);
-       USB_ATTACH_SETUP;
+       sc->sc_dev = self;
+       device_set_desc_copy(self, devinfo);
        kprintf("%s: %s\n", device_get_nameunit(sc->sc_dev), devinfo);
 
        sc->sc_udev = udev = uaa->device;
@@ -213,7 +217,7 @@ USB_ATTACH(ugen)
                kprintf("%s: setting configuration index 0 failed\n",
                       device_get_nameunit(sc->sc_dev));
                sc->sc_dying = 1;
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
        conf = usbd_get_config_descriptor(udev)->bConfigurationValue;
 
@@ -223,7 +227,7 @@ USB_ATTACH(ugen)
                kprintf("%s: setting configuration %d failed\n",
                       device_get_nameunit(sc->sc_dev), conf);
                sc->sc_dying = 1;
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        /* the main device, ctrl endpoint */
@@ -232,7 +236,7 @@ USB_ATTACH(ugen)
        make_dev(&ugen_ops, UGENMINOR(device_get_unit(sc->sc_dev), 0),
                UID_ROOT, GID_OPERATOR, 0644, "%s", device_get_nameunit(sc->sc_dev));
 
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 }
 
 static void
@@ -858,9 +862,10 @@ ugenwrite(struct dev_write_args *ap)
        return (error);
 }
 
-USB_DETACH(ugen)
+static int
+ugen_detach(device_t self)
 {
-       USB_DETACH_START(ugen, sc);
+       struct ugen_softc *sc = device_get_softc(self);
        struct ugen_endpoint *sce;
        int i, dir;
 
index 0c383a3..ae75869 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * $NetBSD: uhid.c,v 1.46 2001/11/13 06:24:55 lukem Exp $
  * $FreeBSD: src/sys/dev/usb/uhid.c,v 1.65 2003/11/09 09:17:22 tanimura Exp $
- * $DragonFly: src/sys/dev/usbmisc/uhid/uhid.c,v 1.25 2007/06/30 20:39:22 hasso Exp $
+ * $DragonFly: src/sys/dev/usbmisc/uhid/uhid.c,v 1.26 2007/07/01 21:24:03 hasso Exp $
  */
 
 /* Also already merged from NetBSD:
@@ -157,9 +157,10 @@ static int uhid_do_ioctl(struct uhid_softc *, u_long, caddr_t, int);
 
 USB_DECLARE_DRIVER(uhid);
 
-USB_MATCH(uhid)
+static int
+uhid_match(device_t self)
 {
-       USB_MATCH_START(uhid, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usb_interface_descriptor_t *id;
 
        if (uaa->iface == NULL)
@@ -172,9 +173,11 @@ USB_MATCH(uhid)
        return (UMATCH_IFACECLASS_GENERIC);
 }
 
-USB_ATTACH(uhid)
+static int
+uhid_attach(device_t self)
 {
-       USB_ATTACH_START(uhid, sc, uaa);
+       struct uhid_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usbd_interface_handle iface = uaa->iface;
        usb_interface_descriptor_t *id;
        usb_endpoint_descriptor_t *ed;
@@ -187,7 +190,8 @@ USB_ATTACH(uhid)
        sc->sc_iface = iface;
        id = usbd_get_interface_descriptor(iface);
        usbd_devinfo(uaa->device, 0, devinfo);
-       USB_ATTACH_SETUP;
+       sc->sc_dev = self;
+       device_set_desc_copy(self, devinfo);
        kprintf("%s: %s, iclass %d/%d\n", device_get_nameunit(sc->sc_dev),
               devinfo, id->bInterfaceClass, id->bInterfaceSubClass);
 
@@ -196,7 +200,7 @@ USB_ATTACH(uhid)
                kprintf("%s: could not read endpoint descriptor\n",
                       device_get_nameunit(sc->sc_dev));
                sc->sc_dying = 1;
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        DPRINTFN(10,("uhid_attach: bLength=%d bDescriptorType=%d "
@@ -212,7 +216,7 @@ USB_ATTACH(uhid)
            (ed->bmAttributes & UE_XFERTYPE) != UE_INTERRUPT) {
                kprintf("%s: unexpected endpoint\n", device_get_nameunit(sc->sc_dev));
                sc->sc_dying = 1;
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        sc->sc_ep_addr = ed->bEndpointAddress;
@@ -233,7 +237,7 @@ USB_ATTACH(uhid)
        if (err) {
                kprintf("%s: no report descriptor\n", device_get_nameunit(sc->sc_dev));
                sc->sc_dying = 1;
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        (void)usbd_set_idle(iface, 0, 0);
@@ -250,12 +254,13 @@ USB_ATTACH(uhid)
                UID_ROOT, GID_OPERATOR,
                0644, "uhid%d", device_get_unit(self));
 
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 }
 
-USB_DETACH(uhid)
+static int
+uhid_detach(device_t self)
 {
-       USB_DETACH_START(uhid, sc);
+       struct uhid_softc *sc = device_get_softc(self);
 
        DPRINTF(("uhid_detach: sc=%p\n", sc));
 
index a85e08f..f9e758b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * $FreeBSD: src/sys/dev/usb/ukbd.c,v 1.45 2003/10/04 21:41:01 joe Exp $
- * $DragonFly: src/sys/dev/usbmisc/ukbd/ukbd.c,v 1.21 2007/06/28 13:55:13 hasso Exp $
+ * $DragonFly: src/sys/dev/usbmisc/ukbd/ukbd.c,v 1.22 2007/07/01 21:24:03 hasso Exp $
  */
 
 /*
@@ -128,9 +128,10 @@ static keyboard_t  default_kbd;
 
 USB_DECLARE_DRIVER_INIT(ukbd, DEVMETHOD(device_resume, ukbd_resume));
 
-USB_MATCH(ukbd)
+static int
+ukbd_match(device_t self)
 {
-       USB_MATCH_START(ukbd, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
 
        keyboard_switch_t *sw;
        void *arg[2];
@@ -148,9 +149,11 @@ USB_MATCH(ukbd)
        return (UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO);
 }
 
-USB_ATTACH(ukbd)
+static int
+ukbd_attach(device_t self)
 {
-       USB_ATTACH_START(ukbd, sc, uaa);
+       struct ukbd_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usbd_interface_handle iface = uaa->iface;
        usb_interface_descriptor_t *id;
        char devinfo[1024];
@@ -162,11 +165,12 @@ USB_ATTACH(ukbd)
 
        sw = kbd_get_switch(DRIVER_NAME);
        if (sw == NULL)
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
 
        id = usbd_get_interface_descriptor(iface);
        usbd_devinfo(uaa->device, 0, devinfo);
-       USB_ATTACH_SETUP;
+       sc->sc_dev = self;
+       device_set_desc_copy(self, devinfo);
        kprintf("%s: %s, iclass %d/%d\n", device_get_nameunit(sc->sc_dev),
               devinfo, id->bInterfaceClass, id->bInterfaceSubClass);
 
@@ -174,19 +178,19 @@ USB_ATTACH(ukbd)
        arg[1] = (void *)ukbd_intr;
        kbd = NULL;
        if ((*sw->probe)(unit, (void *)arg, 0))
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        if ((*sw->init)(unit, &kbd, (void *)arg, 0))
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        (*sw->enable)(kbd);
 
 #ifdef KBD_INSTALL_CDEV
        if (kbd_attach(kbd))
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
 #endif
        if (bootverbose)
                (*sw->diag)(kbd, bootverbose);
 
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 }
 
 int
index 075b262..2cfe4b7 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * $NetBSD: ulpt.c,v 1.55 2002/10/23 09:14:01 jdolecek Exp $
  * $FreeBSD: src/sys/dev/usb/ulpt.c,v 1.59 2003/09/28 20:48:13 phk Exp $
- * $DragonFly: src/sys/dev/usbmisc/ulpt/ulpt.c,v 1.19 2007/06/28 13:55:13 hasso Exp $
+ * $DragonFly: src/sys/dev/usbmisc/ulpt/ulpt.c,v 1.20 2007/07/01 21:24:03 hasso Exp $
  */
 
 /*
@@ -151,9 +151,10 @@ void ieee1284_print_id(char *);
 
 USB_DECLARE_DRIVER(ulpt);
 
-USB_MATCH(ulpt)
+static int
+ulpt_match(device_t self)
 {
-       USB_MATCH_START(ulpt, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usb_interface_descriptor_t *id;
 
        DPRINTFN(10,("ulpt_match\n"));
@@ -170,9 +171,11 @@ USB_MATCH(ulpt)
        return (UMATCH_NONE);
 }
 
-USB_ATTACH(ulpt)
+static int
+ulpt_attach(device_t self)
 {
-       USB_ATTACH_START(ulpt, sc, uaa);
+       struct ulpt_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usbd_device_handle dev = uaa->device;
        usbd_interface_handle iface = uaa->iface;
        usb_interface_descriptor_t *ifcd = usbd_get_interface_descriptor(iface);
@@ -186,7 +189,8 @@ USB_ATTACH(ulpt)
 
        DPRINTFN(10,("ulpt_attach: sc=%p\n", sc));
        usbd_devinfo(dev, 0, devinfo);
-       USB_ATTACH_SETUP;
+       sc->sc_dev = self;
+       device_set_desc_copy(self, devinfo);
        kprintf("%s: %s, iclass %d/%d\n", device_get_nameunit(sc->sc_dev),
               devinfo, ifcd->bInterfaceClass, ifcd->bInterfaceSubClass);
 
@@ -197,7 +201,7 @@ USB_ATTACH(ulpt)
        if (cdesc == NULL) {
                kprintf("%s: failed to get configuration descriptor\n",
                       device_get_nameunit(sc->sc_dev));
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
        iend = (usb_interface_descriptor_t *)
                   ((char *)cdesc + UGETW(cdesc->wTotalLength));
@@ -230,7 +234,7 @@ USB_ATTACH(ulpt)
                        kprintf("%s: setting alternate interface failed\n",
                               device_get_nameunit(sc->sc_dev));
                        sc->sc_dying = 1;
-                       USB_ATTACH_ERROR_RETURN;
+                       return ENXIO;
                }
        }
 
@@ -244,7 +248,7 @@ USB_ATTACH(ulpt)
                if (ed == NULL) {
                        kprintf("%s: couldn't get ep %d\n",
                            device_get_nameunit(sc->sc_dev), i);
-                       USB_ATTACH_ERROR_RETURN;
+                       return ENXIO;
                }
                if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
                    UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
@@ -258,7 +262,7 @@ USB_ATTACH(ulpt)
                kprintf("%s: could not find bulk out endpoint\n",
                    device_get_nameunit(sc->sc_dev));
                sc->sc_dying = 1;
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        if (usbd_get_quirks(dev)->uq_flags & UQ_BROKEN_BIDIR) {
@@ -321,12 +325,13 @@ USB_ATTACH(ulpt)
        usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
                           sc->sc_dev);
 
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 }
 
-USB_DETACH(ulpt)
+static int
+ulpt_detach(device_t self)
 {
-       USB_DETACH_START(ulpt, sc);
+       struct ulpt_softc *sc = device_get_softc(self);
 
        DPRINTF(("ulpt_detach: sc=%p\n", sc));
 
index a773413..39c2e3e 100644 (file)
@@ -26,7 +26,7 @@
  *
  * $NetBSD: umass.c,v 1.28 2000/04/02 23:46:53 augustss Exp $
  * $FreeBSD: src/sys/dev/usb/umass.c,v 1.96 2003/12/19 12:19:11 sanpei Exp $
- * $DragonFly: src/sys/dev/usbmisc/umass/umass.c,v 1.25 2007/06/28 13:55:13 hasso Exp $
+ * $DragonFly: src/sys/dev/usbmisc/umass/umass.c,v 1.26 2007/07/01 21:24:03 hasso Exp $
  */
 
 /*
@@ -793,12 +793,13 @@ umass_match_proto(struct umass_softc *sc, usbd_interface_handle iface,
        return(UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO);
 }
 
-USB_MATCH(umass)
+static int
+umass_match(device_t self)
 {
-       USB_MATCH_START(umass, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        struct umass_softc *sc = device_get_softc(self);
 
-       USB_MATCH_SETUP;
+       sc->sc_dev = self;
 
        if (uaa->iface == NULL)
                return(UMATCH_NONE);
@@ -806,9 +807,11 @@ USB_MATCH(umass)
        return(umass_match_proto(sc, uaa->iface, uaa->device));
 }
 
-USB_ATTACH(umass)
+static int
+umass_attach(device_t self)
 {
-       USB_ATTACH_START(umass, sc, uaa);
+       struct umass_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usb_interface_descriptor_t *id;
        usb_endpoint_descriptor_t *ed;
        char devinfo[1024];
@@ -821,7 +824,8 @@ USB_ATTACH(umass)
         */
 
        usbd_devinfo(uaa->device, 0, devinfo);
-       USB_ATTACH_SETUP;
+       sc->sc_dev = self;
+       device_set_desc_copy(self, devinfo);
 
        sc->iface = uaa->iface;
        sc->ifaceno = uaa->ifaceno;
@@ -884,7 +888,7 @@ USB_ATTACH(umass)
                                "Alt Interface %d\n",
                                device_get_nameunit(sc->sc_dev), 1));
                        umass_detach(self);
-                       USB_ATTACH_ERROR_RETURN;
+                       return ENXIO;
                }
        }
 
@@ -904,7 +908,7 @@ USB_ATTACH(umass)
                if (!ed) {
                        kprintf("%s: could not read endpoint descriptor\n",
                               device_get_nameunit(sc->sc_dev));
-                       USB_ATTACH_ERROR_RETURN;
+                       return ENXIO;
                }
                if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN
                    && (ed->bmAttributes & UE_XFERTYPE) == UE_BULK) {
@@ -933,7 +937,7 @@ USB_ATTACH(umass)
                        device_get_nameunit(sc->sc_dev),
                        sc->bulkin, sc->bulkout, sc->intrin));
                umass_detach(self);
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        /* Open the bulk-in and -out pipe */
@@ -943,7 +947,7 @@ USB_ATTACH(umass)
                DPRINTF(UDMASS_USB, ("%s: cannot open %d-out pipe (bulk)\n",
                        device_get_nameunit(sc->sc_dev), sc->bulkout));
                umass_detach(self);
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
        err = usbd_open_pipe(sc->iface, sc->bulkin,
                                USBD_EXCLUSIVE_USE, &sc->bulkin_pipe);
@@ -951,7 +955,7 @@ USB_ATTACH(umass)
                DPRINTF(UDMASS_USB, ("%s: could not open %d-in pipe (bulk)\n",
                        device_get_nameunit(sc->sc_dev), sc->bulkin));
                umass_detach(self);
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
        /* Open the intr-in pipe if the protocol is CBI with CCI.
         * Note: early versions of the Zip drive do have an interrupt pipe, but
@@ -971,7 +975,7 @@ USB_ATTACH(umass)
                        DPRINTF(UDMASS_USB, ("%s: couldn't open %d-in (intr)\n",
                                device_get_nameunit(sc->sc_dev), sc->intrin));
                        umass_detach(self);
-                       USB_ATTACH_ERROR_RETURN;
+                       return ENXIO;
                }
        }
 
@@ -985,7 +989,7 @@ USB_ATTACH(umass)
                        DPRINTF(UDMASS_USB, ("%s: Out of memory\n",
                                device_get_nameunit(sc->sc_dev)));
                        umass_detach(self);
-                       USB_ATTACH_ERROR_RETURN;
+                       return ENXIO;
                }
        }
 
@@ -1043,14 +1047,14 @@ USB_ATTACH(umass)
                err = umass_cam_attach_sim(sc);
                if (err) {
                        umass_detach(self);
-                       USB_ATTACH_ERROR_RETURN;
+                       return ENXIO;
                }
                /* scan the new sim */
                err = umass_cam_attach(sc);
                if (err) {
                        umass_cam_detach_sim(sc);
                        umass_detach(self);
-                       USB_ATTACH_ERROR_RETURN;
+                       return ENXIO;
                }
        } else {
                panic("%s:%d: Unknown proto 0x%02x",
@@ -1060,12 +1064,13 @@ USB_ATTACH(umass)
        sc->transfer_state = TSTATE_IDLE;
        DPRINTF(UDMASS_GEN, ("%s: Attach finished\n", device_get_nameunit(sc->sc_dev)));
 
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 }
 
-USB_DETACH(umass)
+static int
+umass_detach(device_t self)
 {
-       USB_DETACH_START(umass, sc);
+       struct umass_softc *sc = device_get_softc(self);
        int err = 0;
        int i;
        int to;
index dbab5e2..06281a3 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/usb/umct.c,v 1.12 2006/09/07 00:06:42 imp Exp $
- * $DragonFly: src/sys/dev/usbmisc/umct/umct.c,v 1.9 2007/06/28 06:32:33 hasso Exp $
+ * $DragonFly: src/sys/dev/usbmisc/umct/umct.c,v 1.10 2007/07/01 21:24:03 hasso Exp $
  */
 
 /*
@@ -141,9 +141,10 @@ MODULE_DEPEND(umct, usb, 1, 1, 1);
 MODULE_DEPEND(umct, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER);
 MODULE_VERSION(umct, 1);
 
-USB_MATCH(umct)
+static int
+umct_match(device_t self)
 {
-       USB_MATCH_START(umct, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        int i;
 
        if (uaa->iface != NULL)
@@ -159,9 +160,11 @@ USB_MATCH(umct)
        return (UMATCH_NONE);
 }
 
-USB_ATTACH(umct)
+static int
+umct_attach(device_t self)
 {
-       USB_ATTACH_START(umct, sc, uaa);
+       struct umct_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usbd_device_handle dev;
        struct ucom_softc *ucom;
        usb_config_descriptor_t *cdesc;
@@ -277,16 +280,17 @@ USB_ATTACH(umct)
        ucom_attach(ucom);
 
        kfree(devinfo, M_USBDEV);
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 
 error:
        kfree(devinfo, M_USBDEV);
-       USB_ATTACH_ERROR_RETURN;
+       return ENXIO;
 }
 
-USB_DETACH(umct)
+static int
+umct_detach(device_t self)
 {
-       USB_DETACH_START(umct, sc);
+       struct umct_softc *sc = device_get_softc(self);
        int rv;
 
        if (sc->sc_intr_pipe != NULL) {
index 99b2e47..2e868dc 100644 (file)
@@ -2,7 +2,7 @@
  * $NetBSD: umodem.c,v 1.5 1999/01/08 11:58:25 augustss Exp $
  * $NetBSD: umodem.c,v 1.45 2002/09/23 05:51:23 simonb Exp $
  * $FreeBSD: src/sys/dev/usb/umodem.c,v 1.48 2003/08/24 17:55:55 obrien Exp $
- * $DragonFly: src/sys/dev/usbmisc/umodem/umodem.c,v 1.14 2007/06/28 13:55:13 hasso Exp $
+ * $DragonFly: src/sys/dev/usbmisc/umodem/umodem.c,v 1.15 2007/07/01 21:24:03 hasso Exp $
  */
 
 /*-
@@ -211,9 +211,10 @@ MODULE_DEPEND(umodem, usb, 1, 1, 1);
 MODULE_DEPEND(umodem, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER);
 MODULE_VERSION(umodem, UMODEM_MODVER);
 
-USB_MATCH(umodem)
+static int
+umodem_match(device_t self)
 {
-       USB_MATCH_START(umodem, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usb_interface_descriptor_t *id;
        int cm, acm;
 
@@ -236,9 +237,11 @@ USB_MATCH(umodem)
        return (UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO);
 }
 
-USB_ATTACH(umodem)
+static int
+umodem_attach(device_t self)
 {
-       USB_ATTACH_START(umodem, sc, uaa);
+       struct umodem_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usbd_device_handle dev = uaa->device;
        usb_interface_descriptor_t *id;
        usb_endpoint_descriptor_t *ed;
@@ -258,7 +261,6 @@ USB_ATTACH(umodem)
        device_set_desc_copy(self, devinfo);
        ucom->sc_udev = dev;
        ucom->sc_iface = uaa->iface;
-       /*USB_ATTACH_SETUP; */
 
        sc->sc_udev = dev;
        sc->sc_ctl_iface = uaa->iface;
@@ -390,12 +392,12 @@ USB_ATTACH(umodem)
        ucom_attach(&sc->sc_ucom);
 
        kfree(devinfo, M_USBDEV);
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 
  bad:
        ucom->sc_dying = 1;
        kfree(devinfo, M_USBDEV);
-       USB_ATTACH_ERROR_RETURN;
+       return ENXIO;
 }
 
 static int
@@ -775,9 +777,10 @@ umodem_set_comm_feature(struct umodem_softc *sc, int feature, int state)
        return (USBD_NORMAL_COMPLETION);
 }
 
-USB_DETACH(umodem)
+static int
+umodem_detach(device_t self)
 {
-       USB_DETACH_START(umodem, sc);
+       struct umodem_softc *sc = device_get_softc(self);
        int rv = 0;
 
        DPRINTF(("umodem_detach: sc=%p\n", sc));
index e00b3b5..b8ba93c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * $FreeBSD: src/sys/dev/usb/ums.c,v 1.64 2003/11/09 09:17:22 tanimura Exp $
- * $DragonFly: src/sys/dev/usbmisc/ums/ums.c,v 1.24 2007/06/28 13:55:13 hasso Exp $
+ * $DragonFly: src/sys/dev/usbmisc/ums/ums.c,v 1.25 2007/07/01 21:24:03 hasso Exp $
  */
 
 /*
@@ -157,9 +157,10 @@ static struct dev_ops ums_ops = {
 
 USB_DECLARE_DRIVER(ums);
 
-USB_MATCH(ums)
+static int
+ums_match(device_t self)
 {
-       USB_MATCH_START(ums, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usb_interface_descriptor_t *id;
        int size, ret;
        void *desc;
@@ -185,9 +186,11 @@ USB_MATCH(ums)
        return (ret);
 }
 
-USB_ATTACH(ums)
+static int
+ums_attach(device_t self)
 {
-       USB_ATTACH_START(ums, sc, uaa);
+       struct ums_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usbd_interface_handle iface = uaa->iface;
        usb_interface_descriptor_t *id;
        usb_endpoint_descriptor_t *ed;
@@ -203,14 +206,15 @@ USB_ATTACH(ums)
        sc->sc_iface = iface;
        id = usbd_get_interface_descriptor(iface);
        usbd_devinfo(uaa->device, 0, devinfo);
-       USB_ATTACH_SETUP;
+       sc->sc_dev = self;
+       device_set_desc_copy(self, devinfo);
        kprintf("%s: %s, iclass %d/%d\n", device_get_nameunit(sc->sc_dev),
               devinfo, id->bInterfaceClass, id->bInterfaceSubClass);
        ed = usbd_interface2endpoint_descriptor(iface, 0);
        if (!ed) {
                kprintf("%s: could not read endpoint descriptor\n",
                       device_get_nameunit(sc->sc_dev));
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        DPRINTFN(10,("ums_attach: bLength=%d bDescriptorType=%d "
@@ -226,33 +230,33 @@ USB_ATTACH(ums)
            UE_GET_XFERTYPE(ed->bmAttributes) != UE_INTERRUPT) {
                kprintf("%s: unexpected endpoint\n",
                       device_get_nameunit(sc->sc_dev));
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        err = usbd_read_report_desc(uaa->iface, &desc, &size, M_TEMP);
        if (err)
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
 
        if (!hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X),
                       hid_input, &sc->sc_loc_x, &flags)) {
                kprintf("%s: mouse has no X report\n", device_get_nameunit(sc->sc_dev));
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
        if ((flags & MOUSE_FLAGS_MASK) != MOUSE_FLAGS) {
                kprintf("%s: X report 0x%04x not supported\n",
                       device_get_nameunit(sc->sc_dev), flags);
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        if (!hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y),
                       hid_input, &sc->sc_loc_y, &flags)) {
                kprintf("%s: mouse has no Y report\n", device_get_nameunit(sc->sc_dev));
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
        if ((flags & MOUSE_FLAGS_MASK) != MOUSE_FLAGS) {
                kprintf("%s: Y report 0x%04x not supported\n",
                       device_get_nameunit(sc->sc_dev), flags);
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        /* try to guess the Z activator: first check Z, then WHEEL */
@@ -337,7 +341,7 @@ USB_ATTACH(ums)
                sc->flags |= UMS_SPUR_BUT_UP;
        }
 
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 }
 
 
index 1458690..053beb8 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * $NetBSD: uplcom.c,v 1.21 2001/11/13 06:24:56 lukem Exp $
  * $FreeBSD: src/sys/dev/usb/uplcom.c,v 1.39 2006/09/07 00:06:42 imp Exp $
- * $DragonFly: src/sys/dev/usbmisc/uplcom/uplcom.c,v 1.13 2007/06/28 13:55:13 hasso Exp $
+ * $DragonFly: src/sys/dev/usbmisc/uplcom/uplcom.c,v 1.14 2007/07/01 21:24:04 hasso Exp $
  */
 
 /*-
@@ -312,9 +312,10 @@ SYSCTL_PROC(_hw_usb_uplcom, OID_AUTO, interval, CTLTYPE_INT | CTLFLAG_RW,
            0, sizeof(int), sysctl_hw_usb_uplcom_interval,
            "I", "uplcom interrupt pipe interval");
 
-USB_MATCH(uplcom)
+static int
+uplcom_match(device_t self)
 {
-       USB_MATCH_START(uplcom, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        int i;
 
        if (uaa->iface != NULL)
@@ -331,9 +332,11 @@ USB_MATCH(uplcom)
        return (UMATCH_NONE);
 }
 
-USB_ATTACH(uplcom)
+static int
+uplcom_attach(device_t self)
 {
-       USB_ATTACH_START(uplcom, sc, uaa);
+       struct uplcom_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usbd_device_handle dev = uaa->device;
        struct ucom_softc *ucom;
        usb_config_descriptor_t *cdesc;
@@ -350,10 +353,8 @@ USB_ATTACH(uplcom)
        bzero(sc, sizeof (struct uplcom_softc));
 
        usbd_devinfo(dev, 0, devinfo);
-       /* USB_ATTACH_SETUP; */
        ucom->sc_dev = self;
        device_set_desc_copy(self, devinfo);
-       /* USB_ATTACH_SETUP; */
 
        ucom->sc_udev = dev;
        ucom->sc_iface = uaa->iface;
@@ -545,16 +546,17 @@ USB_ATTACH(uplcom)
        ucom_attach(&sc->sc_ucom);
 
        kfree(devinfo, M_USBDEV);
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 
 error:
        kfree(devinfo, M_USBDEV);
-       USB_ATTACH_ERROR_RETURN;
+       return ENXIO;
 }
 
-USB_DETACH(uplcom)
+static int
+uplcom_detach(device_t self)
 {
-       USB_DETACH_START(uplcom, sc);
+       struct uplcom_softc *sc = device_get_softc(self);
        int rv = 0;
 
        DPRINTF(("uplcom_detach: sc = %p\n", sc));
index 644dba2..de32514 100644 (file)
@@ -30,7 +30,7 @@
 
 /*
  * $FreeBSD: src/sys/dev/usb/urio.c,v 1.28 2003/08/25 22:01:06 joe Exp $
- * $DragonFly: src/sys/dev/usbmisc/urio/urio.c,v 1.19 2007/06/28 13:55:13 hasso Exp $
+ * $DragonFly: src/sys/dev/usbmisc/urio/urio.c,v 1.20 2007/07/01 21:24:04 hasso Exp $
  */
 
 /*
@@ -132,9 +132,10 @@ struct urio_softc {
 
 USB_DECLARE_DRIVER(urio);
 
-USB_MATCH(urio)
+static int
+urio_match(device_t self)
 {
-       USB_MATCH_START(urio, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usb_device_descriptor_t *dd;
 
        DPRINTFN(10,("urio_match\n"));
@@ -154,9 +155,11 @@ USB_MATCH(urio)
                return UMATCH_NONE;
 }
 
-USB_ATTACH(urio)
+static int
+urio_attach(device_t self)
 {
-       USB_ATTACH_START(urio, sc, uaa);
+       struct urio_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        char devinfo[1024];
        usbd_device_handle udev;
        usbd_interface_handle iface;
@@ -167,7 +170,8 @@ USB_ATTACH(urio)
 
        DPRINTFN(10,("urio_attach: sc=%p\n", sc));
        usbd_devinfo(uaa->device, 0, devinfo);
-       USB_ATTACH_SETUP;
+       sc->sc_dev = self;
+       device_set_desc_copy(self, devinfo);
        kprintf("%s: %s\n", device_get_nameunit(sc->sc_dev), devinfo);
 
        sc->sc_udev = udev = uaa->device;
@@ -218,11 +222,11 @@ USB_ATTACH(urio)
 
        DPRINTFN(10, ("urio_attach: %p\n", sc->sc_udev));
 
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 
  nobulk:
        kprintf("%s: could not find %s\n", device_get_nameunit(sc->sc_dev),ermsg);
-       USB_ATTACH_ERROR_RETURN;
+       return ENXIO;
 }
 
 
index 23bb9fa..9e41783 100644 (file)
@@ -1,7 +1,7 @@
 /* 
  * $NetBSD: uscanner.c,v 1.30 2002/07/11 21:14:36 augustss Exp $
  * $FreeBSD: src/sys/dev/usb/uscanner.c,v 1.48 2003/12/22 19:58:27 sanpei Exp $
- * $DragonFly: src/sys/dev/usbmisc/uscanner/uscanner.c,v 1.19 2007/06/28 13:55:13 hasso Exp $
+ * $DragonFly: src/sys/dev/usbmisc/uscanner/uscanner.c,v 1.20 2007/07/01 21:24:04 hasso Exp $
  */
 
 /* Also already merged from NetBSD:
@@ -271,9 +271,10 @@ static void uscanner_do_close(struct uscanner_softc *);
 
 USB_DECLARE_DRIVER(uscanner);
 
-USB_MATCH(uscanner)
+static int
+uscanner_match(device_t self)
 {
-       USB_MATCH_START(uscanner, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
 
        if (uaa->iface != NULL)
                return UMATCH_NONE;
@@ -282,9 +283,11 @@ USB_MATCH(uscanner)
                UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
 }
 
-USB_ATTACH(uscanner)
+static int
+uscanner_attach(device_t self)
 {
-       USB_ATTACH_START(uscanner, sc, uaa);
+       struct uscanner_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usb_interface_descriptor_t *id = 0;
        usb_endpoint_descriptor_t *ed, *ed_bulkin = NULL, *ed_bulkout = NULL;
        char devinfo[1024];
@@ -292,7 +295,8 @@ USB_ATTACH(uscanner)
        usbd_status err;
 
        usbd_devinfo(uaa->device, 0, devinfo);
-       USB_ATTACH_SETUP;
+       sc->sc_dev = self;
+       device_set_desc_copy(self, devinfo);
        kprintf("%s: %s\n", device_get_nameunit(sc->sc_dev), devinfo);
 
        sc->sc_dev_flags = uscanner_lookup(uaa->vendor, uaa->product)->flags;
@@ -303,7 +307,7 @@ USB_ATTACH(uscanner)
        if (err) {
                kprintf("%s: setting config no failed\n",
                    device_get_nameunit(sc->sc_dev));
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        /* XXX We only check the first interface */
@@ -313,7 +317,7 @@ USB_ATTACH(uscanner)
        if (err || id == 0) {
                kprintf("%s: could not get interface descriptor, err=%d,id=%p\n",
                       device_get_nameunit(sc->sc_dev), err, id);
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        /* Find the two first bulk endpoints */
@@ -322,7 +326,7 @@ USB_ATTACH(uscanner)
                if (ed == 0) {
                        kprintf("%s: could not read endpoint descriptor\n",
                               device_get_nameunit(sc->sc_dev));
-                       USB_ATTACH_ERROR_RETURN;
+                       return ENXIO;
                }
 
                if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN
@@ -341,7 +345,7 @@ USB_ATTACH(uscanner)
        if (ed_bulkin == NULL || ed_bulkout == NULL) {
                kprintf("%s: bulk-in and/or bulk-out endpoint not found\n",
                        device_get_nameunit(sc->sc_dev));
-               USB_ATTACH_ERROR_RETURN;
+               return ENXIO;
        }
 
        sc->sc_bulkin = ed_bulkin->bEndpointAddress;
@@ -355,7 +359,7 @@ USB_ATTACH(uscanner)
        usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
                           sc->sc_dev);
 
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 }
 
 int
@@ -588,9 +592,10 @@ uscannerwrite(struct dev_write_args *ap)
        return (error);
 }
 
-USB_DETACH(uscanner)
+static int
+uscanner_detach(device_t self)
 {
-       USB_DETACH_START(uscanner, sc);
+       struct uscanner_softc *sc = device_get_softc(self);
 
        DPRINTF(("uscanner_detach: sc=%p\n", sc));
 
index f8f2531..7854880 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * $NetBSD: uvisor.c,v 1.9 2001/01/23 14:04:14 augustss Exp $
  * $FreeBSD: src/sys/dev/usb/uvisor.c,v 1.16 2003/11/08 11:23:07 joe Exp $
- * $DragonFly: src/sys/dev/usbmisc/uvisor/uvisor.c,v 1.12 2007/06/28 06:32:33 hasso Exp $
+ * $DragonFly: src/sys/dev/usbmisc/uvisor/uvisor.c,v 1.13 2007/07/01 21:24:04 hasso Exp $
  */
 
 /*
@@ -225,9 +225,10 @@ static const struct uvisor_type uvisor_devs[] = {
 #define uvisor_lookup(v, p) ((const struct uvisor_type *)usb_lookup(uvisor_devs, v, p))
 
 
-USB_MATCH(uvisor)
+static int
+uvisor_match(device_t self)
 {
-       USB_MATCH_START(uvisor, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
 
        if (uaa->iface != NULL)
                return (UMATCH_NONE);
@@ -239,9 +240,11 @@ USB_MATCH(uvisor)
                UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
 }
 
-USB_ATTACH(uvisor)
+static int
+uvisor_attach(device_t self)
 {
-       USB_ATTACH_START(uvisor, sc, uaa);
+       struct uvisor_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usbd_device_handle dev = uaa->device;
        usbd_interface_handle iface;
        usb_interface_descriptor_t *id;
@@ -348,12 +351,12 @@ USB_ATTACH(uvisor)
        DPRINTF(("uvisor: in=0x%x out=0x%x\n", ucom->sc_bulkin_no, ucom->sc_bulkout_no));
        ucom_attach(&sc->sc_ucom);
 
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 
 bad:
        DPRINTF(("uvisor_attach: ATTACH ERROR\n"));
        ucom->sc_dying = 1;
-       USB_ATTACH_ERROR_RETURN;
+       return ENXIO;
 }
 
 #if 0
@@ -380,9 +383,10 @@ uvisor_activate(device_t self, enum devact act)
 
 #endif
 
-USB_DETACH(uvisor)
+static int
+uvisor_detach(device_t self)
 {
-       USB_DETACH_START(uvisor, sc);
+       struct uvisor_softc *sc = device_get_softc(self);
        int rv = 0;
 
        DPRINTF(("uvisor_detach: sc=%p\n", sc));
index 292684b..a37ab07 100644 (file)
@@ -25,7 +25,7 @@
  *
  * $NetBSD: usb/uvscom.c,v 1.1 2002/03/19 15:08:42 augustss Exp $
  * $FreeBSD: src/sys/dev/usb/uvscom.c,v 1.19 2003/11/16 12:26:10 akiyama Exp $
- * $DragonFly: src/sys/dev/usbmisc/uvscom/uvscom.c,v 1.12 2007/06/28 13:55:13 hasso Exp $
+ * $DragonFly: src/sys/dev/usbmisc/uvscom/uvscom.c,v 1.13 2007/07/01 21:24:04 hasso Exp $
  */
 
 /*
@@ -233,9 +233,10 @@ DRIVER_MODULE(uvscom, uhub, uvscom_driver, ucom_devclass, usbd_driver_load, 0);
 MODULE_DEPEND(uvscom, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER);
 MODULE_VERSION(uvscom, UVSCOM_MODVER);
 
-USB_MATCH(uvscom)
+static int
+uvscom_match(device_t self)
 {
-       USB_MATCH_START(uvscom, uaa);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
 
        if (uaa->iface != NULL)
                return (UMATCH_NONE);
@@ -244,9 +245,11 @@ USB_MATCH(uvscom)
                UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
 }
 
-USB_ATTACH(uvscom)
+static int
+uvscom_attach(device_t self)
 {
-       USB_ATTACH_START(uvscom, sc, uaa);
+       struct uvscom_softc *sc = device_get_softc(self);
+       struct usb_attach_arg *uaa = device_get_ivars(self);
        usbd_device_handle dev = uaa->device;
        struct ucom_softc *ucom;
        usb_config_descriptor_t *cdesc;
@@ -263,10 +266,8 @@ USB_ATTACH(uvscom)
        bzero(sc, sizeof (struct uvscom_softc));
 
        usbd_devinfo(dev, 0, devinfo);
-       /* USB_ATTACH_SETUP; */
        ucom->sc_dev = self;
        device_set_desc_copy(self, devinfo);
-       /* USB_ATTACH_SETUP; */
 
        ucom->sc_udev = dev;
        ucom->sc_iface = uaa->iface;
@@ -374,17 +375,18 @@ USB_ATTACH(uvscom)
        ucom_attach(&sc->sc_ucom);
 
        kfree(devinfo, M_USBDEV);
-       USB_ATTACH_SUCCESS_RETURN;
+       return 0;
 
 error:
        ucom->sc_dying = 1;
        kfree(devinfo, M_USBDEV);
-       USB_ATTACH_ERROR_RETURN;
+       return ENXIO;
 }
 
-USB_DETACH(uvscom)
+static int
+uvscom_detach(device_t self)
 {
-       USB_DETACH_START(uvscom, sc);
+       struct uvscom_softc *sc = device_get_softc(self);
        int rv = 0;
 
        DPRINTF(("uvscom_detach: sc = %p\n", sc));