Re: [PATCH] usb: add reset endpoint operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 25 Mar 2009, David Vrabel wrote:

> Since Wireless USB endpoints have more state than a simple toggle bit,
> allow HCDs to provide a reset_endpoint method.
> 
> A patch making whci-hcd use this will follow shortly.

There are a couple of small improvements you might want to add to this:


> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -1546,6 +1546,28 @@ void usb_hcd_disable_endpoint(struct usb_device *udev,
>  		hcd->driver->endpoint_disable(hcd, ep);
>  }
>  
> +/**
> + * usb_hcd_reset_endpoint - reset host endpoint state
> + * @udev: USB device.
> + * @ep:   the endpoint to reset.
> + *
> + * Resets any host endpoint state such the toggle bit, sequence number

s/such/such as/

> + * and current window.
> + */


> @@ -1156,26 +1178,26 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
>   * usb_enable_endpoint - Enable an endpoint for USB communications
>   * @dev: the device whose interface is being enabled
>   * @ep: the endpoint
> - * @reset_toggle: flag to set the endpoint's toggle back to 0
> + * @reset_ep: flag to reset the endpoint state
>   *
> - * Resets the endpoint toggle if asked, and sets dev->ep_{in,out} pointers.
> + * Resets the endpoint state if asked, and sets dev->ep_{in,out} pointers.
>   * For control endpoints, both the input and output sides are handled.
>   */
>  void usb_enable_endpoint(struct usb_device *dev, struct usb_host_endpoint *ep,
> -		bool reset_toggle)
> +		bool reset_ep)
>  {
>  	int epnum = usb_endpoint_num(&ep->desc);
>  	int is_out = usb_endpoint_dir_out(&ep->desc);
>  	int is_control = usb_endpoint_xfer_control(&ep->desc);
>  
>  	if (is_out || is_control) {
> -		if (reset_toggle)
> -			usb_settoggle(dev, epnum, 1, 0);
> +		if (reset_ep)
> +			usb_hcd_reset_endpoint(dev, ep);
>  		dev->ep_out[epnum] = ep;
>  	}
>  	if (!is_out || is_control) {
> -		if (reset_toggle)
> -			usb_settoggle(dev, epnum, 0, 0);
> +		if (reset_ep)
> +			usb_hcd_reset_endpoint(dev, ep);
>  		dev->ep_in[epnum] = ep;
>  	}

You should hoist the "if (reset_ep)" parts outside the other "if"  
statements; otherwise the reset_endpoint would be called twice when ep0
is enabled.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux