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