aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Sesterhenn <snakebyte@gmx.de>2006-03-08 05:21:52 -0500
committerJens Axboe <axboe@nelson.home.kernel.dk>2006-03-27 02:29:02 -0500
commit06ff37ffb4ba8bcbda0e9d19c712c954ef7b8a0a (patch)
tree67eb8baf5abbd0776d7fe1c13106c6c9bfe10750
parent28832e83379afd0b0e83b78ac317290c79ebd496 (diff)
[PATCH] kzalloc() conversion in drivers/block
this patch converts drivers/block to kzalloc usage. Compile tested with allyesconfig. Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de> Signed-off-by: Jens Axboe <axboe@suse.de>
-rw-r--r--drivers/block/DAC960.c7
-rw-r--r--drivers/block/cciss.c10
-rw-r--r--drivers/block/cciss_scsi.c3
-rw-r--r--drivers/block/paride/bpck6.c3
4 files changed, 7 insertions, 16 deletions
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 9bdea2a5cf0e..49c7cd558ddf 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -311,11 +311,10 @@ static boolean DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
311 CommandsRemaining = CommandAllocationGroupSize; 311 CommandsRemaining = CommandAllocationGroupSize;
312 CommandGroupByteCount = 312 CommandGroupByteCount =
313 CommandsRemaining * CommandAllocationLength; 313 CommandsRemaining * CommandAllocationLength;
314 AllocationPointer = kmalloc(CommandGroupByteCount, GFP_ATOMIC); 314 AllocationPointer = kzalloc(CommandGroupByteCount, GFP_ATOMIC);
315 if (AllocationPointer == NULL) 315 if (AllocationPointer == NULL)
316 return DAC960_Failure(Controller, 316 return DAC960_Failure(Controller,
317 "AUXILIARY STRUCTURE CREATION"); 317 "AUXILIARY STRUCTURE CREATION");
318 memset(AllocationPointer, 0, CommandGroupByteCount);
319 } 318 }
320 Command = (DAC960_Command_T *) AllocationPointer; 319 Command = (DAC960_Command_T *) AllocationPointer;
321 AllocationPointer += CommandAllocationLength; 320 AllocationPointer += CommandAllocationLength;
@@ -2709,14 +2708,12 @@ DAC960_DetectController(struct pci_dev *PCI_Device,
2709 void __iomem *BaseAddress; 2708 void __iomem *BaseAddress;
2710 int i; 2709 int i;
2711 2710
2712 Controller = (DAC960_Controller_T *) 2711 Controller = kzalloc(sizeof(DAC960_Controller_T), GFP_ATOMIC);
2713 kmalloc(sizeof(DAC960_Controller_T), GFP_ATOMIC);
2714 if (Controller == NULL) { 2712 if (Controller == NULL) {
2715 DAC960_Error("Unable to allocate Controller structure for " 2713 DAC960_Error("Unable to allocate Controller structure for "
2716 "Controller at\n", NULL); 2714 "Controller at\n", NULL);
2717 return NULL; 2715 return NULL;
2718 } 2716 }
2719 memset(Controller, 0, sizeof(DAC960_Controller_T));
2720 Controller->ControllerNumber = DAC960_ControllerCount; 2717 Controller->ControllerNumber = DAC960_ControllerCount;
2721 DAC960_Controllers[DAC960_ControllerCount++] = Controller; 2718 DAC960_Controllers[DAC960_ControllerCount++] = Controller;
2722 Controller->Bus = PCI_Device->bus->number; 2719 Controller->Bus = PCI_Device->bus->number;
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 71ec9e664383..168da0c9ed3d 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -996,13 +996,11 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
996 status = -EINVAL; 996 status = -EINVAL;
997 goto cleanup1; 997 goto cleanup1;
998 } 998 }
999 buff = (unsigned char **) kmalloc(MAXSGENTRIES * 999 buff = kzalloc(MAXSGENTRIES * sizeof(char *), GFP_KERNEL);
1000 sizeof(char *), GFP_KERNEL);
1001 if (!buff) { 1000 if (!buff) {
1002 status = -ENOMEM; 1001 status = -ENOMEM;
1003 goto cleanup1; 1002 goto cleanup1;
1004 } 1003 }
1005 memset(buff, 0, MAXSGENTRIES);
1006 buff_size = (int *) kmalloc(MAXSGENTRIES * sizeof(int), 1004 buff_size = (int *) kmalloc(MAXSGENTRIES * sizeof(int),
1007 GFP_KERNEL); 1005 GFP_KERNEL);
1008 if (!buff_size) { 1006 if (!buff_size) {
@@ -2940,13 +2938,12 @@ static void cciss_getgeometry(int cntl_num)
2940 int block_size; 2938 int block_size;
2941 int total_size; 2939 int total_size;
2942 2940
2943 ld_buff = kmalloc(sizeof(ReportLunData_struct), GFP_KERNEL); 2941 ld_buff = kzalloc(sizeof(ReportLunData_struct), GFP_KERNEL);
2944 if (ld_buff == NULL) 2942 if (ld_buff == NULL)
2945 { 2943 {
2946 printk(KERN_ERR "cciss: out of memory\n"); 2944 printk(KERN_ERR "cciss: out of memory\n");
2947 return; 2945 return;
2948 } 2946 }
2949 memset(ld_buff, 0, sizeof(ReportLunData_struct));
2950 size_buff = kmalloc(sizeof( ReadCapdata_struct), GFP_KERNEL); 2947 size_buff = kmalloc(sizeof( ReadCapdata_struct), GFP_KERNEL);
2951 if (size_buff == NULL) 2948 if (size_buff == NULL)
2952 { 2949 {
@@ -3060,10 +3057,9 @@ static int alloc_cciss_hba(void)
3060 for(i=0; i< MAX_CTLR; i++) { 3057 for(i=0; i< MAX_CTLR; i++) {
3061 if (!hba[i]) { 3058 if (!hba[i]) {
3062 ctlr_info_t *p; 3059 ctlr_info_t *p;
3063 p = kmalloc(sizeof(ctlr_info_t), GFP_KERNEL); 3060 p = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL);
3064 if (!p) 3061 if (!p)
3065 goto Enomem; 3062 goto Enomem;
3066 memset(p, 0, sizeof(ctlr_info_t));
3067 for (n = 0; n < NWD; n++) 3063 for (n = 0; n < NWD; n++)
3068 p->gendisk[n] = disk[n]; 3064 p->gendisk[n] = disk[n];
3069 hba[i] = p; 3065 hba[i] = p;
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index 0e66e904bd8c..597c007fe81b 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -1027,12 +1027,11 @@ cciss_update_non_disk_devices(int cntl_num, int hostno)
1027 int i; 1027 int i;
1028 1028
1029 c = (ctlr_info_t *) hba[cntl_num]; 1029 c = (ctlr_info_t *) hba[cntl_num];
1030 ld_buff = kmalloc(reportlunsize, GFP_KERNEL); 1030 ld_buff = kzalloc(reportlunsize, GFP_KERNEL);
1031 if (ld_buff == NULL) { 1031 if (ld_buff == NULL) {
1032 printk(KERN_ERR "cciss: out of memory\n"); 1032 printk(KERN_ERR "cciss: out of memory\n");
1033 return; 1033 return;
1034 } 1034 }
1035 memset(ld_buff, 0, reportlunsize);
1036 inq_buff = kmalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL); 1035 inq_buff = kmalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL);
1037 if (inq_buff == NULL) { 1036 if (inq_buff == NULL) {
1038 printk(KERN_ERR "cciss: out of memory\n"); 1037 printk(KERN_ERR "cciss: out of memory\n");
diff --git a/drivers/block/paride/bpck6.c b/drivers/block/paride/bpck6.c
index 08d858ad64db..41a237c5957d 100644
--- a/drivers/block/paride/bpck6.c
+++ b/drivers/block/paride/bpck6.c
@@ -224,10 +224,9 @@ static void bpck6_log_adapter( PIA *pi, char * scratch, int verbose )
224 224
225static int bpck6_init_proto(PIA *pi) 225static int bpck6_init_proto(PIA *pi)
226{ 226{
227 Interface *p = kmalloc(sizeof(Interface), GFP_KERNEL); 227 Interface *p = kzalloc(sizeof(Interface), GFP_KERNEL);
228 228
229 if (p) { 229 if (p) {
230 memset(p, 0, sizeof(Interface));
231 pi->private = (unsigned long)p; 230 pi->private = (unsigned long)p;
232 return 0; 231 return 0;
233 } 232 }
l kwb">struct pci_dev *pdev) { if (pdev->subsystem_vendor == PCI_VENDOR_ID_ARTOP && (pdev->subsystem_device == PCI_DEVICE_ID_ARTOP_ATP867A || pdev->subsystem_device == PCI_DEVICE_ID_ARTOP_ATP867B)) { return 1; } return 0; } static int atp867x_cable_detect(struct ata_port *ap) { struct pci_dev *pdev = to_pci_dev(ap->host->dev); if (atp867x_cable_override(pdev)) return ATA_CBL_PATA40_SHORT; return ATA_CBL_PATA_UNK; } static struct scsi_host_template atp867x_sht = { ATA_BMDMA_SHT(DRV_NAME), }; static struct ata_port_operations atp867x_ops = { .inherits = &ata_bmdma_port_ops, .cable_detect = atp867x_cable_detect, .set_piomode = atp867x_set_piomode, .set_dmamode = atp867x_set_dmamode, }; #ifdef ATP867X_DEBUG static void atp867x_check_res(struct pci_dev *pdev) { int i; unsigned long start, len; /* Check the PCI resources for this channel are enabled */ for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { start = pci_resource_start(pdev, i); len = pci_resource_len(pdev, i); printk(KERN_DEBUG "ATP867X: resource start:len=%lx:%lx\n", start, len); } } static void atp867x_check_ports(struct ata_port *ap, int port) { struct ata_ioports *ioaddr = &ap->ioaddr; struct atp867x_priv *dp = ap->private_data; printk(KERN_DEBUG "ATP867X: port[%d] addresses\n" " cmd_addr =0x%llx, 0x%llx\n" " ctl_addr =0x%llx, 0x%llx\n" " bmdma_addr =0x%llx, 0x%llx\n" " data_addr =0x%llx\n" " error_addr =0x%llx\n" " feature_addr =0x%llx\n" " nsect_addr =0x%llx\n" " lbal_addr =0x%llx\n" " lbam_addr =0x%llx\n" " lbah_addr =0x%llx\n" " device_addr =0x%llx\n" " status_addr =0x%llx\n" " command_addr =0x%llx\n" " dp->dma_mode =0x%llx\n" " dp->mstr_piospd =0x%llx\n" " dp->slave_piospd =0x%llx\n" " dp->eightb_piospd =0x%llx\n" " dp->pci66mhz =0x%lx\n", port, (unsigned long long)ioaddr->cmd_addr, (unsigned long long)ATP867X_IO_PORTBASE(ap, port), (unsigned long long)ioaddr->ctl_addr, (unsigned long long)ATP867X_IO_ALTSTATUS(ap, port), (unsigned long long)ioaddr->bmdma_addr, (unsigned long long)ATP867X_IO_DMABASE(ap, port), (unsigned long long)ioaddr->data_addr, (unsigned long long)ioaddr->error_addr, (unsigned long long)ioaddr->feature_addr, (unsigned long long)ioaddr->nsect_addr, (unsigned long long)ioaddr->lbal_addr, (unsigned long long)ioaddr->lbam_addr, (unsigned long long)ioaddr->lbah_addr, (unsigned long long)ioaddr->device_addr, (unsigned long long)ioaddr->status_addr, (unsigned long long)ioaddr->command_addr, (unsigned long long)dp->dma_mode, (unsigned long long)dp->mstr_piospd, (unsigned long long)dp->slave_piospd, (unsigned long long)dp->eightb_piospd, (unsigned long)dp->pci66mhz); } #endif static int atp867x_set_priv(struct ata_port *ap) { struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct atp867x_priv *dp; int port = ap->port_no; dp = ap->private_data = devm_kzalloc(&pdev->dev, sizeof(*dp), GFP_KERNEL); if (dp == NULL) return -ENOMEM; dp->dma_mode = ATP867X_IO_DMAMODE(ap, port); dp->mstr_piospd = ATP867X_IO_MSTRPIOSPD(ap, port); dp->slave_piospd = ATP867X_IO_SLAVPIOSPD(ap, port); dp->eightb_piospd = ATP867X_IO_8BPIOSPD(ap, port); dp->pci66mhz = ioread8(ATP867X_SYS_INFO(ap)) & ATP867X_IO_SYS_INFO_66MHZ; return 0; } static void atp867x_fixup(struct ata_host *host) { struct pci_dev *pdev = to_pci_dev(host->dev); struct ata_port *ap = host->ports[0]; int i; u8 v; /* * Broken BIOS might not set latency high enough */ pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &v); if (v < 0x80) { v = 0x80; pci_write_config_byte(pdev, PCI_LATENCY_TIMER, v); printk(KERN_DEBUG "ATP867X: set latency timer of device %s" " to %d\n", pci_name(pdev), v); } /* * init 8bit io ports speed(0aaarrrr) to 43h and * init udma modes of master/slave to 0/0(11h) */ for (i = 0; i < ATP867X_NUM_PORTS; i++) iowrite16(ATP867X_IO_PORTSPD_VAL, ATP867X_IO_PORTSPD(ap, i)); /* * init PreREAD counts */ for (i = 0; i < ATP867X_NUM_PORTS; i++) iowrite16(ATP867X_PREREAD_VAL, ATP867X_IO_PREREAD(ap, i)); v = ioread8(ATP867X_IOBASE(ap) + 0x28); v &= 0xcf; /* Enable INTA#: bit4=0 means enable */ v |= 0xc0; /* Enable PCI burst, MRM & not immediate interrupts */ iowrite8(v, ATP867X_IOBASE(ap) + 0x28); /* * Turn off the over clocked udma5 mode, only for Rev-B */ v = ioread8(ATP867X_SYS_INFO(ap)); v &= ATP867X_IO_SYS_MASK_RESERVED; if (pdev->device == PCI_DEVICE_ID_ARTOP_ATP867B) v |= ATP867X_IO_SYS_INFO_SLOW_UDMA5; iowrite8(v, ATP867X_SYS_INFO(ap)); } static int atp867x_ata_pci_sff_init_host(struct ata_host *host) { struct device *gdev = host->dev; struct pci_dev *pdev = to_pci_dev(gdev); unsigned int mask = 0; int i, rc; /* * do not map rombase */ rc = pcim_iomap_regions(pdev, 1 << ATP867X_BAR_IOBASE, DRV_NAME); if (rc == -EBUSY) pcim_pin_device(pdev); if (rc) return rc; host->iomap = pcim_iomap_table(pdev); #ifdef ATP867X_DEBUG atp867x_check_res(pdev); for (i = 0; i < PCI_ROM_RESOURCE; i++) printk(KERN_DEBUG "ATP867X: iomap[%d]=0x%llx\n", i, (unsigned long long)(host->iomap[i])); #endif /* * request, iomap BARs and init port addresses accordingly */ for (i = 0; i < host->n_ports; i++) { struct ata_port *ap = host->ports[i]; struct ata_ioports *ioaddr = &ap->ioaddr; ioaddr->cmd_addr = ATP867X_IO_PORTBASE(ap, i); ioaddr->ctl_addr = ioaddr->altstatus_addr = ATP867X_IO_ALTSTATUS(ap, i); ioaddr->bmdma_addr = ATP867X_IO_DMABASE(ap, i); ata_sff_std_ports(ioaddr); rc = atp867x_set_priv(ap); if (rc) return rc; #ifdef ATP867X_DEBUG atp867x_check_ports(ap, i); #endif ata_port_desc(ap, "cmd 0x%lx ctl 0x%lx", (unsigned long)ioaddr->cmd_addr, (unsigned long)ioaddr->ctl_addr); ata_port_desc(ap, "bmdma 0x%lx", (unsigned long)ioaddr->bmdma_addr); mask |= 1 << i; } if (!mask) { dev_printk(KERN_ERR, gdev, "no available native port\n"); return -ENODEV; } atp867x_fixup(host); rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); if (rc) return rc; rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); return rc; } static int atp867x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { static int printed_version; static const struct ata_port_info info_867x = { .flags = ATA_FLAG_SLAVE_POSS, .pio_mask = ATA_PIO4, .udma_mask = ATA_UDMA6, .port_ops = &atp867x_ops, }; struct ata_host *host; const struct ata_port_info *ppi[] = { &info_867x, NULL }; int rc; if (!printed_version++) dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); rc = pcim_enable_device(pdev); if (rc) return rc; printk(KERN_INFO "ATP867X: ATP867 ATA UDMA133 controller (rev %02X)", pdev->device); host = ata_host_alloc_pinfo(&pdev->dev, ppi, ATP867X_NUM_PORTS); if (!host) { dev_printk(KERN_ERR, &pdev->dev, "failed to allocate ATA host\n"); rc = -ENOMEM; goto err_out; } rc = atp867x_ata_pci_sff_init_host(host); if (rc) { dev_printk(KERN_ERR, &pdev->dev, "failed to init host\n"); goto err_out; } pci_set_master(pdev); rc = ata_host_activate(host, pdev->irq, ata_sff_interrupt, IRQF_SHARED, &atp867x_sht); if (rc) dev_printk(KERN_ERR, &pdev->dev, "failed to activate host\n"); err_out: return rc; } #ifdef CONFIG_PM static int atp867x_reinit_one(struct pci_dev *pdev) { struct ata_host *host = dev_get_drvdata(&pdev->dev); int rc; rc = ata_pci_device_do_resume(pdev); if (rc) return rc; atp867x_fixup(host); ata_host_resume(host); return 0; } #endif static struct pci_device_id atp867x_pci_tbl[] = { { PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP867A), 0 }, { PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP867B), 0 }, { }, }; static struct pci_driver atp867x_driver = { .name = DRV_NAME, .id_table = atp867x_pci_tbl, .probe = atp867x_init_one, .remove = ata_pci_remove_one, #ifdef CONFIG_PM .suspend = ata_pci_device_suspend, .resume = atp867x_reinit_one, #endif }; static int __init atp867x_init(void) { return pci_register_driver(&atp867x_driver); } static void __exit atp867x_exit(void) { pci_unregister_driver(&atp867x_driver); } MODULE_AUTHOR("John(Jung-Ik) Lee, Google Inc."); MODULE_DESCRIPTION("low level driver for Artop/Acard 867x ATA controller"); MODULE_LICENSE("GPL"); MODULE_DEVICE_TABLE(pci, atp867x_pci_tbl); MODULE_VERSION(DRV_VERSION); module_init(atp867x_init); module_exit(atp867x_exit);