Module Name:    src
Committed By:   dyoung
Date:           Wed Nov  3 23:46:35 UTC 2010

Modified Files:
        src/sys/dev/usb: moscom.c uark.c uhmodem.c uyurex.c xboxcontroller.c

Log Message:
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera.  These files produce the same assembly
(according to objdump -d) before and after the change, except for minor
differences in moscom.c, uark.c, and xboxcontroller.c which I traced
to line-number shifts and KASSERT() invocation in the child-detachment
routines---e.g., moscom_childdet().


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/usb/moscom.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/usb/uark.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/usb/uhmodem.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/usb/uyurex.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/usb/xboxcontroller.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/moscom.c
diff -u src/sys/dev/usb/moscom.c:1.3 src/sys/dev/usb/moscom.c:1.4
--- src/sys/dev/usb/moscom.c:1.3	Thu Nov 12 19:53:14 2009
+++ src/sys/dev/usb/moscom.c	Wed Nov  3 23:46:35 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: moscom.c,v 1.3 2009/11/12 19:53:14 dyoung Exp $	*/
+/*	$NetBSD: moscom.c,v 1.4 2010/11/03 23:46:35 dyoung Exp $	*/
 /*	$OpenBSD: moscom.c,v 1.11 2007/10/11 18:33:14 deraadt Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: moscom.c,v 1.3 2009/11/12 19:53:14 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: moscom.c,v 1.4 2010/11/03 23:46:35 dyoung Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -35,6 +35,8 @@
 #include <dev/usb/usbdevs.h>
 #include <dev/usb/ucomvar.h>
 
+#include <dev/usb/usb_port.h>
+
 #define MOSCOMBUFSZ		256
 #define MOSCOM_CONFIG_NO	0
 #define MOSCOM_IFACE_NO		0
@@ -137,10 +139,10 @@
 #define MOSCOM_BAUD_REF		115200
 
 struct moscom_softc {
-	USBBASEDEVICE		 sc_dev;
+	device_t		 sc_dev;
 	usbd_device_handle	 sc_udev;
 	usbd_interface_handle	 sc_iface;
-	device_ptr_t		 sc_subdev;
+	device_t		 sc_subdev;
 
 	u_char			 sc_msr;
 	u_char			 sc_lsr;
@@ -181,17 +183,20 @@
 CFATTACH_DECL2_NEW(moscom, sizeof(struct moscom_softc), moscom_match,
     moscom_attach, moscom_detach, moscom_activate, NULL, moscom_childdet);
 
-USB_MATCH(moscom)
+int 
+moscom_match(device_t parent, cfdata_t match, void *aux)
 {
-	USB_MATCH_START(moscom, uaa);
+	struct usb_attach_arg *uaa = aux;
 
 	return (moscom_lookup(uaa->vendor, uaa->product) != NULL ?
 		UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
 }
 
-USB_ATTACH(moscom)
+void 
+moscom_attach(device_t parent, device_t self, void *aux)
 {
-	USB_ATTACH_START(moscom, sc, uaa);
+	struct moscom_softc *sc = device_private(self);
+	struct usb_attach_arg *uaa = aux;
 	usbd_device_handle dev = uaa->device;
 	struct ucom_attach_args uca;
 	usb_interface_descriptor_t *id;
@@ -264,12 +269,12 @@
 	uca.info = NULL;
 
 	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
-	    USBDEV(sc->sc_dev));
+	    sc->sc_dev);
 	
 	sc->sc_subdev = config_found_sm_loc(self, "ucombus", NULL, &uca,
 					    ucomprint, ucomsubmatch);
 
-	USB_ATTACH_SUCCESS_RETURN;
+	return;
 }
 
 void
@@ -281,9 +286,10 @@
 	sc->sc_subdev = NULL;
 }
 
-USB_DETACH(moscom)
+int 
+moscom_detach(device_t self, int flags)
 {
-	USB_DETACH_START(moscom, sc);
+	struct moscom_softc *sc = device_private(self);
 	int rv = 0;
 
 	sc->sc_dying = 1;
@@ -291,7 +297,7 @@
 		rv = config_detach(sc->sc_subdev, flags);
 
 	usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
-			   USBDEV(sc->sc_dev));
+			   sc->sc_dev);
 
 	return (rv);
 }

Index: src/sys/dev/usb/uark.c
diff -u src/sys/dev/usb/uark.c:1.1 src/sys/dev/usb/uark.c:1.2
--- src/sys/dev/usb/uark.c:1.1	Sat May 29 17:39:41 2010
+++ src/sys/dev/usb/uark.c	Wed Nov  3 23:46:35 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: uark.c,v 1.1 2010/05/29 17:39:41 martin Exp $	*/
+/*	$NetBSD: uark.c,v 1.2 2010/11/03 23:46:35 dyoung Exp $	*/
 /*	$OpenBSD: uark.c,v 1.13 2009/10/13 19:33:17 pirofti Exp $	*/
 
 /*
@@ -29,9 +29,10 @@
 #include <dev/usb/usbdi_util.h>
 #include <dev/usb/usbdevs.h>
 
-#include <dev/usb/usbdevs.h>
 #include <dev/usb/ucomvar.h>
 
+#include <dev/usb/usb_port.h>
+
 #ifdef UARK_DEBUG
 #define DPRINTFN(n, x)  do { if (uarkdebug > (n)) printf x; } while (0)
 int	uarkebug = 0;
@@ -93,19 +94,27 @@
 	{ USB_VENDOR_ARKMICROCHIPS, USB_PRODUCT_ARKMICROCHIPS_USBSERIAL },
 };
 
-USB_DECLARE_DRIVER(uark);
+int             uark_match(device_t, cfdata_t, void *);
+void            uark_attach(device_t, device_t, void *);
+int             uark_detach(device_t, int);
+int             uark_activate(device_t, enum devact);
+extern struct cfdriver uark_cd;
+CFATTACH_DECL_NEW(uark, sizeof(struct uark_softc), uark_match, uark_attach, uark_detach, uark_activate);
 
-USB_MATCH(uark)
+int 
+uark_match(device_t parent, cfdata_t match, void *aux)
 {
-	USB_MATCH_START(uarkcom, uaa);
+	struct usb_attach_arg *uaa = aux;
 
 	return (usb_lookup(uark_devs, uaa->vendor, uaa->product) != NULL) ?
 	    UMATCH_VENDOR_PRODUCT : UMATCH_NONE;
 }
 
-USB_ATTACH(uark)
+void 
+uark_attach(device_t parent, device_t self, void *aux)
 {
-	USB_ATTACH_START(uark, sc, uaa);
+	struct uark_softc *sc = device_private(self);
+	struct usb_attach_arg *uaa = aux;
 	usbd_device_handle dev = uaa->device;
 	char *devinfop;
 	struct ucom_attach_args uca;
@@ -118,7 +127,8 @@
 	sc->sc_dev = self;
 
 	devinfop = usbd_devinfo_alloc(dev, 0);
-	USB_ATTACH_SETUP;
+	aprint_naive("\n");
+	aprint_normal("\n");
 	aprint_normal_dev(self, "%s\n", devinfop);
 	usbd_devinfo_free(devinfop);
 
@@ -181,7 +191,7 @@
 	sc->sc_subdev = config_found_sm_loc(self, "ucombus", NULL, &uca,
 					    ucomprint, ucomsubmatch);
 
-	USB_ATTACH_SUCCESS_RETURN;
+	return;
 }
 
 int

Index: src/sys/dev/usb/uhmodem.c
diff -u src/sys/dev/usb/uhmodem.c:1.9 src/sys/dev/usb/uhmodem.c:1.10
--- src/sys/dev/usb/uhmodem.c:1.9	Thu Nov 12 19:58:27 2009
+++ src/sys/dev/usb/uhmodem.c	Wed Nov  3 23:46:35 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhmodem.c,v 1.9 2009/11/12 19:58:27 dyoung Exp $	*/
+/*	$NetBSD: uhmodem.c,v 1.10 2010/11/03 23:46:35 dyoung Exp $	*/
 
 /*
  * Copyright (c) 2008 Yojiro UO <y...@nui.org>.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhmodem.c,v 1.9 2009/11/12 19:58:27 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhmodem.c,v 1.10 2010/11/03 23:46:35 dyoung Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -94,6 +94,8 @@
 #include <dev/usb/usbdi_util.h>
 #include <dev/usb/usbdivar.h>
 
+#include <dev/usb/usb_port.h>
+
 #include <dev/usb/usbcdc.h>
 #include <dev/usb/usbdevs.h>
 #include <dev/usb/usb_quirks.h>
@@ -112,7 +114,7 @@
 Static int	uhmodemdebug = 0;
 #define DPRINTFN(n, x)  do { \
 				if (uhmodemdebug > (n)) \
-					logprintf x; \
+					printf x; \
 			} while (0)
 #else
 #define DPRINTFN(n, x)
@@ -174,9 +176,10 @@
 CFATTACH_DECL2_NEW(uhmodem, sizeof(struct uhmodem_softc), uhmodem_match,
     uhmodem_attach, uhmodem_detach, uhmodem_activate, NULL, uhmodem_childdet);
 
-USB_MATCH(uhmodem)
+int 
+uhmodem_match(device_t parent, cfdata_t match, void *aux)
 {
-	USB_IFMATCH_START(uhmodem, uaa);
+	struct usbif_attach_arg *uaa = aux;
 
 	if (uhmodem_lookup(uaa->vendor, uaa->product) != NULL)
 		/* XXX interface# 0,1 provide modem function, but this driver
@@ -186,9 +189,11 @@
 	return (UMATCH_NONE);
 }
 
-USB_ATTACH(uhmodem)
+void 
+uhmodem_attach(device_t parent, device_t self, void *aux)
 {
-	USB_IFATTACH_START(uhmodem, sc, uaa);
+	struct uhmodem_softc *sc = device_private(self);
+	struct usbif_attach_arg *uaa = aux;
 	usbd_device_handle dev = uaa->device;
 	usb_config_descriptor_t *cdesc;
 	usb_interface_descriptor_t *id;
@@ -369,12 +374,12 @@
 	} /* end of Interface loop */
 
 	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_ubsa.sc_udev,
