[SCSI] kmalloc + memset conversion to kzalloc

In NCR_D700, a4000t, aic7xxx_old, bvme6000, dpt_i2o, gdth, lpfc,
megaraid, mvme16x osst, pluto, qla2xxx, zorro7xx

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
This commit is contained in:
Mariusz Kozlowski 2007-08-11 10:13:24 +02:00 committed by James Bottomley
parent f36789e22a
commit bbfbbbc118
15 changed files with 44 additions and 67 deletions

View File

@ -313,10 +313,10 @@ NCR_D700_probe(struct device *dev)
break; break;
} }
p = kmalloc(sizeof(*p), GFP_KERNEL); p = kzalloc(sizeof(*p), GFP_KERNEL);
if (!p) if (!p)
return -ENOMEM; return -ENOMEM;
memset(p, '\0', sizeof(*p));
p->dev = dev; p->dev = dev;
snprintf(p->name, sizeof(p->name), "D700(%s)", dev->bus_id); snprintf(p->name, sizeof(p->name), "D700(%s)", dev->bus_id);
if (request_irq(irq, NCR_D700_intr, IRQF_SHARED, p->name, p)) { if (request_irq(irq, NCR_D700_intr, IRQF_SHARED, p->name, p)) {

View File

@ -37,7 +37,7 @@ static struct platform_device *a4000t_scsi_device;
static int __devinit a4000t_probe(struct device *dev) static int __devinit a4000t_probe(struct device *dev)
{ {
struct Scsi_Host * host = NULL; struct Scsi_Host *host;
struct NCR_700_Host_Parameters *hostdata; struct NCR_700_Host_Parameters *hostdata;
if (!(MACH_IS_AMIGA && AMIGAHW_PRESENT(A4000_SCSI))) if (!(MACH_IS_AMIGA && AMIGAHW_PRESENT(A4000_SCSI)))
@ -47,12 +47,11 @@ static int __devinit a4000t_probe(struct device *dev)
"A4000T builtin SCSI")) "A4000T builtin SCSI"))
goto out; goto out;
hostdata = kmalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL); hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
if (hostdata == NULL) { if (!hostdata) {
printk(KERN_ERR "a4000t-scsi: Failed to allocate host data\n"); printk(KERN_ERR "a4000t-scsi: Failed to allocate host data\n");
goto out_release; goto out_release;
} }
memset(hostdata, 0, sizeof(struct NCR_700_Host_Parameters));
/* Fill in the required pieces of hostdata */ /* Fill in the required pieces of hostdata */
hostdata->base = (void __iomem *)ZTWO_VADDR(A4000T_SCSI_ADDR); hostdata->base = (void __iomem *)ZTWO_VADDR(A4000T_SCSI_ADDR);

View File

