Re: [PATCH 2/5] usb-core: Track if an endpoint has streams

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

 



On Wed, Aug 14, 2013 at 02:32:03PM +0200, Hans de Goede wrote:
> -	/* Streams only apply to bulk endpoints. */
> -	for (i = 0; i < num_eps; i++)
> +	for (i = 0; i < num_eps; i++) {
> +		/* Streams only apply to bulk endpoints. */
>  		if (!usb_endpoint_xfer_bulk(&eps[i]->desc))
>  			return -EINVAL;
> +		/* Re-alloc is not allowed */
> +		if (eps[i]->has_streams)
> +			return -EINVAL;
> +	}

[snip]

>  }
>  EXPORT_SYMBOL_GPL(usb_alloc_streams);
>  
> @@ -2075,7 +2086,7 @@ void usb_free_streams(struct usb_interface *interface,
>  {
>  	struct usb_hcd *hcd;
>  	struct usb_device *dev;
> -	int i;
> +	int i, ret;
>  
>  	dev = interface_to_usbdev(interface);
>  	hcd = bus_to_hcd(dev->bus);
> @@ -2087,7 +2098,12 @@ void usb_free_streams(struct usb_interface *interface,
>  		if (!eps[i] || !usb_endpoint_xfer_bulk(&eps[i]->desc))
>  			return;

Shouldn't you also check if all the endpoints have streams enabled here?
If you're going to return an error in the allocation function if any
endpoint has streams enabled, I think it makes sense to return an error
in the free function if one of the endpoints doesn't have streams
enabled.

>  
> -	hcd->driver->free_streams(hcd, dev, eps, num_eps, mem_flags);
> +	ret = hcd->driver->free_streams(hcd, dev, eps, num_eps, mem_flags);
> +	if (ret < 0)
> +		return;
> +
> +	for (i = 0; i < num_eps; i++)
> +		eps[i]->has_streams = 0;
>  }
>  EXPORT_SYMBOL_GPL(usb_free_streams);
>  
> diff --git a/include/linux/usb.h b/include/linux/usb.h
> index 001629c..4512eb3 100644
> --- a/include/linux/usb.h
> +++ b/include/linux/usb.h
> @@ -71,6 +71,7 @@ struct usb_host_endpoint {
>  	unsigned char *extra;   /* Extra descriptors */
>  	int extralen;
>  	int enabled;
> +	int has_streams;
>  };
>  
>  /* host-side wrapper for one interface setting's parsed descriptors */
> -- 
> 1.8.3.1
> 
> --
> 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
--
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