From owner-p4-projects@FreeBSD.ORG Sun Jun 11 08:25:54 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C1BD416A420; Sun, 11 Jun 2006 08:25:54 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7D70916A41A for ; Sun, 11 Jun 2006 08:25:54 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2C88C43D45 for ; Sun, 11 Jun 2006 08:25:54 +0000 (GMT) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k5B8NiUG047341 for ; Sun, 11 Jun 2006 08:23:44 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k5B8NiSo047338 for perforce@freebsd.org; Sun, 11 Jun 2006 08:23:44 GMT (envelope-from hselasky@FreeBSD.org) Date: Sun, 11 Jun 2006 08:23:44 GMT Message-Id: <200606110823.k5B8NiSo047338@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 98974 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Jun 2006 08:25:55 -0000 http://perforce.freebsd.org/chv.cgi?CH=98974 Change 98974 by hselasky@hselasky_mini_itx on 2006/06/11 08:22:50 Improve handling of "clear-stall". Affected files ... .. //depot/projects/usb/src/sys/dev/usb/ums.c#5 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/ums.c#5 (text+ko) ==== @@ -110,7 +110,7 @@ #define UMS_FLAG_T_AXIS 0x0008 #define UMS_FLAG_SBU 0x0010 /* spurious button up events */ #define UMS_FLAG_SELECT 0x0020 /* select is waiting */ -#define UMS_FLAG_PIPE_ERROR 0x0040 /* set if transfer error */ +#define UMS_FLAG_INTR_STALL 0x0040 /* set if transfer error */ #define UMS_FLAG_WAIT_USB 0x0080 /* device is waiting for callbacks */ #define UMS_FLAG_WAIT_CO 0x0100 /* device is waiting for callbacks */ #define UMS_FLAG_GONE 0x0200 /* device is gone */ @@ -152,40 +152,29 @@ } static void -ums_clear_stall_callback(struct usbd_xfer *xfer1) +ums_clear_stall_callback(struct usbd_xfer *xfer) { - usb_device_request_t *req = xfer1->buffer; - struct ums_softc *sc = xfer1->priv_sc; - struct usbd_xfer *xfer0 = sc->sc_xfer[0]; + struct ums_softc *sc = xfer->priv_sc; - USBD_CHECK_STATUS(xfer1); + USBD_CHECK_STATUS(xfer); tr_setup: - - /* setup a CLEAR STALL packet */ - - req->bmRequestType = UT_WRITE_ENDPOINT; - req->bRequest = UR_CLEAR_FEATURE; - USETW(req->wValue, UF_ENDPOINT_HALT); - req->wIndex[0] = xfer0->pipe->edesc->bEndpointAddress; - req->wIndex[1] = 0; - USETW(req->wLength, 0); - - usbd_start_hardware(xfer1); + /* start clear stall */ + usbd_clear_stall_tr_setup(xfer, sc->sc_xfer[0]); return; - tr_error: tr_transferred: + usbd_clear_stall_tr_transferred(xfer, sc->sc_xfer[0]); - sc->sc_flags &= ~UMS_FLAG_PIPE_ERROR; + sc->sc_flags &= ~UMS_FLAG_INTR_STALL; + usbd_transfer_start(sc->sc_xfer[0]); + return; - if (xfer1->error != USBD_CANCELLED) { - - xfer0->pipe->clearstall = 0; - xfer0->pipe->toggle_next = 0; - - usbd_transfer_start(xfer0); - } + tr_error: + /* bomb out */ + sc->sc_flags &= ~UMS_FLAG_INTR_STALL; + DPRINTF(0, "clear stall failed, error=%s!\n", + usbd_errstr(xfer->error)); return; } @@ -294,18 +283,21 @@ } tr_setup: - USBD_IF_POLL(&sc->sc_rdq_free, m); + if (sc->sc_flags & UMS_FLAG_INTR_STALL) { + usbd_transfer_start(sc->sc_xfer[1]); + } else { + USBD_IF_POLL(&sc->sc_rdq_free, m); - if (m && (!(sc->sc_flags & UMS_FLAG_PIPE_ERROR))) { - usbd_start_hardware(xfer); + if (m) { + usbd_start_hardware(xfer); + } } return; tr_error: if (xfer->error != USBD_CANCELLED) { /* start clear stall */ - sc->sc_flags |= UMS_FLAG_PIPE_ERROR; - + sc->sc_flags |= UMS_FLAG_INTR_STALL; usbd_transfer_start(sc->sc_xfer[1]); } return;