-			   USBDEV(sc->sc_ubsa.sc_dev));
+			   sc->sc_ubsa.sc_dev);
 
-	USB_ATTACH_SUCCESS_RETURN;
+	return;
 
 error:
-	USB_ATTACH_ERROR_RETURN;
+	return;
 }
 
 void
@@ -391,9 +396,10 @@
 	sc->sc_ubsa.sc_subdevs[i] = NULL;
 }
 
-USB_DETACH(uhmodem)
+int 
+uhmodem_detach(device_t self, int flags)
 {
-	USB_DETACH_START(uhmodem, sc);
+	struct uhmodem_softc *sc = device_private(self);
 	int i;
 	int rv = 0;
 
@@ -413,7 +419,7 @@
 	}
 
 	usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_ubsa.sc_udev,
-			   USBDEV(sc->sc_ubsa.sc_dev));
+			   sc->sc_ubsa.sc_dev);
 
 	return (rv);
 }

Index: src/sys/dev/usb/uyurex.c
diff -u src/sys/dev/usb/uyurex.c:1.2 src/sys/dev/usb/uyurex.c:1.3
--- src/sys/dev/usb/uyurex.c:1.2	Mon Mar 15 03:27:49 2010
+++ src/sys/dev/usb/uyurex.c	Wed Nov  3 23:46:35 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: uyurex.c,v 1.2 2010/03/15 03:27:49 enami Exp $ */
+/*	$NetBSD: uyurex.c,v 1.3 2010/11/03 23:46:35 dyoung Exp $ */
 /*	$OpenBSD: uyurex.c,v 1.3 2010/03/04 03:47:22 deraadt Exp $ */
 
 /*
@@ -38,6 +38,8 @@
 #include <dev/usb/uhidev.h>
 #include <dev/usb/hid.h>
 
+#include <dev/usb/usb_port.h>
+
 #ifdef USB_DEBUG
 #define UYUREX_DEBUG
 #endif
@@ -112,9 +114,10 @@
 CFATTACH_DECL_NEW(uyurex, sizeof(struct uyurex_softc),
     uyurex_match, uyurex_attach, uyurex_detach, uyurex_activate);
 
-USB_MATCH(uyurex)
+int 
+uyurex_match(device_t parent, cfdata_t match, void *aux)
 {
-	USB_MATCH_START(uyurex, uaa);
+	struct usb_attach_arg *uaa = aux;
 	struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)uaa;
 
 	if (uyurex_lookup(uha->uaa->vendor, uha->uaa->product) == NULL)
@@ -123,9 +126,11 @@
 	return (UMATCH_VENDOR_PRODUCT);
 }
 
-USB_ATTACH(uyurex)
+void 
+uyurex_attach(device_t parent, device_t self, void *aux)
 {
-	USB_ATTACH_START(uyurex, sc, uaa);
+	struct uyurex_softc *sc = device_private(self);
+	struct usb_attach_arg *uaa = aux;
 	struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)uaa;
 	usbd_device_handle dev = uha->parent->sc_udev;
 	int size, repid, err;
@@ -194,9 +199,10 @@
 	uyurex_set_mode(sc, 0);
 }
 
-USB_DETACH(uyurex)
+int 
+uyurex_detach(device_t self, int flags)
 {
-	USB_DETACH_START(uyurex, sc);
+	struct uyurex_softc *sc = device_private(self);
 	int rv = 0;
 
 	sc->sc_dying = 1;

Index: src/sys/dev/usb/xboxcontroller.c
diff -u src/sys/dev/usb/xboxcontroller.c:1.12 src/sys/dev/usb/xboxcontroller.c:1.13
--- src/sys/dev/usb/xboxcontroller.c:1.12	Thu Nov 12 20:01:15 2009
+++ src/sys/dev/usb/xboxcontroller.c	Wed Nov  3 23:46:35 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: xboxcontroller.c,v 1.12 2009/11/12 20:01:15 dyoung Exp $ */
+/* $NetBSD: xboxcontroller.c,v 1.13 2010/11/03 23:46:35 dyoung Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcne...@invisible.ca>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xboxcontroller.c,v 1.12 2009/11/12 20:01:15 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xboxcontroller.c,v 1.13 2010/11/03 23:46:35 dyoung Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -44,10 +44,12 @@
 #include <dev/usb/usbdi_util.h>
 #include <dev/usb/usbdevs.h>
 
+#include <dev/usb/usb_port.h>
+
 #define XBOX_CONTROLLER_BUFSZ	32
 
 struct xboxcontroller_softc {
-	USBBASEDEVICE		sc_dev;
+	device_t		sc_dev;
 
 	usbd_device_handle	sc_udev;
 	usbd_interface_handle	sc_iface;
@@ -88,9 +90,10 @@
     xboxcontroller_match, xboxcontroller_attach, xboxcontroller_detach,
     xboxcontroller_activate, NULL, xboxcontroller_childdet);
 
-USB_MATCH(xboxcontroller)
+int 
+xboxcontroller_match(device_t parent, cfdata_t match, void *aux)
 {
-	USB_MATCH_START(xboxcontroller, uaa);
+	struct usb_attach_arg *uaa = aux;
 
 	if (uaa->vendor == USB_VENDOR_MICROSOFT) {
 		switch (uaa->product) {
@@ -103,9 +106,11 @@
 	return UMATCH_NONE;
 }
 
-USB_ATTACH(xboxcontroller)
+void 
+xboxcontroller_attach(device_t parent, device_t self, void *aux)
 {
-	USB_ATTACH_START(xboxcontroller, sc, uaa);
+	struct xboxcontroller_softc *sc = device_private(self);
+	struct usb_attach_arg *uaa = aux;
 	usbd_device_handle dev = uaa->device;
 	usbd_status err;
 	struct wsmousedev_attach_args waa;
@@ -131,26 +136,26 @@
 		aprint_error_dev(self, "setting config no failed: %s\n",
 		    usbd_errstr(err));
 		sc->sc_dying = 1;
-		USB_ATTACH_ERROR_RETURN;
+		return;
 	}
 	err = usbd_device2interface_handle(dev, 0, &sc->sc_iface);
 	if (err) {
 		aprint_error_dev(self, "failed to get interface: %s\n",
 		    usbd_errstr(err));
 		sc->sc_dying = 1;
-		USB_ATTACH_ERROR_RETURN;
+		return;
 	}
 
 	ed = usbd_interface2endpoint_descriptor(sc->sc_iface, 0);
 	if (ed == NULL) {
 		aprint_error_dev(sc->sc_dev, "couldn't get ep 0\n");
 		sc->sc_dying = 1;
-		USB_ATTACH_ERROR_RETURN;
+		return;
 	}
 	sc->sc_ed = ed->bEndpointAddress;
 
 	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
-	    USBDEV(sc->sc_dev));
+	    sc->sc_dev);
 
 	waa.accessops = &xboxcontroller_accessops;
 	waa.accesscookie = sc;
@@ -158,7 +163,7 @@
 	sc->sc_wsmousedev = config_found_ia(self, "wsmousedev", &waa,
 	    wsmousedevprint);
 
-	USB_ATTACH_SUCCESS_RETURN;
+	return;
 }
 
 void
@@ -170,9 +175,10 @@
 	sc->sc_wsmousedev = NULL;
 }
 
-USB_DETACH(xboxcontroller)
+int 
+xboxcontroller_detach(device_t self, int flags)
 {
-	USB_DETACH_START(xboxcontroller, sc);
+	struct xboxcontroller_softc *sc = device_private(self);
 	int rv;
 
 	rv = 0;
@@ -192,7 +198,7 @@
 }
 
 int
-xboxcontroller_activate(device_ptr_t self, enum devact act)
+xboxcontroller_activate(device_t self, enum devact act)
 {
 	struct xboxcontroller_softc *sc = device_private(self);
 

Reply via email to