/* Allocate a circular buffer and all associated memory.  */
static struct edge_buf * edge_buf_alloc(unsigned int size)
/* Allocate a circular buffer and all associated memory.  */
static struct edge_buf * edge_buf_alloc(unsigned int size)
{
	struct edge_buf *eb;
	if (size == 0)
		return NULL;
	eb = kmalloc(sizeof(struct edge_buf), GFP_KERNEL);
	if (eb == NULL)
		return NULL;
	eb->buf_buf = kmalloc(size, GFP_KERNEL);
	if (eb->buf_buf == NULL) {
		kfree(eb);
		return NULL;
	}
	eb->buf_size = size;
	eb->buf_get = eb->buf_put = eb->buf_buf;
	return eb;
}