struct scatterlist *sg;
u32 i;
struct bam_desc_hw *desc;
- unsigned int num_alloc = 0;
-
+ unsigned int num_alloc;
if (!is_slave_direction(direction)) {
dev_err(bdev->dev, "invalid dma direction\n");
return NULL;
}
- /* calculate number of required entries */
- for_each_sg(sgl, sg, sg_len, i)
- num_alloc += DIV_ROUND_UP(sg_dma_len(sg), BAM_FIFO_SIZE);
-
/* allocate enough room to accommodate the number of entries */
+ num_alloc = sg_nents_for_dma(sgl, sg_len, BAM_FIFO_SIZE);
async_desc = kzalloc(struct_size(async_desc, desc, num_alloc),
GFP_NOWAIT);
-
if (!async_desc)
return NULL;