From owner-svn-src-head@FreeBSD.ORG Sun Apr 5 18:21:10 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1A2011065AF6; Sun, 5 Apr 2009 18:21:10 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 080728FC34; Sun, 5 Apr 2009 18:21:09 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n35IL8AI028066; Sun, 5 Apr 2009 18:21:08 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n35IL8UP028065; Sun, 5 Apr 2009 18:21:08 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200904051821.n35IL8UP028065@svn.freebsd.org> From: Andrew Thompson Date: Sun, 5 Apr 2009 18:21:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190737 - head/sys/dev/usb/controller X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Apr 2009 18:21:12 -0000 Author: thompsa Date: Sun Apr 5 18:21:08 2009 New Revision: 190737 URL: http://svn.freebsd.org/changeset/base/190737 Log: MFp4 //depot/projects/usb@159926 Minor code factorisation in atmegadci.c Submitted by: Hans Petter Selasky Modified: head/sys/dev/usb/controller/atmegadci.c Modified: head/sys/dev/usb/controller/atmegadci.c ============================================================================== --- head/sys/dev/usb/controller/atmegadci.c Sun Apr 5 18:20:58 2009 (r190736) +++ head/sys/dev/usb/controller/atmegadci.c Sun Apr 5 18:21:08 2009 (r190737) @@ -77,9 +77,7 @@ SYSCTL_INT(_hw_usb2_atmegadci, OID_AUTO, /* 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 @@ atmegadci_do_poll(struct usb2_bus *bus) /*------------------------------------------------------------------------* * 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 @@ struct usb2_pipe_methods atmegadci_devic * 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 @@ atmegadci_xfer_setup(struct usb2_setup_p /* * 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) { - - ntd = xfer->nframes + 1 /* SYNC */ ; - } else { - ntd = 0; + ntd = xfer->nframes + 1 /* SYNC */ ; } /* * check if "usb2_transfer_setup_sub" set an error */ - if (parm->err) { + if (parm->err) return; - } + /* * allocate transfer descriptors */ @@ -2119,19 +2024,13 @@ atmegadci_xfer_setup(struct usb2_setup_p /* * 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 @@ atmegadci_pipe_init(struct usb2_device * /* 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; } }