Date: Sun, 8 Aug 2010 08:56:31 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 182067 for review Message-ID: <201008080856.o788uV1O067149@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@182067?ac=10 Change 182067 by hselasky@hselasky_laptop001 on 2010/08/08 08:55:46 USB core: - extend use of clear stall bus method. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/usb_controller.h#26 edit .. //depot/projects/usb/src/sys/dev/usb/usb_device.c#76 edit .. //depot/projects/usb/src/sys/dev/usb/usb_request.c#41 edit .. //depot/projects/usb/src/sys/dev/usb/usb_transfer.c#183 edit .. //depot/projects/usb/src/sys/dev/usb/usb_transfer.h#17 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/usb_controller.h#26 (text+ko) ==== @@ -97,6 +97,9 @@ void (*get_hw_ep_profile) (struct usb_device *udev, const struct usb_hw_ep_profile **ppf, uint8_t ep_addr); void (*set_stall) (struct usb_device *udev, struct usb_xfer *xfer, struct usb_endpoint *ep, uint8_t *did_stall); + + /* USB Device mode mandatory. USB Host mode optional. */ + void (*clear_stall) (struct usb_device *udev, struct usb_endpoint *ep); /* Optional transfer polling support */ ==== //depot/projects/usb/src/sys/dev/usb/usb_device.c#76 (text+ko) ==== @@ -928,8 +928,8 @@ /*------------------------------------------------------------------------* * usbd_set_endpoint_stall * - * This function is used to make a BULK or INTERRUPT endpoint - * send STALL tokens. + * This function is used to make a BULK or INTERRUPT endpoint send + * STALL tokens in USB device mode. * * Returns: * 0: Success ==== //depot/projects/usb/src/sys/dev/usb/usb_request.c#41 (text+ko) ==== @@ -245,6 +245,8 @@ ep->is_stalled) { ep->toggle_next = 0; ep->is_stalled = 0; + /* some hardware needs a callback to clear the data toggle */ + usbd_clear_stall_locked(udev, ep); /* start up the current or next transfer, if any */ usb_command_wrapper(&ep->endpoint_q, ep->endpoint_q.curr); ==== //depot/projects/usb/src/sys/dev/usb/usb_transfer.c#183 (text+ko) ==== @@ -2863,12 +2863,34 @@ * data toggle. *------------------------------------------------------------------------*/ void +usbd_clear_stall_locked(struct usb_device *udev, struct usb_endpoint *ep) +{ + USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED); + + /* check that we have a valid case */ + if ((udev->flags.usb_mode == USB_MODE_HOST) && + (udev->parent_hub != NULL) && + (udev->bus->methods->clear_stall != NULL) && + (ep->methods != NULL)) { + (udev->bus->methods->clear_stall) (udev, ep); + } +} + +/*------------------------------------------------------------------------* + * usbd_clear_data_toggle - factored out code + * + * NOTE: the intention of this function is not to reset the hardware + * data toggle on the USB device side. + *------------------------------------------------------------------------*/ +void usbd_clear_data_toggle(struct usb_device *udev, struct usb_endpoint *ep) { DPRINTFN(5, "udev=%p endpoint=%p\n", udev, ep); USB_BUS_LOCK(udev->bus); ep->toggle_next = 0; + /* some hardware needs a callback to clear the data toggle */ + usbd_clear_stall_locked(udev, ep); USB_BUS_UNLOCK(udev->bus); } ==== //depot/projects/usb/src/sys/dev/usb/usb_transfer.h#17 (text+ko) ==== @@ -125,6 +125,8 @@ struct usb_xfer *xfer); void usbd_transfer_setup_sub(struct usb_setup_params *parm); void usbd_ctrl_transfer_setup(struct usb_device *udev); +void usbd_clear_stall_locked(struct usb_device *udev, + struct usb_endpoint *ep); void usbd_clear_data_toggle(struct usb_device *udev, struct usb_endpoint *ep); usb_callback_t usbd_do_request_callback;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008080856.o788uV1O067149>