/* This stops a request after it has been started by usb_sg_wait(). It can also prevents one initialized by usb_sg_init() from starting, so that call just frees resources allocated to the request.  */
void usb_sg_cancel(struct usb_sg_request *io)
/* This stops a request after it has been started by usb_sg_wait(). It can also prevents one initialized by usb_sg_init() from starting, so that call just frees resources allocated to the request.  */
void usb_sg_cancel(struct usb_sg_request *io)
{
	unsigned long flags;
	spin_lock_irqsave(&io->lock, flags);
	if (!io->status) {
		int i;
		io->status = -ECONNRESET;
		spin_unlock(&io->lock);
		for (i = 0; i < io->entries; i++) {
			int retval;
			if (!io->urbs [i]->dev)
				continue;
			retval = usb_unlink_urb(io->urbs [i]);
			if (retval != -EINPROGRESS && retval != -EBUSY)
				dev_warn(&io->dev->dev, "%s, unlink --> %d\n",
					__func__, retval);
		}
		spin_lock(&io->lock);
	}
	spin_unlock_irqrestore(&io->lock, flags);
}