@ -8416,10 +8416,9 @@ aic7xxx_alloc(struct scsi_host_template *sht, struct aic7xxx_host *temp)
*p = *temp; *p = *temp;
p->host = host; p->host = host;
p->scb_data = kmalloc(sizeof(scb_data_type), GFP_ATOMIC); p->scb_data = kzalloc(sizeof(scb_data_type), GFP_ATOMIC);
if (p->scb_data != NULL) if (!p->scb_data)
{ {
memset(p->scb_data, 0, sizeof(scb_data_type));
scbq_init (&p->scb_data->free_scbs); scbq_init (&p->scb_data->free_scbs);
} }
else else
@ -9196,10 +9195,9 @@ aic7xxx_detect(struct scsi_host_template *template)
printk(KERN_INFO " this driver, we are ignoring it.\n"); printk(KERN_INFO " this driver, we are ignoring it.\n");
} }
} }
else if ( (temp_p = kmalloc(sizeof(struct aic7xxx_host), else if ( (temp_p = kzalloc(sizeof(struct aic7xxx_host),
GFP_ATOMIC)) != NULL ) GFP_ATOMIC)) != NULL )
{ {
memset(temp_p, 0, sizeof(struct aic7xxx_host));
temp_p->chip = aic_pdevs[i].chip | AHC_PCI; temp_p->chip = aic_pdevs[i].chip | AHC_PCI;
temp_p->flags = aic_pdevs[i].flags; temp_p->flags = aic_pdevs[i].flags;
temp_p->features = aic_pdevs[i].features; temp_p->features = aic_pdevs[i].features;

View File

@ -36,19 +36,18 @@ static struct platform_device *bvme6000_scsi_device;
static __devinit int static __devinit int
bvme6000_probe(struct device *dev) bvme6000_probe(struct device *dev)
{ {
struct Scsi_Host * host = NULL; struct Scsi_Host *host;
struct NCR_700_Host_Parameters *hostdata; struct NCR_700_Host_Parameters *hostdata;
if (!MACH_IS_BVME6000) if (!MACH_IS_BVME6000)
goto out; goto out;
hostdata = kmalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL); hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
if (hostdata == NULL) { if (!hostdata) {
printk(KERN_ERR "bvme6000-scsi: " printk(KERN_ERR "bvme6000-scsi: "
"Failed to allocate host data\n"); "Failed to allocate host data\n");
goto out; goto out;
} }
memset(hostdata, 0, sizeof(struct NCR_700_Host_Parameters));
/* Fill in the required pieces of hostdata */ /* Fill in the required pieces of hostdata */
hostdata->base = (void __iomem *)BVME_NCR53C710_BASE; hostdata->base = (void __iomem *)BVME_NCR53C710_BASE;

View File

@ -949,16 +949,14 @@ static int adpt_install_hba(struct pci_dev* pDev)
} }
// Allocate and zero the data structure // Allocate and zero the data structure
pHba = kmalloc(sizeof(adpt_hba), GFP_KERNEL); pHba = kzalloc(sizeof(adpt_hba), GFP_KERNEL);
if( pHba == NULL) { if (!pHba) {
if(msg_addr_virt != base_addr_virt){ if (msg_addr_virt != base_addr_virt)
iounmap(msg_addr_virt); iounmap(msg_addr_virt);
}
iounmap(base_addr_virt); iounmap(base_addr_virt);
pci_release_regions(pDev); pci_release_regions(pDev);
return -ENOMEM; return -ENOMEM;
} }
memset(pHba, 0, sizeof(adpt_hba));
mutex_lock(&adpt_configuration_lock); mutex_lock(&adpt_configuration_lock);
@ -2622,14 +2620,13 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba)
msg=(u32 __iomem *)(pHba->msg_addr_virt+m); msg=(u32 __iomem *)(pHba->msg_addr_virt+m);
status = kmalloc(4,GFP_KERNEL|ADDR32); status = kzalloc(4, GFP_KERNEL|ADDR32);
if (status==NULL) { if (!status) {
adpt_send_nop(pHba, m); adpt_send_nop(pHba, m);
printk(KERN_WARNING"%s: IOP reset failed - no free memory.\n", printk(KERN_WARNING"%s: IOP reset failed - no free memory.\n",
pHba->name); pHba->name);
return -ENOMEM; return -ENOMEM;
} }
memset(status, 0, 4);
writel(EIGHT_WORD_MSG_SIZE| SGL_OFFSET_6, &msg[0]); writel(EIGHT_WORD_MSG_SIZE| SGL_OFFSET_6, &msg[0]);
writel(I2O_CMD_OUTBOUND_INIT<<24 | HOST_TID<<12 | ADAPTER_TID, &msg[1]); writel(I2O_CMD_OUTBOUND_INIT<<24 | HOST_TID<<12 | ADAPTER_TID, &msg[1]);
@ -2668,12 +2665,11 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba)
kfree(pHba->reply_pool); kfree(pHba->reply_pool);
pHba->reply_pool = kmalloc(pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, GFP_KERNEL|ADDR32); pHba->reply_pool = kzalloc(pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, GFP_KERNEL|ADDR32);
if(!pHba->reply_pool){ if (!pHba->reply_pool) {
printk(KERN_ERR"%s: Could not allocate reply pool\n",pHba->name); printk(KERN_ERR "%s: Could not allocate reply pool\n", pHba->name);
return -1; return -ENOMEM;
} }
memset(pHba->reply_pool, 0 , pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4);
ptr = pHba->reply_pool; ptr = pHba->reply_pool;
for(i = 0; i < pHba->reply_fifo_size; i++) { for(i = 0; i < pHba->reply_fifo_size; i++) {
@ -2884,12 +2880,11 @@ static int adpt_i2o_build_sys_table(void)
kfree(sys_tbl); kfree(sys_tbl);
sys_tbl = kmalloc(sys_tbl_len, GFP_KERNEL|ADDR32); sys_tbl = kzalloc(sys_tbl_len, GFP_KERNEL|ADDR32);
if(!sys_tbl) { if (!sys_tbl) {
printk(KERN_WARNING "SysTab Set failed. Out of memory.\n"); printk(KERN_WARNING "SysTab Set failed. Out of memory.\n");
return -ENOMEM; return -ENOMEM;
} }
memset(sys_tbl, 0, sys_tbl_len);
sys_tbl->num_entries = hba_count; sys_tbl->num_entries = hba_count;
sys_tbl->version = I2OVERSION; sys_tbl->version = I2OVERSION;

View File

@ -726,10 +726,10 @@ int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd, char *cmnd,
DECLARE_COMPLETION_ONSTACK(wait); DECLARE_COMPLETION_ONSTACK(wait);
int rval; int rval;
scp = kmalloc(sizeof(*scp), GFP_KERNEL); scp = kzalloc(sizeof(*scp), GFP_KERNEL);
if (!scp) if (!scp)
return -ENOMEM; return -ENOMEM;
memset(scp, 0, sizeof(*scp));
scp->device = sdev; scp->device = sdev;
/* use request field to save the ptr. to completion struct. */ /* use request field to save the ptr. to completion struct. */
scp->request = (struct request *)&wait; scp->request = (struct request *)&wait;
@ -5518,10 +5518,9 @@ static int gdth_ioctl(struct inode *inode, struct file *filep,
ha = HADATA(gdth_ctr_tab[hanum]); ha = HADATA(gdth_ctr_tab[hanum]);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
scp = kmalloc(sizeof(*scp), GFP_KERNEL); scp = kzalloc(sizeof(*scp), GFP_KERNEL);
if (!scp) if (!scp)
return -ENOMEM; return -ENOMEM;
memset(scp, 0, sizeof(*scp));
scp->device = ha->sdev; scp->device = ha->sdev;
scp->cmd_len = 12; scp->cmd_len = 12;
scp->use_sg = 0; scp->use_sg = 0;

View File

@ -901,7 +901,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
} }
} }
vport->disc_trc = kmalloc( vport->disc_trc = kmzlloc(
(sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_disc_trc), (sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_disc_trc),
GFP_KERNEL); GFP_KERNEL);
@ -912,8 +912,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
goto debug_failed; goto debug_failed;
} }
atomic_set(&vport->disc_trc_cnt, 0); atomic_set(&vport->disc_trc_cnt, 0);
memset(vport->disc_trc, 0,
(sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_disc_trc));
snprintf(name, sizeof(name), "discovery_trace"); snprintf(name, sizeof(name), "discovery_trace");
vport->debug_disc_trc = vport->debug_disc_trc =

