/* This function can't be called from interrupt context. Use uvc_queue_cancel() instead.  */
int uvc_queue_enable(struct uvc_video_queue *queue, int enable)
/* This function can't be called from interrupt context. Use uvc_queue_cancel() instead.  */
int uvc_queue_enable(struct uvc_video_queue *queue, int enable)
{
	unsigned int i;
	int ret = 0;
	mutex_lock(&queue->mutex);
	if (enable) {
		if (uvc_queue_streaming(queue)) {
			ret = -EBUSY;
			goto done;
		}
		queue->sequence = 0;
		queue->flags |= UVC_QUEUE_STREAMING;
		queue->buf_used = 0;
	} else {
		uvc_queue_cancel(queue, 0);
		INIT_LIST_HEAD(&queue->mainqueue);
		for (i = 0; i < queue->count; ++i)
			queue->buffer[i].state = UVC_BUF_STATE_IDLE;
		queue->flags &= ~UVC_QUEUE_STREAMING;
	}
done:
	mutex_unlock(&queue->mutex);
	return ret;
}