Date: Wed, 12 Dec 2007 22:40:20 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 130744 for review Message-ID: <200712122240.lBCMeKGh077509@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=130744 Change 130744 by hselasky@hselasky_laptop001 on 2007/12/12 22:39:22 Refactor "usbreq_reset_port" a little bit. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/usb_requests.c#12 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/usb_requests.c#12 (text+ko) ==== @@ -54,62 +54,50 @@ * usbreq_reset_port *------------------------------------------------------------------------*/ usbd_status_t -usbreq_reset_port(struct usbd_device *udev, struct mtx *mtx, - usb_port_status_t *ps, uint8_t port) +usbreq_reset_port(struct usbd_device *udev, struct mtx *mtx, uint8_t port) { - usb_device_request_t req; + usb_port_status_t ps; usbd_status_t err; uint8_t n; - req.bmRequestType = UT_WRITE_CLASS_OTHER; - req.bRequest = UR_SET_FEATURE; - USETW(req.wValue, UHF_PORT_RESET); - req.wIndex[0] = port; - req.wIndex[1] = 0; - USETW(req.wLength, 0); - err = usbd_do_request(udev, mtx, &req, 0); - - PRINTFN(1, ("port %d reset done, error=%s\n", - port, usbd_errstr(err))); - + err = usbreq_set_port_feature(udev, mtx, port, UHF_PORT_RESET); if (err) { goto done; } - n = 12; - do { - /* wait for device to recover from reset */ + for (n = 12; n != 0; n--) { + + /* wait for the device to recover from reset */ usbd_pause_mtx(mtx, USB_PORT_RESET_DELAY); - err = usbreq_get_port_status(udev, mtx, ps, port); - + err = usbreq_get_port_status(udev, mtx, &ps, port); if (err) { - PRINTF(("get status failed %d\n", - err)); goto done; } /* if the device disappeared, just give up */ - if (!(UGETW(ps->wPortStatus) & UPS_CURRENT_CONNECT_STATUS)) { - err = USBD_NORMAL_COMPLETION; + if (!(UGETW(ps.wPortStatus) & UPS_CURRENT_CONNECT_STATUS)) { goto done; } - if (n == 0) { - err = USBD_TIMEOUT; - goto done; - } else { - n--; + /* check if reset is complete */ + if (UGETW(ps.wPortChange) & UPS_C_PORT_RESET) { + break; } - } while ((UGETW(ps->wPortChange) & UPS_C_PORT_RESET) == 0); + } - err = usbreq_clear_port_feature(udev, mtx, port, UHF_C_PORT_RESET); -#ifdef USB_DEBUG + /* clear port reset first */ + err = usbreq_clear_port_feature( + udev, mtx, port, UHF_C_PORT_RESET); if (err) { - PRINTF(("clear port feature failed %d\n", - err)); + goto done; + } + /* check for timeout */ + if (n == 0) { + err = USBD_TIMEOUT; + goto done; } -#endif - /* wait for the device to recover from reset */ usbd_pause_mtx(mtx, USB_PORT_RESET_RECOVERY); done: + PRINTFN(1, ("port %d reset returning error=%s\n", + port, usbd_errstr(err))); return (err); } @@ -217,7 +205,7 @@ /* this is the language table */ return (USBD_INVAL); } - if (udev->no_strings) { + if (udev->flags.no_strings) { return (USBD_STALLED); } swap = (udev->quirks->uq_flags & UQ_SWAP_UNICODE) ? 1 : 0;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200712122240.lBCMeKGh077509>