Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e9f31779 authored by Himanshu Jha's avatar Himanshu Jha Committed by Martin K. Petersen
Browse files

scsi: qedi: Use zeroing allocator instead of allocator/memset



Use dma_zalloc_coherent instead of dma_alloc_coherent followed by memset
0.

Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

Suggested-by: default avatarLuis R. Rodriguez <mcgrof@kernel.org>
Signed-off-by: default avatarHimanshu Jha <himanshujha199640@gmail.com>
Acked-by: default avatarManish Rangankar <Manish.Rangankar@cavium.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent bb5420c3
Loading
Loading
Loading
Loading
+15 −27
Original line number Diff line number Diff line
@@ -1268,8 +1268,7 @@ static int qedi_alloc_bdq(struct qedi_ctx *qedi)
	}

	/* Allocate list of PBL pages */
	qedi->bdq_pbl_list = dma_alloc_coherent(&qedi->pdev->dev,
						PAGE_SIZE,
	qedi->bdq_pbl_list = dma_zalloc_coherent(&qedi->pdev->dev, PAGE_SIZE,
						 &qedi->bdq_pbl_list_dma,
						 GFP_KERNEL);
	if (!qedi->bdq_pbl_list) {
@@ -1277,7 +1276,6 @@ static int qedi_alloc_bdq(struct qedi_ctx *qedi)
			 "Could not allocate list of PBL pages.\n");
		return -ENOMEM;
	}
	memset(qedi->bdq_pbl_list, 0, PAGE_SIZE);

	/*
	 * Now populate PBL list with pages that contain pointers to the
@@ -1367,8 +1365,7 @@ static int qedi_alloc_global_queues(struct qedi_ctx *qedi)
		    (qedi->global_queues[i]->cq_pbl_size +
		    (QEDI_PAGE_SIZE - 1));

		qedi->global_queues[i]->cq =
		    dma_alloc_coherent(&qedi->pdev->dev,
		qedi->global_queues[i]->cq = dma_zalloc_coherent(&qedi->pdev->dev,
								 qedi->global_queues[i]->cq_mem_size,
								 &qedi->global_queues[i]->cq_dma,
								 GFP_KERNEL);
@@ -1379,11 +1376,7 @@ static int qedi_alloc_global_queues(struct qedi_ctx *qedi)
			status = -ENOMEM;
			goto mem_alloc_failure;
		}
		memset(qedi->global_queues[i]->cq, 0,
		       qedi->global_queues[i]->cq_mem_size);

		qedi->global_queues[i]->cq_pbl =
		    dma_alloc_coherent(&qedi->pdev->dev,
		qedi->global_queues[i]->cq_pbl = dma_zalloc_coherent(&qedi->pdev->dev,
								     qedi->global_queues[i]->cq_pbl_size,
								     &qedi->global_queues[i]->cq_pbl_dma,
								     GFP_KERNEL);
@@ -1394,8 +1387,6 @@ static int qedi_alloc_global_queues(struct qedi_ctx *qedi)
			status = -ENOMEM;
			goto mem_alloc_failure;
		}
		memset(qedi->global_queues[i]->cq_pbl, 0,
		       qedi->global_queues[i]->cq_pbl_size);

		/* Create PBL */
		num_pages = qedi->global_queues[i]->cq_mem_size /
@@ -1456,7 +1447,7 @@ int qedi_alloc_sq(struct qedi_ctx *qedi, struct qedi_endpoint *ep)
	ep->sq_pbl_size = (ep->sq_mem_size / QEDI_PAGE_SIZE) * sizeof(void *);
	ep->sq_pbl_size = ep->sq_pbl_size + QEDI_PAGE_SIZE;

	ep->sq = dma_alloc_coherent(&qedi->pdev->dev, ep->sq_mem_size,
	ep->sq = dma_zalloc_coherent(&qedi->pdev->dev, ep->sq_mem_size,
				     &ep->sq_dma, GFP_KERNEL);
	if (!ep->sq) {
		QEDI_WARN(&qedi->dbg_ctx,
@@ -1464,9 +1455,7 @@ int qedi_alloc_sq(struct qedi_ctx *qedi, struct qedi_endpoint *ep)
		rval = -ENOMEM;
		goto out;
	}
	memset(ep->sq, 0, ep->sq_mem_size);

	ep->sq_pbl = dma_alloc_coherent(&qedi->pdev->dev, ep->sq_pbl_size,
	ep->sq_pbl = dma_zalloc_coherent(&qedi->pdev->dev, ep->sq_pbl_size,
					 &ep->sq_pbl_dma, GFP_KERNEL);
	if (!ep->sq_pbl) {
		QEDI_WARN(&qedi->dbg_ctx,
@@ -1474,7 +1463,6 @@ int qedi_alloc_sq(struct qedi_ctx *qedi, struct qedi_endpoint *ep)
		rval = -ENOMEM;
		goto out_free_sq;
	}
	memset(ep->sq_pbl, 0, ep->sq_pbl_size);

	/* Create PBL */
	num_pages = ep->sq_mem_size / QEDI_PAGE_SIZE;