Example #1
0
int usb_urb_exitv2(struct usb_data_stream *stream)
{
	usb_urb_free_urbs(stream);
	usb_free_stream_buffers(stream);

	return 0;
}
Example #2
0
static int usb_allocate_stream_buffers(struct usb_data_stream *stream, int num, unsigned long size)
{
	stream->buf_num = 0;
	stream->buf_size = size;

	deb_mem("all in all I will use %lu bytes for streaming\n",num*size);

	for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) {
		deb_mem("allocating buffer %d\n",stream->buf_num);
		if (( stream->buf_list[stream->buf_num] =
					usb_buffer_alloc(stream->udev, size, GFP_ATOMIC,
					&stream->dma_addr[stream->buf_num]) ) == NULL) {
			deb_mem("not enough memory for urb-buffer allocation.\n");
			usb_free_stream_buffers(stream);
			return -ENOMEM;
		}
		deb_mem("buffer %d: %p (dma: %Lu)\n",
			stream->buf_num,
stream->buf_list[stream->buf_num], (long long)stream->dma_addr[stream->buf_num]);
		memset(stream->buf_list[stream->buf_num],0,size);
		stream->state |= USB_STATE_URB_BUF;
	}
	deb_mem("allocation successful\n");

	return 0;
}
Example #3
0
static int usb_alloc_stream_buffers(struct usb_data_stream *stream, int num,
				    unsigned long size)
{
	stream->buf_num = 0;
	stream->buf_size = size;

	dev_dbg(&stream->udev->dev,
			"%s: all in all I will use %lu bytes for streaming\n",
			__func__,  num * size);

	for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) {
		stream->buf_list[stream->buf_num] = usb_alloc_coherent(
				stream->udev, size, GFP_ATOMIC,
				&stream->dma_addr[stream->buf_num]);
		if (!stream->buf_list[stream->buf_num]) {
			dev_dbg(&stream->udev->dev, "%s: alloc buf=%d failed\n",
					__func__, stream->buf_num);
			usb_free_stream_buffers(stream);
			return -ENOMEM;
		}

		dev_dbg(&stream->udev->dev, "%s: alloc buf=%d %p (dma %llu)\n",
				__func__, stream->buf_num,
				stream->buf_list[stream->buf_num],
				(long long)stream->dma_addr[stream->buf_num]);
		memset(stream->buf_list[stream->buf_num], 0, size);
		stream->state |= USB_STATE_URB_BUF;
	}

	return 0;
}
Example #4
0
int usb_urb_exit(struct usb_data_stream *stream)
{
	int i;

	usb_urb_kill(stream);

	for (i = 0; i < stream->urbs_initialized; i++) {
		if (stream->urb_list[i] != NULL) {
			deb_mem("freeing URB no. %d.\n",i);
			/* free the URBs */
			usb_free_urb(stream->urb_list[i]);
		}
	}
	stream->urbs_initialized = 0;

	usb_free_stream_buffers(stream);
	return 0;
}