Commit 08eb7f45 authored by Thomas Meyer's avatar Thomas Meyer Committed by Martin K. Petersen

scsi: qla2xxx: Cocci spatch "pool_zalloc-simple"

Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0.
Found by coccinelle spatch "api/alloc/pool_zalloc-simple.cocci"
Signed-off-by: default avatarThomas Meyer <thomas@m3y3r.de>
Acked-by: default avatarHimanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent df2f7729
...@@ -1116,14 +1116,13 @@ qla84xx_mgmt_cmd(struct bsg_job *bsg_job) ...@@ -1116,14 +1116,13 @@ qla84xx_mgmt_cmd(struct bsg_job *bsg_job)
return -EINVAL; return -EINVAL;
} }
mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma); mn = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma);
if (!mn) { if (!mn) {
ql_log(ql_log_warn, vha, 0x703c, ql_log(ql_log_warn, vha, 0x703c,
"DMA alloc failed for fw buffer.\n"); "DMA alloc failed for fw buffer.\n");
return -ENOMEM; return -ENOMEM;
} }
memset(mn, 0, sizeof(struct access_chip_84xx));
mn->entry_type = ACCESS_CHIP_IOCB_TYPE; mn->entry_type = ACCESS_CHIP_IOCB_TYPE;
mn->entry_count = 1; mn->entry_count = 1;
ql84_mgmt = (void *)bsg_request + sizeof(struct fc_bsg_request); ql84_mgmt = (void *)bsg_request + sizeof(struct fc_bsg_request);
......
...@@ -812,13 +812,12 @@ int qla24xx_async_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt) ...@@ -812,13 +812,12 @@ int qla24xx_async_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt)
sp->gen2 = fcport->login_gen; sp->gen2 = fcport->login_gen;
qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
if (pd == NULL) { if (pd == NULL) {
ql_log(ql_log_warn, vha, 0xd043, ql_log(ql_log_warn, vha, 0xd043,
"Failed to allocate port database structure.\n"); "Failed to allocate port database structure.\n");
goto done_free_sp; goto done_free_sp;
} }
memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE));
mb = sp->u.iocb_cmd.u.mbx.out_mb; mb = sp->u.iocb_cmd.u.mbx.out_mb;
mb[0] = MBC_GET_PORT_DATABASE; mb[0] = MBC_GET_PORT_DATABASE;
......
...@@ -1782,13 +1782,12 @@ qla2x00_get_port_database(scsi_qla_host_t *vha, fc_port_t *fcport, uint8_t opt) ...@@ -1782,13 +1782,12 @@ qla2x00_get_port_database(scsi_qla_host_t *vha, fc_port_t *fcport, uint8_t opt)
"Entered %s.\n", __func__); "Entered %s.\n", __func__);
pd24 = NULL; pd24 = NULL;
pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
if (pd == NULL) { if (pd == NULL) {
ql_log(ql_log_warn, vha, 0x1050, ql_log(ql_log_warn, vha, 0x1050,
"Failed to allocate port database structure.\n"); "Failed to allocate port database structure.\n");
return QLA_MEMORY_ALLOC_FAILED; return QLA_MEMORY_ALLOC_FAILED;
} }
memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE));
mcp->mb[0] = MBC_GET_PORT_DATABASE; mcp->mb[0] = MBC_GET_PORT_DATABASE;
if (opt != 0 && !IS_FWI2_CAPABLE(ha)) if (opt != 0 && !IS_FWI2_CAPABLE(ha))
...@@ -2255,13 +2254,12 @@ qla24xx_login_fabric(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain, ...@@ -2255,13 +2254,12 @@ qla24xx_login_fabric(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain,
else else
req = ha->req_q_map[0]; req = ha->req_q_map[0];
lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); lg = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
if (lg == NULL) { if (lg == NULL) {
ql_log(ql_log_warn, vha, 0x1062, ql_log(ql_log_warn, vha, 0x1062,
"Failed to allocate login IOCB.\n"); "Failed to allocate login IOCB.\n");
return QLA_MEMORY_ALLOC_FAILED; return QLA_MEMORY_ALLOC_FAILED;
} }
memset(lg, 0, sizeof(struct logio_entry_24xx));
lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; lg->entry_type = LOGINOUT_PORT_IOCB_TYPE;
lg->entry_count = 1; lg->entry_count = 1;
...@@ -2525,13 +2523,12 @@ qla24xx_fabric_logout(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain, ...@@ -2525,13 +2523,12 @@ qla24xx_fabric_logout(scsi_qla_host_t *vha, uint16_t loop_id, uint8_t domain,
ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106d, ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106d,
"Entered %s.\n", __func__); "Entered %s.\n", __func__);
lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); lg = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
if (lg == NULL) { if (lg == NULL) {
ql_log(ql_log_warn, vha, 0x106e, ql_log(ql_log_warn, vha, 0x106e,
"Failed to allocate logout IOCB.\n"); "Failed to allocate logout IOCB.\n");
return QLA_MEMORY_ALLOC_FAILED; return QLA_MEMORY_ALLOC_FAILED;
} }
memset(lg, 0, sizeof(struct logio_entry_24xx));
req = vha->req; req = vha->req;
lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; lg->entry_type = LOGINOUT_PORT_IOCB_TYPE;
...@@ -2820,13 +2817,12 @@ qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map) ...@@ -2820,13 +2817,12 @@ qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map)
ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107f, ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107f,
"Entered %s.\n", __func__); "Entered %s.\n", __func__);
pmap = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma); pmap = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma);
if (pmap == NULL) { if (pmap == NULL) {
ql_log(ql_log_warn, vha, 0x1080, ql_log(ql_log_warn, vha, 0x1080,
"Memory alloc failed.\n"); "Memory alloc failed.\n");
return QLA_MEMORY_ALLOC_FAILED; return QLA_MEMORY_ALLOC_FAILED;
} }
memset(pmap, 0, FCAL_MAP_SIZE);
mcp->mb[0] = MBC_GET_FC_AL_POSITION_MAP; mcp->mb[0] = MBC_GET_FC_AL_POSITION_MAP;
mcp->mb[2] = MSW(pmap_dma); mcp->mb[2] = MSW(pmap_dma);
...@@ -3014,13 +3010,12 @@ qla24xx_abort_command(srb_t *sp) ...@@ -3014,13 +3010,12 @@ qla24xx_abort_command(srb_t *sp)
return QLA_FUNCTION_FAILED; return QLA_FUNCTION_FAILED;
} }
abt = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma); abt = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma);
if (abt == NULL) { if (abt == NULL) {
ql_log(ql_log_warn, vha, 0x108d, ql_log(ql_log_warn, vha, 0x108d,
"Failed to allocate abort IOCB.\n"); "Failed to allocate abort IOCB.\n");
return QLA_MEMORY_ALLOC_FAILED; return QLA_MEMORY_ALLOC_FAILED;
} }
memset(abt, 0, sizeof(struct abort_entry_24xx));
abt->entry_type = ABORT_IOCB_TYPE; abt->entry_type = ABORT_IOCB_TYPE;
abt->entry_count = 1; abt->entry_count = 1;
...@@ -3098,13 +3093,12 @@ __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport, ...@@ -3098,13 +3093,12 @@ __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport,
rsp = req->rsp; rsp = req->rsp;
} }
tsk = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma); tsk = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma);
if (tsk == NULL) { if (tsk == NULL) {
ql_log(ql_log_warn, vha, 0x1093, ql_log(ql_log_warn, vha, 0x1093,
"Failed to allocate task management IOCB.\n"); "Failed to allocate task management IOCB.\n");
return QLA_MEMORY_ALLOC_FAILED; return QLA_MEMORY_ALLOC_FAILED;
} }
memset(tsk, 0, sizeof(struct tsk_mgmt_cmd));
tsk->p.tsk.entry_type = TSK_MGMT_IOCB_TYPE; tsk->p.tsk.entry_type = TSK_MGMT_IOCB_TYPE;
tsk->p.tsk.entry_count = 1; tsk->p.tsk.entry_count = 1;
...@@ -3856,14 +3850,13 @@ qla24xx_modify_vp_config(scsi_qla_host_t *vha) ...@@ -3856,14 +3850,13 @@ qla24xx_modify_vp_config(scsi_qla_host_t *vha)
ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10bb, ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10bb,
"Entered %s.\n", __func__); "Entered %s.\n", __func__);
vpmod = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma); vpmod = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma);
if (!vpmod) { if (!vpmod) {
ql_log(ql_log_warn, vha, 0x10bc, ql_log(ql_log_warn, vha, 0x10bc,
"Failed to allocate modify VP IOCB.\n"); "Failed to allocate modify VP IOCB.\n");
return QLA_MEMORY_ALLOC_FAILED; return QLA_MEMORY_ALLOC_FAILED;
} }
memset(vpmod, 0, sizeof(struct vp_config_entry_24xx));
vpmod->entry_type = VP_CONFIG_IOCB_TYPE; vpmod->entry_type = VP_CONFIG_IOCB_TYPE;
vpmod->entry_count = 1; vpmod->entry_count = 1;
vpmod->command = VCT_COMMAND_MOD_ENABLE_VPS; vpmod->command = VCT_COMMAND_MOD_ENABLE_VPS;
...@@ -3934,13 +3927,12 @@ qla24xx_control_vp(scsi_qla_host_t *vha, int cmd) ...@@ -3934,13 +3927,12 @@ qla24xx_control_vp(scsi_qla_host_t *vha, int cmd)
if (vp_index == 0 || vp_index >= ha->max_npiv_vports) if (vp_index == 0 || vp_index >= ha->max_npiv_vports)
return QLA_PARAMETER_ERROR; return QLA_PARAMETER_ERROR;
vce = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vce_dma); vce = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &vce_dma);
if (!vce) { if (!vce) {
ql_log(ql_log_warn, vha, 0x10c2, ql_log(ql_log_warn, vha, 0x10c2,
"Failed to allocate VP control IOCB.\n"); "Failed to allocate VP control IOCB.\n");
return QLA_MEMORY_ALLOC_FAILED; return QLA_MEMORY_ALLOC_FAILED;
} }
memset(vce, 0, sizeof(struct vp_ctrl_entry_24xx));
vce->entry_type = VP_CTRL_IOCB_TYPE; vce->entry_type = VP_CTRL_IOCB_TYPE;
vce->entry_count = 1; vce->entry_count = 1;
...@@ -6025,13 +6017,12 @@ int qla24xx_gpdb_wait(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt) ...@@ -6025,13 +6017,12 @@ int qla24xx_gpdb_wait(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt)
if (!vha->hw->flags.fw_started) if (!vha->hw->flags.fw_started)
goto done; goto done;
pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
if (pd == NULL) { if (pd == NULL) {
ql_log(ql_log_warn, vha, 0xd047, ql_log(ql_log_warn, vha, 0xd047,
"Failed to allocate port database structure.\n"); "Failed to allocate port database structure.\n");
goto done_free_sp; goto done_free_sp;
} }
memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE));
memset(&mc, 0, sizeof(mc)); memset(&mc, 0, sizeof(mc));
mc.mb[0] = MBC_GET_PORT_DATABASE; mc.mb[0] = MBC_GET_PORT_DATABASE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment