From owner-p4-projects@FreeBSD.ORG Tue Oct 9 19:56:03 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 19F9816A46B; Tue, 9 Oct 2007 19:56:03 +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 C5BCF16A421 for ; Tue, 9 Oct 2007 19:56:02 +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 B49A913C44B for ; Tue, 9 Oct 2007 19:56:02 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l99Ju2Er049370 for ; Tue, 9 Oct 2007 19:56:02 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l99Ju2fW049367 for perforce@freebsd.org; Tue, 9 Oct 2007 19:56:02 GMT (envelope-from hselasky@FreeBSD.org) Date: Tue, 9 Oct 2007 19:56:02 GMT Message-Id: <200710091956.l99Ju2fW049367@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 127347 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: Tue, 09 Oct 2007 19:56:03 -0000 http://perforce.freebsd.org/chv.cgi?CH=127347 Change 127347 by hselasky@hselasky_laptop001 on 2007/10/09 19:55:18 This commit is the first of two commits where the "USBD_CHECK_STATUS()" macro will be replaced by a switch statement. The change was suggested by Alfred Perlstein. This commit also includes a fix to the "usbd_std_packet_size[]" table, which had one BULK entry too little for Variable USB speed. The entry in question is currently not used. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/usb.h#17 edit .. //depot/projects/usb/src/sys/dev/usb/usb_port.h#18 edit .. //depot/projects/usb/src/sys/dev/usb/usb_subr.h#47 edit .. //depot/projects/usb/src/sys/dev/usb/usb_transfer.c#34 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/usb.h#17 (text+ko) ==== @@ -188,9 +188,6 @@ #define USB_MAX_IPACKET 8 /* maximum size of the initial packet */ -#define USB_2_MAX_CTRL_PACKET 64 -#define USB_2_MAX_BULK_PACKET 512 - typedef struct { uByte bLength; uByte bDescriptorType; ==== //depot/projects/usb/src/sys/dev/usb/usb_port.h#18 (text+ko) ==== @@ -234,14 +234,6 @@ #define PRINTFN(n,x) #endif -#define USBD_CHECK_STATUS(xfer) do { \ - if (!(xfer)->flags_int.transferring) goto tr_setup; \ - (xfer)->flags_int.transferring = 0; \ - if ((xfer)->error) goto tr_error; \ - goto tr_transferred; \ -} while (0) -/**/ - #define _MAKE_ENUM(enum,value,arg...) \ enum value, \ /**/ ==== //depot/projects/usb/src/sys/dev/usb/usb_subr.h#47 (text+ko) ==== @@ -70,6 +70,14 @@ MAKE_ENUM(USBD_STATUS, N_USBD_STATUS); +#define USBD_GET_STATE(xfer) ((xfer)->usb_state) + +enum { + USBD_ST_SETUP, + USBD_ST_TRANSFERRED, + USBD_ST_ERROR, +}; + struct usbd_xfer; struct usbd_pipe; struct usbd_bus; @@ -418,6 +426,7 @@ uint8_t usb_smask; uint8_t usb_cmask; uint8_t usb_uframe; + uint8_t usb_state; usbd_status error; ==== //depot/projects/usb/src/sys/dev/usb/usb_transfer.c#34 (text+ko) ==== @@ -249,7 +249,7 @@ [USB_SPEED_LOW] = { }, /* invalid (all zero) */ [USB_SPEED_FULL] = { .fixed = { 8, 16, 32, 64 } }, [USB_SPEED_HIGH] = { .fixed = { 512, 512, 512, 512 } }, - [USB_SPEED_VARIABLE] = { .fixed = { 512, 1024, 1536 } }, + [USB_SPEED_VARIABLE] = { .fixed = { 512, 512, 1024, 1536 } }, }, [UE_ISOCHRONOUS] = { @@ -1504,6 +1504,17 @@ xfer->flags_int.recursed_1 = 1; xfer->flags_int.recursed_2 = 1; + /* set correct USB state for callback */ + if (!xfer->flags_int.transferring) { + xfer->usb_state = USBD_ST_SETUP; + } else { + xfer->flags_int.transferring = 0; + if (xfer->error) + xfer->usb_state = USBD_ST_ERROR; + else + xfer->usb_state = USBD_ST_TRANSFERRED; + } + /* call processing routine */ (xfer->callback)(xfer);