[PATCH v2 1/4] USB: HCD: support giveback of URB in tasklet context

Alan Stern stern at rowland.harvard.edu
Tue Jun 25 10:48:30 EDT 2013


On Tue, 25 Jun 2013, Ming Lei wrote:

> >> +
> >> +     spin_lock(&bh->lock);
> >> +     list_add_tail(&urb->urb_list, &bh->head);
> >> +     if (bh->running)
> >> +             sched = 0;
> >> +     else
> >> +             sched = 1;
> >> +     spin_unlock(&bh->lock);
> >
> > How about calling this variable "running" instead of "sched"?  Then you
> > could just say:
> >
> >         running = bh->running;
> >
> > with no "if" statement.
> 
> OK, even we can do this below without name change:
> 
>            sched = !bh->running;
> 
> >
> >> +
> >> +     if (!sched)
> >> +             ;
> >> +     else if (high_prio_bh)
> >> +             tasklet_hi_schedule(&bh->bh);
> >> +     else
> >> +             tasklet_schedule(&bh->bh);

The advantage of "running" instead of "sched" is that it avoids a 
double negative:

	sched = !bh->running;
	...
	if (!sched) ...

as opposed to

	running = bh->running;
	...
	if (running) ...

Alan Stern




More information about the linux-arm-kernel mailing list