View File

@ -1265,11 +1265,10 @@ lpfc_hba_init(struct lpfc_hba *phba, uint32_t *hbainit)
uint32_t *HashWorking; uint32_t *HashWorking;
uint32_t *pwwnn = (uint32_t *) phba->wwnn; uint32_t *pwwnn = (uint32_t *) phba->wwnn;
HashWorking = kmalloc(80 * sizeof(uint32_t), GFP_KERNEL); HashWorking = kcalloc(80, sizeof(uint32_t), GFP_KERNEL);
if (!HashWorking) if (!HashWorking)
return; return;
memset(HashWorking, 0, (80 * sizeof(uint32_t)));
HashWorking[0] = HashWorking[78] = *pwwnn++; HashWorking[0] = HashWorking[78] = *pwwnn++;
HashWorking[1] = HashWorking[79] = *pwwnn; HashWorking[1] = HashWorking[79] = *pwwnn;

View File

@ -202,10 +202,9 @@ lpfc_new_scsi_buf(struct lpfc_vport *vport)
dma_addr_t pdma_phys; dma_addr_t pdma_phys;
uint16_t iotag; uint16_t iotag;
psb = kmalloc(sizeof(struct lpfc_scsi_buf), GFP_KERNEL); psb = kzalloc(sizeof(struct lpfc_scsi_buf), GFP_KERNEL);
if (!psb) if (!psb)
return NULL; return NULL;
memset(psb, 0, sizeof (struct lpfc_scsi_buf));
/* /*
* Get memory from the pci pool to map the virt space to pci bus space * Get memory from the pci pool to map the virt space to pci bus space

View File

@ -4408,8 +4408,7 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)
scmd = &adapter->int_scmd; scmd = &adapter->int_scmd;
memset(scmd, 0, sizeof(Scsi_Cmnd)); memset(scmd, 0, sizeof(Scsi_Cmnd));
sdev = kmalloc(sizeof(struct scsi_device), GFP_KERNEL); sdev = kzalloc(sizeof(struct scsi_device), GFP_KERNEL);
memset(sdev, 0, sizeof(struct scsi_device));
scmd->device = sdev; scmd->device = sdev;
scmd->device->host = adapter->host; scmd->device->host = adapter->host;

View File

@ -48,13 +48,12 @@ mvme16x_probe(struct device *dev)
goto out; goto out;
} }
hostdata = kmalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL); hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
if (hostdata == NULL) { if (hostdata == NULL) {
printk(KERN_ERR "mvme16x-scsi: " printk(KERN_ERR "mvme16x-scsi: "
"Failed to allocate host data\n"); "Failed to allocate host data\n");
goto out; goto out;
} }
memset(hostdata, 0, sizeof(struct NCR_700_Host_Parameters));
/* Fill in the required pieces of hostdata */ /* Fill in the required pieces of hostdata */
hostdata->base = (void __iomem *)0xfff47000UL; hostdata->base = (void __iomem *)0xfff47000UL;

View File

@ -5778,13 +5778,12 @@ static int osst_probe(struct device *dev)
dev_num = i; dev_num = i;
/* allocate a struct osst_tape for this device */ /* allocate a struct osst_tape for this device */
tpnt = kmalloc(sizeof(struct osst_tape), GFP_ATOMIC); tpnt = kzalloc(sizeof(struct osst_tape), GFP_ATOMIC);
if (tpnt == NULL) { if (!tpnt) {
write_unlock(&os_scsi_tapes_lock); write_unlock(&os_scsi_tapes_lock);
printk(KERN_ERR "osst :E: Can't allocate device descriptor, device not attached.\n"); printk(KERN_ERR "osst :E: Can't allocate device descriptor, device not attached.\n");
goto out_put_disk; goto out_put_disk;
} }
memset(tpnt, 0, sizeof(struct osst_tape));
/* allocate a buffer for this device */ /* allocate a buffer for this device */
i = SDp->host->sg_tablesize; i = SDp->host->sg_tablesize;

View File

@ -111,13 +111,12 @@ int __init pluto_detect(struct scsi_host_template *tpnt)
#endif #endif
return 0; return 0;
} }
fcs = kmalloc(sizeof (struct ctrl_inquiry) * fcscount, GFP_DMA); fcs = kcalloc(fcscount, sizeof (struct ctrl_inquiry), GFP_DMA);
if (!fcs) { if (!fcs) {
printk ("PLUTO: Not enough memory to probe\n"); printk ("PLUTO: Not enough memory to probe\n");
return 0; return 0;
} }
memset (fcs, 0, sizeof (struct ctrl_inquiry) * fcscount);
memset (&dev, 0, sizeof(dev)); memset (&dev, 0, sizeof(dev));
atomic_set (&fcss, fcscount); atomic_set (&fcss, fcscount);
@ -211,7 +210,7 @@ int __init pluto_detect(struct scsi_host_template *tpnt)
char *p; char *p;
long *ages; long *ages;
ages = kmalloc (((inq->channels + 1) * inq->targets) * sizeof(long), GFP_KERNEL); ages = kcalloc((inq->channels + 1) * inq->targets, sizeof(long), GFP_KERNEL);
if (!ages) continue; if (!ages) continue;
host = scsi_register (tpnt, sizeof (struct pluto)); host = scsi_register (tpnt, sizeof (struct pluto));
@ -238,7 +237,6 @@ int __init pluto_detect(struct scsi_host_template *tpnt)
fc->channels = inq->channels + 1; fc->channels = inq->channels + 1;
fc->targets = inq->targets; fc->targets = inq->targets;
fc->ages = ages; fc->ages = ages;
memset (ages, 0, ((inq->channels + 1) * inq->targets) * sizeof(long));
pluto->fc = fc; pluto->fc = fc;
memcpy (pluto->rev_str, inq->revision, 4); memcpy (pluto->rev_str, inq->revision, 4);
@ -260,7 +258,7 @@ int __init pluto_detect(struct scsi_host_template *tpnt)
} else } else
fc->fcp_register(fc, TYPE_SCSI_FCP, 1); fc->fcp_register(fc, TYPE_SCSI_FCP, 1);
} }
kfree((char *)fcs); kfree(fcs);
if (nplutos) if (nplutos)
printk ("PLUTO: Total of %d SparcSTORAGE Arrays found\n", nplutos); printk ("PLUTO: Total of %d SparcSTORAGE Arrays found\n", nplutos);
return nplutos; return nplutos;

View File

@ -1786,12 +1786,11 @@ qla2x00_alloc_fcport(scsi_qla_host_t *ha, gfp_t flags)
{ {
fc_port_t *fcport; fc_port_t *fcport;
fcport = kmalloc(sizeof(fc_port_t), flags); fcport = kzalloc(sizeof(fc_port_t), flags);
if (fcport == NULL) if (!fcport)
return (fcport); return NULL;
/* Setup fcport template structure. */ /* Setup fcport template structure. */
memset(fcport, 0, sizeof (fc_port_t));
fcport->ha = ha; fcport->ha = ha;
fcport->vp_idx = ha->vp_idx; fcport->vp_idx = ha->vp_idx;
fcport->port_type = FCT_UNKNOWN; fcport->port_type = FCT_UNKNOWN;
@ -1801,7 +1800,7 @@ qla2x00_alloc_fcport(scsi_qla_host_t *ha, gfp_t flags)
fcport->supported_classes = FC_COS_UNSPECIFIED; fcport->supported_classes = FC_COS_UNSPECIFIED;
spin_lock_init(&fcport->rport_lock); spin_lock_init(&fcport->rport_lock);
return (fcport); return fcport;
} }
/* /*
@ -2473,13 +2472,12 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports)
rval = QLA_SUCCESS; rval = QLA_SUCCESS;
/* Try GID_PT to get device list, else GAN. */ /* Try GID_PT to get device list, else GAN. */
swl = kmalloc(sizeof(sw_info_t) * MAX_FIBRE_DEVICES, GFP_ATOMIC); swl = kcalloc(MAX_FIBRE_DEVICES, sizeof(sw_info_t), GFP_ATOMIC);
if (swl == NULL) { if (!swl) {
/*EMPTY*/ /*EMPTY*/
DEBUG2(printk("scsi(%ld): GID_PT allocations failed, fallback " DEBUG2(printk("scsi(%ld): GID_PT allocations failed, fallback "
"on GA_NXT\n", ha->host_no)); "on GA_NXT\n", ha->host_no));
} else { } else {
memset(swl, 0, sizeof(sw_info_t) * MAX_FIBRE_DEVICES);
if (qla2x00_gid_pt(ha, swl) != QLA_SUCCESS) { if (qla2x00_gid_pt(ha, swl) != QLA_SUCCESS) {
kfree(swl); kfree(swl);
swl = NULL; swl = NULL;

View File

@ -69,7 +69,7 @@ static struct zorro_device_id zorro7xx_zorro_tbl[] __devinitdata = {
static int __devinit zorro7xx_init_one(struct zorro_dev *z, static int __devinit zorro7xx_init_one(struct zorro_dev *z,
const struct zorro_device_id *ent) const struct zorro_device_id *ent)
{ {
struct Scsi_Host * host = NULL; struct Scsi_Host *host;
struct NCR_700_Host_Parameters *hostdata; struct NCR_700_Host_Parameters *hostdata;
struct zorro_driver_data *zdd; struct zorro_driver_data *zdd;
unsigned long board, ioaddr; unsigned long board, ioaddr;
@ -89,14 +89,12 @@ static int __devinit zorro7xx_init_one(struct zorro_dev *z,
return -EBUSY; return -EBUSY;
} }
hostdata = kmalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL); hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
if (hostdata == NULL) { if (!hostdata) {
printk(KERN_ERR "zorro7xx: Failed to allocate host data\n"); printk(KERN_ERR "zorro7xx: Failed to allocate host data\n");
goto out_release; goto out_release;
} }
memset(hostdata, 0, sizeof(struct NCR_700_Host_Parameters));
/* Fill in the required pieces of hostdata */ /* Fill in the required pieces of hostdata */
if (ioaddr > 0x01000000) if (ioaddr > 0x01000000)
hostdata->base = ioremap(ioaddr, zorro_resource_len(z)); hostdata->base = ioremap(ioaddr, zorro_resource_len(z));