Re: [PATCH 4/9] pxa27x_udc: optimize code to remove local variable and extra check

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

 



Vernon Sauder <vernoninhand@xxxxxxxxx> writes:

> diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
> index a896431..af35088 100644
> --- a/drivers/usb/gadget/pxa27x_udc.c
> +++ b/drivers/usb/gadget/pxa27x_udc.c
> @@ -817,9 +817,7 @@ static void ep_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req)
>   */
>  static void ep0_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req)
>  {
> -	struct pxa_udc *udc = ep->dev;
> -
> -	set_ep0state(udc, IN_STATUS_STAGE);
> +	set_ep0state(ep->dev, IN_STATUS_STAGE);
>  	ep_end_in_req(ep, req);
>  }
No. Leave the optimization to the compiler, he's smarter than me anyway. The way
the code is written is for maintainability. I'm pretty sure the compiler will
deal with the local variable appropriately.

> @@ -1225,30 +1223,26 @@ static int pxa_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
>  	struct udc_usb_ep	*udc_usb_ep;
>  	struct pxa27x_request	*req;
>  	unsigned long		flags;
> -	int			rc;
> +	int			rc = -EINVAL;
>  
>  	if (!_ep)
> -		return -EINVAL;
> +		return rc;
>  	udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep);
>  	ep = udc_usb_ep->pxa_ep;
>  	if (!ep || is_ep0(ep))
> -		return -EINVAL;
> +		return rc;
>  
>  	spin_lock_irqsave(&ep->lock, flags);
>  
>  	/* make sure it's actually queued on this endpoint */
>  	list_for_each_entry(req, &ep->queue, queue) {
> -		if (&req->req == _req)
> +		if (&req->req == _req) {
> +			req_done(ep, req, -ECONNRESET);
> +			rc = 0;
>  			break;
> +		}
>  	}
>  
> -	rc = -EINVAL;
> -	if (&req->req != _req)
> -		goto out;
> -
> -	rc = 0;
> -	req_done(ep, req, -ECONNRESET);
> -out:
>  	spin_unlock_irqrestore(&ep->lock, flags);
>  	return rc;
OK.

So that one will need a little update.

Cheers.

--
Robert
--
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