Module Name: src Committed By: dyoung Date: Thu Sep 3 20:54:03 UTC 2009 Modified Files: src/sys/dev/usb: uhub.c usb_subr.c Log Message: Expand some of the portability macros from sys/dev/usb/usb_port.h. There is no change in the generated assembly. To generate a diff of this commit: cvs rdiff -u -r1.104 -r1.105 src/sys/dev/usb/uhub.c cvs rdiff -u -r1.163 -r1.164 src/sys/dev/usb/usb_subr.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/uhub.c diff -u src/sys/dev/usb/uhub.c:1.104 src/sys/dev/usb/uhub.c:1.105 --- src/sys/dev/usb/uhub.c:1.104 Tue Apr 7 18:15:45 2009 +++ src/sys/dev/usb/uhub.c Thu Sep 3 20:54:03 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: uhub.c,v 1.104 2009/04/07 18:15:45 dyoung Exp $ */ +/* $NetBSD: uhub.c,v 1.105 2009/09/03 20:54:03 dyoung Exp $ *//* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ *//* @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h>-__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.104 2009/04/07 18:15:45 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.105 2009/09/03 20:54:03 dyoung Exp $");#include <sys/param.h> #include <sys/systm.h> @@ -106,7 +106,8 @@ CFATTACH_DECL2_NEW(uroothub, sizeof(struct uhub_softc), uhub_match,uhub_attach, uhub_detach, uhub_activate, uhub_rescan, uhub_childdet);-USB_MATCH(uhub) +int +uhub_match(device_t parent, cfdata_t match, void *aux) { USB_MATCH_START(uhub, uaa); @@ -120,7 +121,8 @@ return (UMATCH_NONE); } -USB_ATTACH(uhub) +void +uhub_attach(device_t parent, device_t self, void *aux) { USB_ATTACH_START(uhub, sc, uaa); usbd_device_handle dev = uaa->device; @@ -155,7 +157,7 @@ err = usbd_set_config_index(dev, 0, 1); if (err) { DPRINTF(("%s: configuration failed, error=%s\n", - USBDEVNAME(sc->sc_dev), usbd_errstr(err))); + device_xname(sc->sc_dev), usbd_errstr(err))); USB_ATTACH_ERROR_RETURN; } @@ -181,7 +183,7 @@ } if (err) { DPRINTF(("%s: getting hub descriptor failed, error=%s\n", - USBDEVNAME(sc->sc_dev), usbd_errstr(err))); + device_xname(sc->sc_dev), usbd_errstr(err))); USB_ATTACH_ERROR_RETURN; } @@ -254,7 +256,7 @@ /* Wait with power off for a while. */ usbd_delay_ms(dev, USB_POWER_DOWN_TIME);- usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, dev, USBDEV(sc- >sc_dev));+ usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, dev, sc->sc_dev); /* * To have the best chance of success we do things in the exact same @@ -467,7 +469,7 @@ /* Disconnected */ DPRINTF(("uhub_explore: device addr=%d disappeared " "on port %d\n", up->device->address, port)); - usb_disconnect_port(up, USBDEV(sc->sc_dev)); + usb_disconnect_port(up, sc->sc_dev); usbd_clear_port_feature(dev, port, UHF_C_PORT_CONNECTION); } @@ -519,7 +521,7 @@ else speed = USB_SPEED_FULL; /* Get device info and set its address. */ - err = usbd_new_device(USBDEV(sc->sc_dev), dev->bus, + err = usbd_new_device(sc->sc_dev, dev->bus, dev->depth + 1, speed, port, up); /* XXX retry a few times? */ if (err) { @@ -584,7 +586,8 @@ * Called from process context when the hub is gone. * Detach all devices on active ports. */ -USB_DETACH(uhub) +int +uhub_detach(device_t self, int flags) { USB_DETACH_START(uhub, sc); struct usbd_hub *hub = sc->sc_hub->hub; @@ -607,8 +610,7 @@ usb_disconnect_port(rup, self); } - usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_hub, - USBDEV(sc->sc_dev)); + usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_hub, sc->sc_dev); #if 0 if (hub->ports[0].tt) @@ -636,8 +638,7 @@ dev = hub->ports[port].device; if (dev == NULL) continue; - err = usbd_reattach_device(USBDEV(sc->sc_dev), dev, - port, locators); + err = usbd_reattach_device(sc->sc_dev, dev, port, locators); } return 0; } @@ -679,8 +680,7 @@ * to be explored again. */ void -uhub_intr(usbd_xfer_handle xfer, usbd_private_handle addr, - usbd_status status)+uhub_intr(usbd_xfer_handle xfer, usbd_private_handle addr, usbd_status status){ struct uhub_softc *sc = addr; Index: src/sys/dev/usb/usb_subr.cdiff -u src/sys/dev/usb/usb_subr.c:1.163 src/sys/dev/usb/usb_subr.c: 1.164--- src/sys/dev/usb/usb_subr.c:1.163 Sun Aug 16 13:06:32 2009 +++ src/sys/dev/usb/usb_subr.c Thu Sep 3 20:54:03 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: usb_subr.c,v 1.163 2009/08/16 13:06:32 martin Exp $ */ +/* $NetBSD: usb_subr.c,v 1.164 2009/09/03 20:54:03 dyoung Exp $ *//* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ *//* @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h>-__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.163 2009/08/16 13:06:32 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.164 2009/09/03 20:54:03 dyoung Exp $");#include "opt_compat_netbsd.h" #include "opt_usbverbose.h" @@ -78,8 +78,8 @@ Static void usbd_free_iface_data(usbd_device_handle dev, int ifcno); Static void usbd_kill_pipe(usbd_pipe_handle); usbd_status usbd_attach_roothub(device_t, usbd_device_handle); -Static usbd_status usbd_probe_and_attach(device_ptr_t parent, - usbd_device_handle dev, int port, int addr); +Static usbd_status usbd_probe_and_attach(device_t parent,+ usbd_device_handle dev, int port, int addr);Static u_int32_t usb_cookie_no = 0; @@ -640,7 +640,7 @@ if (msg) printf("%s: device addr %d (config %d): " "can't set self powered configuration\n", - USBDEVNAME(dev->bus->bdev), dev->address, + device_xname(dev->bus->bdev), dev->address, cdp->bConfigurationValue); err = USBD_NO_POWER; goto bad; @@ -904,8 +904,8 @@ } usbd_status -usbd_probe_and_attach(device_ptr_t parent, usbd_device_handle dev, - int port, int addr) +usbd_probe_and_attach(device_t parent, usbd_device_handle dev, + int port, int addr) { usb_device_descriptor_t *dd = &dev->ddesc; int confi, nifaces; @@ -927,11 +927,11 @@ if (err) { #ifdef USB_DEBUG DPRINTF(("%s: port %d, set config at addr %d failed, " - "error=%s\n", USBDEVPTRNAME(parent), port, - addr, usbd_errstr(err))); + "error=%s\n", device_xname(parent), port, + addr, usbd_errstr(err))); #else printf("%s: port %d, set config at addr %d failed\n", - USBDEVPTRNAME(parent), port, addr); + device_xname(parent), port, addr); #endif return (err); } @@ -976,8 +976,8 @@ * called before calling this. */ usbd_status -usbd_reattach_device(device_ptr_t parent, usbd_device_handle dev, - int port, const int *locators) +usbd_reattach_device(device_t parent, usbd_device_handle dev, + int port, const int *locators) { int i, loc; @@ -1024,8 +1024,8 @@ * and attach a driver. */ usbd_status -usbd_new_device(device_ptr_t parent, usbd_bus_handle bus, int depth, - int speed, int port, struct usbd_port *up) +usbd_new_device(device_t parent, usbd_bus_handle bus, int depth, + int speed, int port, struct usbd_port *up) { usbd_device_handle dev, adev; struct usbd_device *hub; @@ -1211,9 +1211,9 @@ if (err) { usbd_remove_device(dev, up); return (err); - } + } - return (USBD_NORMAL_COMPLETION); + return (USBD_NORMAL_COMPLETION); } usbd_status @@ -1337,16 +1337,16 @@ j < USB_MAX_DEVNAMES; i++) { if (!dev->subdevs[i]) continue; - strncpy(di->udi_devnames[j], USBDEVPTRNAME(dev->subdevs[i]), - USB_MAX_DEVNAMELEN); + strncpy(di->udi_devnames[j], + device_xname(dev->subdevs[i]), USB_MAX_DEVNAMELEN); di->udi_devnames[j][USB_MAX_DEVNAMELEN-1] = '\0'; j++; - } - } else { - j = 0; - } - for (/* j is set */; j < USB_MAX_DEVNAMES; j++)- di->udi_devnames[j][0] = 0; /* empty */+ } + } else { + j = 0; + } + for (/* j is set */; j < USB_MAX_DEVNAMES; j++) + di->udi_devnames[j][0] = 0; /* empty */ if (dev->hub) { for (i = 0; @@ -1403,8 +1403,8 @@ j < USB_MAX_DEVNAMES; i++) { if (!dev->subdevs[i]) continue; - strncpy(di->udi_devnames[j], USBDEVPTRNAME(dev->subdevs[i]), - USB_MAX_DEVNAMELEN); + strncpy(di->udi_devnames[j], + device_xname(dev->subdevs[i]), USB_MAX_DEVNAMELEN); di->udi_devnames[j][USB_MAX_DEVNAMELEN-1] = '\0'; j++; } @@ -1482,10 +1482,10 @@ * been disconnected. */ void -usb_disconnect_port(struct usbd_port *up, device_ptr_t parent) +usb_disconnect_port(struct usbd_port *up, device_t parent) { usbd_device_handle dev = up->device; - const char *hubname = USBDEVPTRNAME(parent); + const char *hubname = device_xname(parent); int i; DPRINTFN(3,("uhub_disconnect: up=%p dev=%p port=%d\n", @@ -1503,7 +1503,7 @@ for (i = 0; i < dev->subdevlen; i++) { if (!dev->subdevs[i]) continue; - printf("%s: at %s", USBDEVPTRNAME(dev->subdevs[i]), + printf("%s: at %s", device_xname(dev->subdevs[i]), hubname); if (up->portno != 0) printf(" port %d", up->portno);
fwiw, I still have the sed script laying aroung which I used to expand
all of these macros in OpenBSD. The macros indeed make not much sense
anymore, .Ox removed them and .Fx gets a new stack....
- Re: CVS commit: src/sys/dev/usb Marc Balmer
- Re: CVS commit: src/sys/dev/usb David Young
- CVS commit: src/sys/dev/usb Jonathan A. Kollasch
- CVS commit: src/sys/dev/usb Jonathan A. Kollasch
- CVS commit: src/sys/dev/usb Martin Husemann
- CVS commit: src/sys/dev/usb Martin Husemann
- CVS commit: src/sys/dev/usb Martin Husemann
- CVS commit: src/sys/dev/usb David Young
- CVS commit: src/sys/dev/usb David Young
- CVS commit: src/sys/dev/usb Antti Kantee
- CVS commit: src/sys/dev/usb Jonathan A. Kollasch