>>>> +static void uas_unlink_data_urbs(struct uas_dev_info *devinfo,
>>>> +                           struct uas_cmd_info *cmdinfo)
>>>> +{
>>>> +  unsigned long flags;
>>>> +
>>>> +  spin_lock_irqsave(&devinfo->lock, flags);
>>>> +  if (cmdinfo->state & DATA_IN_URB_INFLIGHT) {
>>>> +          spin_unlock_irqrestore(&devinfo->lock, flags);
>>
>> urb_unlink_urb may call the completion callback which in turn grabs the
>> lock to update cmdinfo->state, so we must drop it to avoid deadlocks.
> 
> But what is the point of taking it at all if the result of the check may be 
> reversed
> when you act upon it?

Good question.  I'm doing all cmdinfo->state access under lock to avoid
races, but I can see how this is kida pointless here.  Guess I can just
call urb_unlink_urb no matter what as the usb core guarantees the
completion handler is called only once.

Is it safe to call urb_unlink_urb twice on the same urb?  Or must I take
care to not do that?

cheers,
  Gerd
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to