/* Add a new chunk of special memory to the specified pool.  */
int gen_pool_add(struct gen_pool *pool, unsigned long addr, size_t size, int nid)
/* Add a new chunk of special memory to the specified pool.  */
int gen_pool_add(struct gen_pool *pool, unsigned long addr, size_t size, int nid)
{
	struct gen_pool_chunk *chunk;
	int nbits = size >> pool->min_alloc_order;
	int nbytes = sizeof(struct gen_pool_chunk) +
				(nbits + BITS_PER_BYTE - 1) / BITS_PER_BYTE;
	chunk = kmalloc_node(nbytes, GFP_KERNEL | __GFP_ZERO, nid);
	if (unlikely(chunk == NULL))
		return -1;
	spin_lock_init(&chunk->lock);
	chunk->start_addr = addr;
	chunk->end_addr = addr + size;
	write_lock(&pool->lock);
	list_add(&chunk->next_chunk, &pool->chunks);
	write_unlock(&pool->lock);
	return 0;
}