From owner-p4-projects@FreeBSD.ORG Mon Jun 8 13:10:12 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A1F4A1065690; Mon, 8 Jun 2009 13:10:12 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 40F5D10656D6 for ; Mon, 8 Jun 2009 13:10:12 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 465E88FC1D for ; Mon, 8 Jun 2009 13:10:10 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n58DAAsU036938 for ; Mon, 8 Jun 2009 13:10:10 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n58DAAwQ036936 for perforce@freebsd.org; Mon, 8 Jun 2009 13:10:10 GMT (envelope-from hselasky@FreeBSD.org) Date: Mon, 8 Jun 2009 13:10:10 GMT Message-Id: <200906081310.n58DAAwQ036936@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 163780 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: Mon, 08 Jun 2009 13:10:14 -0000 http://perforce.freebsd.org/chv.cgi?CH=163780 Change 163780 by hselasky@hselasky_laptop001 on 2009/06/08 13:09:58 USB CORE: - minor device side improvement. Make sure a not complete state gets paired with a complete state in device side mode for the default control endpoint. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/usb_core.h#24 edit .. //depot/projects/usb/src/sys/dev/usb/usb_handle_request.c#11 edit .. //depot/projects/usb/src/sys/dev/usb/usb_if.m#8 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/usb_core.h#24 (text+ko) ==== @@ -215,6 +215,11 @@ #define USB_ST_TRANSFERRED 1 #define USB_ST_ERROR 2 +/* USB handle request states */ +#define USB_HR_NOT_COMPLETE 0 +#define USB_HR_COMPLETE_OK 1 +#define USB_HR_COMPLETE_ERR 2 + /* * The following macro will return the current state of an USB * transfer like defined by the "USB_ST_XXX" enums. ==== //depot/projects/usb/src/sys/dev/usb/usb_handle_request.c#11 (text+ko) ==== @@ -42,13 +42,6 @@ #include #include -/* enum */ - -enum { - ST_DATA, - ST_POST_STATUS, -}; - /* function prototypes */ static uint8_t usb2_handle_get_stall(struct usb_device *, uint8_t); @@ -88,16 +81,17 @@ usb2_needs_explore(xfer->xroot->bus, 0); break; } - /* - * If no control transfer is active, - * receive the next SETUP message: - */ goto tr_restart; } usb2_start_hardware(xfer); break; default: + /* check if a control transfer is active */ + if (xfer->flags_int.control_rem != 0xFFFF) { + /* handle the request */ + err = usb2_handle_request(xfer); + } if (xfer->error != USB_ERR_CANCELLED) { /* should not happen - try stalling */ goto tr_restart; @@ -107,6 +101,10 @@ return; tr_restart: + /* + * If a control transfer is active, stall it, and wait for the + * next control transfer. + */ xfer->frlengths[0] = sizeof(struct usb_device_request); xfer->nframes = 1; xfer->flags.manual_status = 1; @@ -215,7 +213,7 @@ #endif error = USB_HANDLE_REQUEST(iface->subdev, &req, ppdata, plen, - off, (state == ST_POST_STATUS)); + off, state); } iface_parent = usb2_get_iface(udev, iface->parent_iface_index); @@ -235,7 +233,7 @@ device_is_attached(iface_parent->subdev)) { error = USB_HANDLE_REQUEST(iface_parent->subdev, &req, ppdata, plen, off, - (state == ST_POST_STATUS)); + state); } if (error == 0) { /* negativly adjust pointer and length */ @@ -249,7 +247,7 @@ iface_index++; /* iterate */ goto tr_repeat; } - if (state == ST_POST_STATUS) { + if (state != USB_HR_NOT_COMPLETE) { /* we are complete */ goto tr_valid; } @@ -409,7 +407,7 @@ * * Internal state sequence: * - * ST_DATA -> ST_POST_STATUS + * USB_HR_NOT_COMPLETE -> USB_HR_COMPLETE_OK v USB_HR_COMPLETE_ERR * * Returns: * 0: Ready to start hardware @@ -441,21 +439,23 @@ switch (USB_GET_STATE(xfer)) { case USB_ST_SETUP: - state = ST_DATA; + state = USB_HR_NOT_COMPLETE; if (!xfer->flags_int.control_act) { /* nothing to do */ goto tr_stalled; } break; - - default: /* USB_ST_TRANSFERRED */ + case USB_ST_TRANSFERRED: if (!xfer->flags_int.control_act) { - state = ST_POST_STATUS; + state = USB_HR_COMPLETE_OK; } else { - state = ST_DATA; + state = USB_HR_NOT_COMPLETE; } break; + default: + state = USB_HR_COMPLETE_ERR; + break; } /* reset frame stuff */ @@ -499,7 +499,7 @@ switch (req.bmRequestType) { case UT_READ_DEVICE: - if (state != ST_DATA) { + if (state != USB_HR_NOT_COMPLETE) { break; } switch (req.bRequest) { @@ -629,7 +629,7 @@ goto tr_valid; tr_handle_set_address: - if (state == ST_DATA) { + if (state == USB_HR_NOT_COMPLETE) { if (wValue >= 0x80) { /* invalid value */ goto tr_stalled; @@ -637,14 +637,14 @@ /* we are configured ! */ goto tr_stalled; } - } else if (state == ST_POST_STATUS) { + } else if (state != USB_HR_NOT_COMPLETE) { udev->address = (wValue & 0x7F); goto tr_bad_context; } goto tr_valid; tr_handle_set_config: - if (state == ST_DATA) { + if (state == USB_HR_NOT_COMPLETE) { if (usb2_handle_set_config(xfer, req.wValue[0])) { goto tr_stalled; } @@ -652,7 +652,7 @@ goto tr_valid; tr_handle_clear_halt: - if (state == ST_DATA) { + if (state == USB_HR_NOT_COMPLETE) { if (usb2_handle_set_stall(xfer, req.wIndex[0], 0)) { goto tr_stalled; } @@ -660,7 +660,7 @@ goto tr_valid; tr_handle_clear_wakeup: - if (state == ST_DATA) { + if (state == USB_HR_NOT_COMPLETE) { if (usb2_handle_remote_wakeup(xfer, 0)) { goto tr_stalled; } @@ -668,7 +668,7 @@ goto tr_valid; tr_handle_set_halt: - if (state == ST_DATA) { + if (state == USB_HR_NOT_COMPLETE) { if (usb2_handle_set_stall(xfer, req.wIndex[0], 1)) { goto tr_stalled; } @@ -676,7 +676,7 @@ goto tr_valid; tr_handle_set_wakeup: - if (state == ST_DATA) { + if (state == USB_HR_NOT_COMPLETE) { if (usb2_handle_remote_wakeup(xfer, 1)) { goto tr_stalled; } @@ -684,7 +684,7 @@ goto tr_valid; tr_handle_get_ep_status: - if (state == ST_DATA) { + if (state == USB_HR_NOT_COMPLETE) { temp.wStatus[0] = usb2_handle_get_stall(udev, req.wIndex[0]); temp.wStatus[1] = 0; @@ -694,7 +694,7 @@ goto tr_valid; tr_valid: - if (state == ST_POST_STATUS) { + if (state != USB_HR_NOT_COMPLETE) { goto tr_stalled; } /* subtract offset from length */ @@ -750,7 +750,7 @@ return (0); /* success */ tr_stalled: - DPRINTF("%s\n", (state == ST_POST_STATUS) ? + DPRINTF("%s\n", (state != USB_HR_NOT_COMPLETE) ? "complete" : "stalled"); return (USB_ERR_STALLED); ==== //depot/projects/usb/src/sys/dev/usb/usb_if.m#8 (text+ko) ==== @@ -47,6 +47,5 @@ void **pptr; /* data pointer */ uint16_t *plen; /* maximum transfer length */ uint16_t offset; /* data offset */ - uint8_t is_complete; /* set if transfer is complete */ + uint8_t is_complete; /* set if transfer is complete, see USB_HR_XXX */ }; -