/* Returns 0 on success, otherwise returns an errno.  */
int ipath_init_qp_table(struct ipath_ibdev *idev, int size)
/* Returns 0 on success, otherwise returns an errno.  */
int ipath_init_qp_table(struct ipath_ibdev *idev, int size)
{
	int i;
	int ret;
	idev->qp_table.last = 1;
	idev->qp_table.max = size;
	idev->qp_table.nmaps = 1;
	idev->qp_table.table = kzalloc(size * sizeof(*idev->qp_table.table),
				       GFP_KERNEL);
	if (idev->qp_table.table == NULL) {
		ret = -ENOMEM;
		goto bail;
	}
	for (i = 0; i < ARRAY_SIZE(idev->qp_table.map); i++) {
		atomic_set(&idev->qp_table.map[i].n_free, BITS_PER_PAGE);
		idev->qp_table.map[i].page = NULL;
	}
	ret = 0;
bail:
	return ret;
}