From owner-svn-src-stable@FreeBSD.ORG Sun Mar 22 06:47:30 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7D5811065672; Sun, 22 Mar 2009 06:47:30 +0000 (UTC) (envelope-from n_hibma@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 61A948FC12; Sun, 22 Mar 2009 06:47:30 +0000 (UTC) (envelope-from n_hibma@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2M6lUYP060098; Sun, 22 Mar 2009 06:47:30 GMT (envelope-from n_hibma@svn.freebsd.org) Received: (from n_hibma@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2M6lUfd060093; Sun, 22 Mar 2009 06:47:30 GMT (envelope-from n_hibma@svn.freebsd.org) Message-Id: <200903220647.n2M6lUfd060093@svn.freebsd.org> From: Nick Hibma Date: Sun, 22 Mar 2009 06:47:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190252 - stable/6/sys/dev/usb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Mar 2009 06:47:31 -0000 Author: n_hibma Date: Sun Mar 22 06:47:29 2009 New Revision: 190252 URL: http://svn.freebsd.org/changeset/base/190252 Log: MFC 184941: Add a reset device command to ugen.c. This is needed to make some devices work that require a firmware upload and a USB reset afterwards. Modified: stable/6/sys/dev/usb/ugen.c stable/6/sys/dev/usb/usb.h stable/6/sys/dev/usb/usb_subr.c stable/6/sys/dev/usb/usbdi.c stable/6/sys/dev/usb/usbdi.h Modified: stable/6/sys/dev/usb/ugen.c ============================================================================== --- stable/6/sys/dev/usb/ugen.c Sun Mar 22 06:37:14 2009 (r190251) +++ stable/6/sys/dev/usb/ugen.c Sun Mar 22 06:47:29 2009 (r190252) @@ -1133,8 +1133,8 @@ ugen_isoc_rintr(usbd_xfer_handle xfer, u sce->cur += count; if(sce->cur >= sce->limit) sce->cur = sce->ibuf + (sce->limit - sce->cur); - DPRINTFN(5, ("ugen_isoc_rintr: throwing away %d bytes\n", - count)); + DPRINTF(("ugen_isoc_rintr: throwing away %d bytes\n", + count)); } isize = UGETW(sce->edesc->wMaxPacketSize); @@ -1505,7 +1505,6 @@ ugen_do_ioctl(struct ugen_softc *sc, int struct iovec iov; struct uio uio; void *ptr = 0; - usbd_status err; int error = 0; if (!(flag & FWRITE)) @@ -1563,6 +1562,11 @@ ugen_do_ioctl(struct ugen_softc *sc, int usbd_fill_deviceinfo(sc->sc_udev, (struct usb_device_info *)addr, 1); break; + case USB_RESET_DEVICE: + err = usbd_reset_device(sc->sc_udev); + if (err) + return EIO; + break; default: return (EINVAL); } Modified: stable/6/sys/dev/usb/usb.h ============================================================================== --- stable/6/sys/dev/usb/usb.h Sun Mar 22 06:37:14 2009 (r190251) +++ stable/6/sys/dev/usb/usb.h Sun Mar 22 06:47:29 2009 (r190252) @@ -683,6 +683,7 @@ struct usb_event { #define USB_GET_DEVICEINFO _IOR ('U', 112, struct usb_device_info) #define USB_SET_SHORT_XFER _IOW ('U', 113, int) #define USB_SET_TIMEOUT _IOW ('U', 114, int) +#define USB_RESET_DEVICE _IO ('U', 115) /* Modem device */ #define USB_GET_CM_OVER_DATA _IOR ('U', 130, int) Modified: stable/6/sys/dev/usb/usb_subr.c ============================================================================== --- stable/6/sys/dev/usb/usb_subr.c Sun Mar 22 06:37:14 2009 (r190251) +++ stable/6/sys/dev/usb/usb_subr.c Sun Mar 22 06:47:29 2009 (r190252) @@ -334,16 +334,10 @@ usbd_delay_ms(usbd_device_handle dev, u_ usbd_status usbd_reset_port(usbd_device_handle dev, int port, usb_port_status_t *ps) { - usb_device_request_t req; usbd_status err; int n; - req.bmRequestType = UT_WRITE_CLASS_OTHER; - req.bRequest = UR_SET_FEATURE; - USETW(req.wValue, UHF_PORT_RESET); - USETW(req.wIndex, port); - USETW(req.wLength, 0); - err = usbd_do_request(dev, &req, 0); + err = usbd_set_port_feature(dev, port, UHF_PORT_RESET); DPRINTFN(1,("usbd_reset_port: port %d reset done, error=%s\n", port, usbd_errstr(err))); if (err) @@ -697,11 +691,11 @@ usbd_set_config_index(usbd_device_handle DPRINTF(("power exceeded %d %d\n", power,dev->powersrc->power)); /* XXX print nicer message. */ if (msg) - printf("%s: device addr %d (config %d) exceeds power " - "budget, %d mA > %d mA\n", - USBDEVNAME(dev->bus->bdev), dev->address, - cdp->bConfigurationValue, - power, dev->powersrc->power); + device_printf(dev->bus->bdev, + "device addr %d (config %d) exceeds " + "power budget, %d mA > %d mA\n", + dev->address, cdp->bConfigurationValue, + power, dev->powersrc->power); err = USBD_NO_POWER; goto bad; } @@ -1010,8 +1004,7 @@ usbd_new_device(device_ptr_t parent, usb bus, port, depth, speed)); addr = usbd_getnewaddr(bus); if (addr < 0) { - printf("%s: No free USB addresses, new device ignored.\n", - USBDEVNAME(bus->bdev)); + device_printf(bus->bdev, "No free USB addresses\n"); return (USBD_NO_ADDR); } @@ -1417,11 +1410,12 @@ usb_disconnect_port(struct usbd_port *up if (dev->subdevs != NULL) { DPRINTFN(3,("usb_disconnect_port: disconnect subdevs\n")); for (i = 0; dev->subdevs[i]; i++) { - printf("%s: at %s", USBDEVPTRNAME(dev->subdevs[i]), - hubname); - if (up->portno != 0) - printf(" port %d", up->portno); - printf(" (addr %d) disconnected\n", dev->address); + if (!device_is_quiet(dev->subdevs[i])) { + device_printf(dev->subdevs[i], "at %s",hubname); + if (up->portno != 0) + printf(" port %d", up->portno); + printf(" (addr %d) disconnected\n", dev->address); + } config_detach(dev->subdevs[i], DETACH_FORCE); dev->subdevs[i] = NULL; } Modified: stable/6/sys/dev/usb/usbdi.c ============================================================================== --- stable/6/sys/dev/usb/usbdi.c Sun Mar 22 06:37:14 2009 (r190251) +++ stable/6/sys/dev/usb/usbdi.c Sun Mar 22 06:47:29 2009 (r190252) @@ -1112,6 +1112,15 @@ usbd_set_polling(usbd_device_handle dev, dev->bus->methods->soft_intr(dev->bus); } +usbd_status +usbd_reset_device(usbd_device_handle dev) +{ + usbd_device_handle parent = dev->myhub; + struct usbd_port *up = dev->powersrc; + + return usbd_reset_port(parent, up->portno, &up->status); +} + usb_endpoint_descriptor_t * usbd_get_endpoint_descriptor(usbd_interface_handle iface, u_int8_t address) Modified: stable/6/sys/dev/usb/usbdi.h ============================================================================== --- stable/6/sys/dev/usb/usbdi.h Sun Mar 22 06:37:14 2009 (r190251) +++ stable/6/sys/dev/usb/usbdi.h Sun Mar 22 06:47:29 2009 (r190252) @@ -158,6 +158,7 @@ usb_endpoint_descriptor_t *usbd_find_ede void usbd_dopoll(usbd_interface_handle); void usbd_set_polling(usbd_device_handle, int); +usbd_status usbd_reset_device(usbd_device_handle); const char *usbd_errstr(usbd_status);