From owner-p4-projects@FreeBSD.ORG Fri Mar 27 21:11:55 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6814A1065675; Fri, 27 Mar 2009 21:11:55 +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 27099106564A for ; Fri, 27 Mar 2009 21:11:55 +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 148D28FC19 for ; Fri, 27 Mar 2009 21:11:55 +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 n2RLBsHR058039 for ; Fri, 27 Mar 2009 21:11:54 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n2RLBse3058037 for perforce@freebsd.org; Fri, 27 Mar 2009 21:11:54 GMT (envelope-from hselasky@FreeBSD.org) Date: Fri, 27 Mar 2009 21:11:54 GMT Message-Id: <200903272111.n2RLBse3058037@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 159926 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: Fri, 27 Mar 2009 21:11:56 -0000 http://perforce.freebsd.org/chv.cgi?CH=159926 Change 159926 by hselasky@hselasky_laptop001 on 2009/03/27 21:11:44 USB controller: - minor code factorisation in atmegadci.c Affected files ... .. //depot/projects/usb/src/sys/dev/usb/controller/atmegadci.c#16 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/controller/atmegadci.c#16 (text+ko) ==== @@ -77,9 +77,7 @@ /* prototypes */ struct usb2_bus_methods atmegadci_bus_methods; -struct usb2_pipe_methods atmegadci_device_bulk_methods; -struct usb2_pipe_methods atmegadci_device_ctrl_methods; -struct usb2_pipe_methods atmegadci_device_intr_methods; +struct usb2_pipe_methods atmegadci_device_non_isoc_methods; struct usb2_pipe_methods atmegadci_device_isoc_fs_methods; static atmegadci_cmd_t atmegadci_setup_rx; @@ -1343,117 +1341,41 @@ /*------------------------------------------------------------------------* * at91dci bulk support - *------------------------------------------------------------------------*/ -static void -atmegadci_device_bulk_open(struct usb2_xfer *xfer) -{ - return; -} - -static void -atmegadci_device_bulk_close(struct usb2_xfer *xfer) -{ - atmegadci_device_done(xfer, USB_ERR_CANCELLED); -} - -static void -atmegadci_device_bulk_enter(struct usb2_xfer *xfer) -{ - return; -} - -static void -atmegadci_device_bulk_start(struct usb2_xfer *xfer) -{ - /* setup TDs */ - atmegadci_setup_standard_chain(xfer); - atmegadci_start_standard_chain(xfer); -} - -struct usb2_pipe_methods atmegadci_device_bulk_methods = -{ - .open = atmegadci_device_bulk_open, - .close = atmegadci_device_bulk_close, - .enter = atmegadci_device_bulk_enter, - .start = atmegadci_device_bulk_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, -}; - -/*------------------------------------------------------------------------* * at91dci control support - *------------------------------------------------------------------------*/ -static void -atmegadci_device_ctrl_open(struct usb2_xfer *xfer) -{ - return; -} - -static void -atmegadci_device_ctrl_close(struct usb2_xfer *xfer) -{ - atmegadci_device_done(xfer, USB_ERR_CANCELLED); -} - -static void -atmegadci_device_ctrl_enter(struct usb2_xfer *xfer) -{ - return; -} - -static void -atmegadci_device_ctrl_start(struct usb2_xfer *xfer) -{ - /* setup TDs */ - atmegadci_setup_standard_chain(xfer); - atmegadci_start_standard_chain(xfer); -} - -struct usb2_pipe_methods atmegadci_device_ctrl_methods = -{ - .open = atmegadci_device_ctrl_open, - .close = atmegadci_device_ctrl_close, - .enter = atmegadci_device_ctrl_enter, - .start = atmegadci_device_ctrl_start, - .enter_is_cancelable = 1, - .start_is_cancelable = 1, -}; - -/*------------------------------------------------------------------------* * at91dci interrupt support *------------------------------------------------------------------------*/ static void -atmegadci_device_intr_open(struct usb2_xfer *xfer) +atmegadci_device_non_isoc_open(struct usb2_xfer *xfer) { return; } static void -atmegadci_device_intr_close(struct usb2_xfer *xfer) +atmegadci_device_non_isoc_close(struct usb2_xfer *xfer) { atmegadci_device_done(xfer, USB_ERR_CANCELLED); } static void -atmegadci_device_intr_enter(struct usb2_xfer *xfer) +atmegadci_device_non_isoc_enter(struct usb2_xfer *xfer) { return; } static void -atmegadci_device_intr_start(struct usb2_xfer *xfer) +atmegadci_device_non_isoc_start(struct usb2_xfer *xfer) { /* setup TDs */ atmegadci_setup_standard_chain(xfer); atmegadci_start_standard_chain(xfer); } -struct usb2_pipe_methods atmegadci_device_intr_methods = +struct usb2_pipe_methods atmegadci_device_non_isoc_methods = { - .open = atmegadci_device_intr_open, - .close = atmegadci_device_intr_close, - .enter = atmegadci_device_intr_enter, - .start = atmegadci_device_intr_start, + .open = atmegadci_device_non_isoc_open, + .close = atmegadci_device_non_isoc_close, + .enter = atmegadci_device_non_isoc_enter, + .start = atmegadci_device_non_isoc_start, .enter_is_cancelable = 1, .start_is_cancelable = 1, }; @@ -1552,10 +1474,6 @@ * Simulate a hardware HUB by handling all the necessary requests. *------------------------------------------------------------------------*/ -/* - * USB descriptors for the virtual Root HUB: - */ - static const struct usb2_device_descriptor atmegadci_devd = { .bLength = sizeof(struct usb2_device_descriptor), .bDescriptorType = UDESC_DEVICE, @@ -2083,34 +2001,21 @@ /* * compute maximum number of TDs */ - if (parm->methods == &atmegadci_device_ctrl_methods) { + if ((xfer->pipe->edesc->bmAttributes & UE_XFERTYPE) == UE_CONTROL) { - ntd = xfer->nframes + 1 /* STATUS */ + 1 /* SYNC 1 */ + ntd = xfer->nframes + 1 /* STATUS */ + 1 /* SYNC 1 */ + 1 /* SYNC 2 */ ; - - } else if (parm->methods == &atmegadci_device_bulk_methods) { - - ntd = xfer->nframes + 1 /* SYNC */ ; - - } else if (parm->methods == &atmegadci_device_intr_methods) { - - ntd = xfer->nframes + 1 /* SYNC */ ; - - } else if (parm->methods == &atmegadci_device_isoc_fs_methods) { + } else { ntd = xfer->nframes + 1 /* SYNC */ ; - - } else { - - ntd = 0; } /* * check if "usb2_transfer_setup_sub" set an error */ - if (parm->err) { + if (parm->err) return; - } + /* * allocate transfer descriptors */ @@ -2119,19 +2024,13 @@ /* * get profile stuff */ - if (ntd) { + ep_no = xfer->endpoint & UE_ADDR; + atmegadci_get_hw_ep_profile(parm->udev, &pf, ep_no); - ep_no = xfer->endpoint & UE_ADDR; - atmegadci_get_hw_ep_profile(parm->udev, &pf, ep_no); - - if (pf == NULL) { - /* should not happen */ - parm->err = USB_ERR_INVAL; - return; - } - } else { - ep_no = 0; - pf = NULL; + if (pf == NULL) { + /* should not happen */ + parm->err = USB_ERR_INVAL; + return; } /* align data */ @@ -2188,23 +2087,10 @@ /* not supported */ return; } - switch (edesc->bmAttributes & UE_XFERTYPE) { - case UE_CONTROL: - pipe->methods = &atmegadci_device_ctrl_methods; - break; - case UE_INTERRUPT: - pipe->methods = &atmegadci_device_intr_methods; - break; - case UE_ISOCHRONOUS: + if ((edesc->bmAttributes & UE_XFERTYPE) == UE_ISOCHRONOUS) pipe->methods = &atmegadci_device_isoc_fs_methods; - break; - case UE_BULK: - pipe->methods = &atmegadci_device_bulk_methods; - break; - default: - /* do nothing */ - break; - } + else + pipe->methods = &atmegadci_device_non_isoc_methods; } }