Skip to contentSkip to conversation

crypto: ccp - Replace dma_pool_alloc + memset with dma_pool_zalloc

PATCH In review Chuhong Yuan 3 participants 3 messages Jul 18, 2019 – Jul 26, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: ccp - Replace dma_pool_alloc + memset with dma_pool_zalloc

Use dma_pool_zalloc instead of using dma_pool_alloc to allocate memory and then zeroing it with memset 0.
This simplifies the code.

---
 drivers/crypto/ccp/ccp-ops.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/crypto/ccp/ccp-ops.c +1 -2
index 866b2e05ca77..03797c42b336 100644
@@ -150,14 +150,13 @@ static int ccp_init_dm_workarea(struct ccp_dm_workarea *wa,
 	if (len <= CCP_DMAPOOL_MAX_SIZE) {
 		wa->dma_pool = cmd_q->dma_pool;
 
-		wa->address = dma_pool_alloc(wa->dma_pool, GFP_KERNEL,
+		wa->address = dma_pool_zalloc(wa->dma_pool, GFP_KERNEL,
 					     &wa->dma.address);
 		if (!wa->address)
 			return -ENOMEM;
 
 		wa->dma.length = CCP_DMAPOOL_MAX_SIZE;
 
-		memset(wa->address, 0, CCP_DMAPOOL_MAX_SIZE);
 	} else {
 		wa->address = kzalloc(len, GFP_KERNEL);
 		if (!wa->address)
Signature · 1 line
2.20.1
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Chuhong Yuan

Use dma_pool_zalloc instead of using dma_pool_alloc to allocate memory and then zeroing it with memset 0.
This simplifies the code.

Quoted 25 lines
---
  drivers/crypto/ccp/ccp-ops.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/crypto/ccp/ccp-ops.c +1 -2
index 866b2e05ca77..03797c42b336 100644
@@ -150,14 +150,13 @@ static int ccp_init_dm_workarea(struct ccp_dm_workarea *wa,
  	if (len <= CCP_DMAPOOL_MAX_SIZE) {
  		wa->dma_pool = cmd_q->dma_pool;
 
-		wa->address = dma_pool_alloc(wa->dma_pool, GFP_KERNEL,
+		wa->address = dma_pool_zalloc(wa->dma_pool, GFP_KERNEL,
  					     &wa->dma.address);
  		if (!wa->address)
  			return -ENOMEM;
 
  		wa->dma.length = CCP_DMAPOOL_MAX_SIZE;
 
-		memset(wa->address, 0, CCP_DMAPOOL_MAX_SIZE);
  	} else {
  		wa->address = kzalloc(len, GFP_KERNEL);
  		if (!wa->address)
maintainer
#2 lore raw
In reply to Chuhong Yuan
Quoted 8 lines · Chuhong Yuan

Use dma_pool_zalloc instead of using dma_pool_alloc to allocate memory and then zeroing it with memset 0.
This simplifies the code.

---
drivers/crypto/ccp/ccp-ops.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt