/* Returns NULL if no memory was available, else pointer to a list of ascbs. When this function returns, @num would be the number of SCBs which were not able to be allocated, 0 if all requested were able to be allocated.  */
struct asd_ascb* asd_ascb_alloc_list(struct asd_ha_struct *asd_ha, int *num, gfp_t gfp_flags)
/* Returns NULL if no memory was available, else pointer to a list of ascbs. When this function returns, @num would be the number of SCBs which were not able to be allocated, 0 if all requested were able to be allocated.  */
struct asd_ascb* asd_ascb_alloc_list(struct asd_ha_struct *asd_ha, int *num, gfp_t gfp_flags)
{
	struct asd_ascb *first = NULL;
	for ( ; *num > 0; --*num) {
		struct asd_ascb *ascb = asd_ascb_alloc(asd_ha, gfp_flags);
		if (!ascb)
			break;
		else if (!first)
			first = ascb;
		else {
			struct asd_ascb *last = list_entry(first->list.prev,
							   struct asd_ascb,
							   list);
			list_add_tail(&ascb->list, &first->list);
			last->scb->header.next_scb =
				cpu_to_le64(((u64)ascb->dma_scb.dma_handle));
		}
	}
	return first;
}