All pastes #1949531 Raw Edit

Miscellany

public diff v1 · immutable
#1949531 ·published 2010-09-27 12:11 UTC
rendered paste body
Index: uhub.c===================================================================RCS file: /cvs/src/sys/dev/usb/uhub.c,vretrieving revision 1.52diff -u -p -u -r1.52 uhub.c--- uhub.c	13 Nov 2009 18:06:57 -0000	1.52+++ uhub.c	20 Sep 2010 06:38:17 -0000@@ -65,7 +65,8 @@ struct uhub_softc { 	struct device		sc_dev;		/* base device */ 	usbd_device_handle	sc_hub;		/* USB device */ 	usbd_pipe_handle	sc_ipipe;	/* interrupt pipe */-	u_int8_t		sc_status[1];	/* XXX more ports */+	u_int8_t		*sc_statusbuf;	/* per port status buffer */+	size_t			sc_statuslen;	/* status bufferlen */ 	u_char			sc_running; }; #define UHUB_PROTO(sc) ((sc)->sc_hub->ddesc.bDeviceProtocol)@@ -234,9 +235,14 @@ uhub_attach(struct device *parent, struc 		goto bad; 	} +	sc->sc_statuslen = (nports + 1 + 7) / 8;+	sc->sc_statusbuf = malloc(sc->sc_statuslen, M_USBDEV, M_NOWAIT);+	if (!sc->sc_statusbuf)+		goto bad;+ 	err = usbd_open_pipe_intr(iface, ed->bEndpointAddress,-		  USBD_SHORT_XFER_OK, &sc->sc_ipipe, sc, sc->sc_status,-		  sizeof(sc->sc_status), uhub_intr, UHUB_INTR_INTERVAL);+		  USBD_SHORT_XFER_OK, &sc->sc_ipipe, sc, sc->sc_statusbuf,+		  sc->sc_statuslen, uhub_intr, UHUB_INTR_INTERVAL); 	if (err) { 		printf("%s: cannot open interrupt pipe\n", 		       sc->sc_dev.dv_xname);@@ -327,6 +333,8 @@ uhub_attach(struct device *parent, struc  bad: 	if (hub->ports) 		free(hub->ports, M_USBDEV);+	if (sc->sc_statusbuf)+		free(sc->sc_statusbuf, M_USBDEV); 	if (hub) 		free(hub, M_USBDEV); 	dev->hub = NULL;@@ -352,7 +360,7 @@ uhub_explore(usbd_device_handle dev) 	if (dev->depth > USB_HUB_MAX_DEPTH) 		return (USBD_TOO_DEEP); -	for(port = 1; port <= hd->bNbrPorts; port++) {+	for (port = 1; port <= hd->bNbrPorts; port++) { 		up = &dev->hub->ports[port-1]; 		err = usbd_get_port_status(dev, port, &up->status); 		if (err) {@@ -565,6 +573,8 @@ uhub_detach(struct device *self, int fla 		free(hub->ports[0].tt, M_USBDEV); 	if (hub->ports) 		free(hub->ports, M_USBDEV);+	if (sc->sc_statusbuf)+		free(sc->sc_statusbuf, M_USBDEV); 	free(hub, M_USBDEV); 	sc->sc_hub->hub = NULL; @@ -587,4 +597,6 @@ uhub_intr(usbd_xfer_handle xfer, usbd_pr 		usbd_clear_endpoint_stall_async(sc->sc_ipipe); 	else if (status == USBD_NORMAL_COMPLETION) 		usb_needs_explore(sc->sc_hub);+	else+		DPRINTFN(8, ("uhub_intr: unknown status, %d\n", status)); }