Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Stop using the compatibility macros USB_ATTACH()...
details: https://anonhg.NetBSD.org/src/rev/e51d346d88fe
branches: trunk
changeset: 758393:e51d346d88fe
user: dyoung <dyoung%NetBSD.org@localhost>
date: Wed Nov 03 23:46:35 2010 +0000
description:
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().
diffstat:
sys/dev/usb/moscom.c | 32 +++++++++++++++++++-------------
sys/dev/usb/uark.c | 28 +++++++++++++++++++---------
sys/dev/usb/uhmodem.c | 32 +++++++++++++++++++-------------
sys/dev/usb/uyurex.c | 20 +++++++++++++-------
sys/dev/usb/xboxcontroller.c | 36 +++++++++++++++++++++---------------
5 files changed, 91 insertions(+), 57 deletions(-)
diffs (truncated from 455 to 300 lines):
diff -r acccc7f0fcb9 -r e51d346d88fe sys/dev/usb/moscom.c
--- a/sys/dev/usb/moscom.c Wed Nov 03 23:24:14 2010 +0000
+++ b/sys/dev/usb/moscom.c Wed Nov 03 23:46:35 2010 +0000
@@ -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);
}
diff -r acccc7f0fcb9 -r e51d346d88fe sys/dev/usb/uark.c
--- a/sys/dev/usb/uark.c Wed Nov 03 23:24:14 2010 +0000
+++ b/sys/dev/usb/uark.c Wed Nov 03 23:46:35 2010 +0000
@@ -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
diff -r acccc7f0fcb9 -r e51d346d88fe sys/dev/usb/uhmodem.c
--- a/sys/dev/usb/uhmodem.c Wed Nov 03 23:24:14 2010 +0000
+++ b/sys/dev/usb/uhmodem.c Wed Nov 03 23:46:35 2010 +0000
@@ -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 <yuo%nui.org@localhost>.
@@ -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);
}
diff -r acccc7f0fcb9 -r e51d346d88fe sys/dev/usb/uyurex.c
--- a/sys/dev/usb/uyurex.c Wed Nov 03 23:24:14 2010 +0000
+++ b/sys/dev/usb/uyurex.c Wed Nov 03 23:46:35 2010 +0000
@@ -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
Home |
Main Index |
Thread Index |
Old Index