[patch 2/3] staging: dwc2: cleanup in dwc2_schedule_periodic()

Paul Zimmerman Paul.Zimmerman at synopsys.com
Mon Nov 25 19:46:57 UTC 2013


> From: Dan Carpenter [mailto:dan.carpenter at oracle.com]
> Sent: Monday, November 25, 2013 6:14 AM
> 
> Combine two conditions and make the success path explicit.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>
> ---
> The code is more complicated than it needs to be because of the debug
> code.  If we just tested for error and then returned instead of trying
> to print a debug message that is the easiest way.  Debug code is not
> often used.  I don't like debug code very much.
> 
> diff --git a/drivers/staging/dwc2/hcd_queue.c b/drivers/staging/dwc2/hcd_queue.c
> index ad9136e9d820..5d188254728c 100644
> --- a/drivers/staging/dwc2/hcd_queue.c
> +++ b/drivers/staging/dwc2/hcd_queue.c
> @@ -517,13 +517,11 @@ static int dwc2_schedule_periodic(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
>  			frame = status - 1;
> 
>  		/* Set the new frame up */
> -		if (frame > -1) {
> +		if (status >= 0) {
>  			qh->sched_frame &= ~0x7;
>  			qh->sched_frame |= (frame & 7);
> -		}
> -
> -		if (status != -1)
>  			status = 0;
> +		}
>  	} else {
>  		status = dwc2_periodic_channel_available(hsotg);
>  		if (status) {
> @@ -566,7 +564,7 @@ static int dwc2_schedule_periodic(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
>  	/* Update claimed usecs per (micro)frame */
>  	hsotg->periodic_usecs += qh->usecs;
> 
> -	return status;
> +	return 0;
>  }
> 
>  /**

This touches the same function as the patch series "staging: dwc2:
cleanups for DWC2 driver" that I have already submitted. If you don't
mind, I will fold this patch into that series when I resubmit it to
fix some other things.

-- 
Paul



More information about the devel mailing list