/* allocate pages for queue: outer loop allocates whole kernel pages (page aligned) and inner loop divides a kernel page into smaller hca queue pages  */
static int alloc_queue_pages(struct ipz_queue *queue, const u32 nr_of_pages)
/* allocate pages for queue: outer loop allocates whole kernel pages (page aligned) and inner loop divides a kernel page into smaller hca queue pages  */
static int alloc_queue_pages(struct ipz_queue *queue, const u32 nr_of_pages)
{
	int k, f = 0;
	u8 *kpage;
	while (f < nr_of_pages) {
		kpage = (u8 *)get_zeroed_page(GFP_KERNEL);
		if (!kpage)
			goto out;
		for (k = 0; k < PAGES_PER_KPAGE && f < nr_of_pages; k++) {
			queue->queue_pages[f] = (struct ipz_page *)kpage;
			kpage += EHCA_PAGESIZE;
			f++;
		}
	}
	return 1;
out:
	for (f = 0; f < nr_of_pages && queue->queue_pages[f];
	     f += PAGES_PER_KPAGE)
		free_page((unsigned long)(queue->queue_pages)[f]);
	return 0;
}