Re: [PATCH v2] usb: dwc3: gadget: Iterate only over valid endpoints

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

 



Hi,

On Tue, Mar 25, 2014 at 04:11:06PM -0700, Jack Pham wrote:
> Make dwc3_gadget_resize_tx_fifos() iterate only over IN
> endpoints that are actually present, based on the
> num_in_eps parameter. This terminates the loop so as to
> prevent dereferencing a potential NULL dwc->eps[i] where
> i >= (num_in_eps + num_out_eps).
> 
> Signed-off-by: Jack Pham <jackp@xxxxxxxxxxxxxx>

cool, this has the added benefit of making that loop execute faster
(well, we won't iterate over *all* endpoints).

> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index a740eac..258eee6 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -187,15 +187,11 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc)
>  	 * improve this algorithm so that we better use the internal
>  	 * FIFO space
>  	 */
> -	for (num = 0; num < DWC3_ENDPOINTS_NUM; num++) {
> -		struct dwc3_ep	*dep = dwc->eps[num];
> -		int		fifo_number = dep->number >> 1;
> +	for (num = 0; num < dwc->num_in_eps; num++) {
> +		struct dwc3_ep	*dep = dwc->eps[(num << 1) | 1];

Just add a comment here stating that bit0 is the direction bit, just so
we don't forget in the future.

One question, out of curiosity:

do you *really* need to enable tx-fifo-resize ? I thought OMAP5 ES1.0
was the only brainfart with FIFO setups which wouldn't even fit a single
USB3 packet :-p

Sure your patch is correct, and will be applied soonish, but if you
don't need to resize fifos, you might want to avoid it. Just curious.

cheers

ps: can you guys, please, just send your dwc3 glue layer ? :-)

-- 
balbi

Attachment: signature.asc
Description: Digital signature


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

  Powered by Linux