aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorDeepak Saxena <dsaxena@plexity.net>2005-11-07 04:01:25 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-07 10:54:00 -0500
commitf5e3c2faa20615e900ab26bd957f898400435924 (patch)
treed3dd4c93539f155e3fd4ef18ae9cfe482ed1b340 /drivers/ide
parent9c2153844d72ac92b6da0ee42f7f81fb0aa91f8a (diff)
[PATCH] ide: kmalloc + memset -> kzalloc conversion
Signed-off-by: Deepak Saxena <dsaxena@plexity.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ide-cd.c4
-rw-r--r--drivers/ide/ide-disk.c4
-rw-r--r--drivers/ide/ide-floppy.c4
-rw-r--r--drivers/ide/ide-probe.c3
-rw-r--r--drivers/ide/ide-tape.c4
-rw-r--r--drivers/ide/ide-taskfile.c12
-rw-r--r--drivers/ide/ide.c3
-rw-r--r--drivers/ide/legacy/ide-cs.c6
-rw-r--r--drivers/ide/pci/hpt366.c3
-rw-r--r--drivers/ide/pci/it821x.c3
10 files changed, 14 insertions, 32 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 8b9d85526596..74d2ab0d901e 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -3455,7 +3455,7 @@ static int ide_cd_probe(struct device *dev)
3455 printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name); 3455 printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name);
3456 goto failed; 3456 goto failed;
3457 } 3457 }
3458 info = kmalloc(sizeof(struct cdrom_info), GFP_KERNEL); 3458 info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL);
3459 if (info == NULL) { 3459 if (info == NULL) {
3460 printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name); 3460 printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name);
3461 goto failed; 3461 goto failed;
@@ -3469,8 +3469,6 @@ static int ide_cd_probe(struct device *dev)
3469 3469
3470 ide_register_subdriver(drive, &ide_cdrom_driver); 3470 ide_register_subdriver(drive, &ide_cdrom_driver);
3471 3471
3472 memset(info, 0, sizeof (struct cdrom_info));
3473
3474 kref_init(&info->kref); 3472 kref_init(&info->kref);
3475 3473
3476 info->drive = drive; 3474 info->drive = drive;
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 234f5de3e929..e827b39e4b3c 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -1215,7 +1215,7 @@ static int ide_disk_probe(struct device *dev)
1215 if (drive->media != ide_disk) 1215 if (drive->media != ide_disk)
1216 goto failed; 1216 goto failed;
1217 1217
1218 idkp = kmalloc(sizeof(*idkp), GFP_KERNEL); 1218 idkp = kzalloc(sizeof(*idkp), GFP_KERNEL);
1219 if (!idkp) 1219 if (!idkp)
1220 goto failed; 1220 goto failed;
1221 1221
@@ -1228,8 +1228,6 @@ static int ide_disk_probe(struct device *dev)
1228 1228
1229 ide_register_subdriver(drive, &idedisk_driver); 1229 ide_register_subdriver(drive, &idedisk_driver);
1230 1230
1231 memset(idkp, 0, sizeof(*idkp));
1232
1233 kref_init(&idkp->kref); 1231 kref_init(&idkp->kref);
1234 1232
1235 idkp->drive = drive; 1233 idkp->drive = drive;
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 29c22fc278c6..e83f54d37f96 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -2146,7 +2146,7 @@ static int ide_floppy_probe(struct device *dev)
2146 printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name); 2146 printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name);
2147 goto failed; 2147 goto failed;
2148 } 2148 }
2149 if ((floppy = (idefloppy_floppy_t *) kmalloc (sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) { 2149 if ((floppy = (idefloppy_floppy_t *) kzalloc (sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) {
2150 printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name); 2150 printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name);
2151 goto failed; 2151 goto failed;
2152 } 2152 }
@@ -2159,8 +2159,6 @@ static int ide_floppy_probe(struct device *dev)
2159 2159
2160 ide_register_subdriver(drive, &idefloppy_driver); 2160 ide_register_subdriver(drive, &idefloppy_driver);
2161 2161
2162 memset(floppy, 0, sizeof(*floppy));
2163
2164 kref_init(&floppy->kref); 2162 kref_init(&floppy->kref);
2165 2163
2166 floppy->drive = drive; 2164 floppy->drive = drive;
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index c1128ae5cd2f..e6695e5df5bd 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -596,14 +596,13 @@ static inline u8 probe_for_drive (ide_drive_t *drive)
596 * Also note that 0 everywhere means "can't do X" 596 * Also note that 0 everywhere means "can't do X"
597 */ 597 */
598 598
599 drive->id = kmalloc(SECTOR_WORDS *4, GFP_KERNEL); 599 drive->id = kzalloc(SECTOR_WORDS *4, GFP_KERNEL);
600 drive->id_read = 0; 600 drive->id_read = 0;
601 if(drive->id == NULL) 601 if(drive->id == NULL)
602 { 602 {
603 printk(KERN_ERR "ide: out of memory for id data.\n"); 603 printk(KERN_ERR "ide: out of memory for id data.\n");
604 return 0; 604 return 0;
605 } 605 }
606 memset(drive->id, 0, SECTOR_WORDS * 4);
607 strcpy(drive->id->model, "UNKNOWN"); 606 strcpy(drive->id->model, "UNKNOWN");
608 607
609 /* skip probing? */ 608 /* skip probing? */
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 47f2b832555f..0ac7eb8f40d5 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -4850,7 +4850,7 @@ static int ide_tape_probe(struct device *dev)
4850 printk(KERN_WARNING "ide-tape: Use drive %s with ide-scsi emulation and osst.\n", drive->name); 4850 printk(KERN_WARNING "ide-tape: Use drive %s with ide-scsi emulation and osst.\n", drive->name);
4851 printk(KERN_WARNING "ide-tape: OnStream support will be removed soon from ide-tape!\n"); 4851 printk(KERN_WARNING "ide-tape: OnStream support will be removed soon from ide-tape!\n");
4852 } 4852 }
4853 tape = (idetape_tape_t *) kmalloc (sizeof (idetape_tape_t), GFP_KERNEL); 4853 tape = (idetape_tape_t *) kzalloc (sizeof (idetape_tape_t), GFP_KERNEL);
4854 if (tape == NULL) { 4854 if (tape == NULL) {
4855 printk(KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name); 4855 printk(KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name);
4856 goto failed; 4856 goto failed;
@@ -4864,8 +4864,6 @@ static int ide_tape_probe(struct device *dev)
4864 4864
4865 ide_register_subdriver(drive, &idetape_driver); 4865 ide_register_subdriver(drive, &idetape_driver);
4866 4866
4867 memset(tape, 0, sizeof(*tape));
4868
4869 kref_init(&tape->kref); 4867 kref_init(&tape->kref);
4870 4868
4871 tape->drive = drive; 4869 tape->drive = drive;
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index ace8edad6e96..9c3b4f615621 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -528,9 +528,8 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
528 528
529// printk("IDE Taskfile ...\n"); 529// printk("IDE Taskfile ...\n");
530 530
531 req_task = kmalloc(tasksize, GFP_KERNEL); 531 req_task = kzalloc(tasksize, GFP_KERNEL);
532 if (req_task == NULL) return -ENOMEM; 532 if (req_task == NULL) return -ENOMEM;
533 memset(req_task, 0, tasksize);
534 if (copy_from_user(req_task, buf, tasksize)) { 533 if (copy_from_user(req_task, buf, tasksize)) {
535 kfree(req_task); 534 kfree(req_task);
536 return -EFAULT; 535 return -EFAULT;
@@ -541,12 +540,11 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
541 540
542 if (taskout) { 541 if (taskout) {
543 int outtotal = tasksize; 542 int outtotal = tasksize;
544 outbuf = kmalloc(taskout, GFP_KERNEL); 543 outbuf = kzalloc(taskout, GFP_KERNEL);
545 if (outbuf == NULL) { 544 if (outbuf == NULL) {
546 err = -ENOMEM; 545 err = -ENOMEM;
547 goto abort; 546 goto abort;
548 } 547 }
549 memset(outbuf, 0, taskout);
550 if (copy_from_user(outbuf, buf + outtotal, taskout)) { 548 if (copy_from_user(outbuf, buf + outtotal, taskout)) {
551 err = -EFAULT; 549 err = -EFAULT;
552 goto abort; 550 goto abort;
@@ -555,12 +553,11 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
555 553
556 if (taskin) { 554 if (taskin) {
557 int intotal = tasksize + taskout; 555 int intotal = tasksize + taskout;
558 inbuf = kmalloc(taskin, GFP_KERNEL); 556 inbuf = kzalloc(taskin, GFP_KERNEL);
559 if (inbuf == NULL) { 557 if (inbuf == NULL) {
560 err = -ENOMEM; 558 err = -ENOMEM;
561 goto abort; 559 goto abort;
562 } 560 }
563 memset(inbuf, 0, taskin);
564 if (copy_from_user(inbuf, buf + intotal, taskin)) { 561 if (copy_from_user(inbuf, buf + intotal, taskin)) {
565 err = -EFAULT; 562 err = -EFAULT;
566 goto abort; 563 goto abort;
@@ -709,10 +706,9 @@ int ide_cmd_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
709 706
710 if (args[3]) { 707 if (args[3]) {
711 argsize = 4 + (SECTOR_WORDS * 4 * args[3]); 708 argsize = 4 + (SECTOR_WORDS * 4 * args[3]);
712 argbuf = kmalloc(argsize, GFP_KERNEL); 709 argbuf = kzalloc(argsize, GFP_KERNEL);
713 if (argbuf == NULL) 710 if (argbuf == NULL)
714 return -ENOMEM; 711 return -ENOMEM;
715 memcpy(argbuf, args, 4);
716 } 712 }
717 if (set_transfer(drive, &tfargs)) { 713 if (set_transfer(drive, &tfargs)) {
718 xfer_rate = args[1]; 714 xfer_rate = args[1];
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 73ca8f73917d..1bbf67882ae5 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -864,9 +864,8 @@ static int __ide_add_setting(ide_drive_t *drive, const char *name, int rw, int r
864 down(&ide_setting_sem); 864 down(&ide_setting_sem);
865 while ((*p) && strcmp((*p)->name, name) < 0) 865 while ((*p) && strcmp((*p)->name, name) < 0)
866 p = &((*p)->next); 866 p = &((*p)->next);
867 if ((setting = kmalloc(sizeof(*setting), GFP_KERNEL)) == NULL) 867 if ((setting = kzalloc(sizeof(*setting), GFP_KERNEL)) == NULL)
868 goto abort; 868 goto abort;
869 memset(setting, 0, sizeof(*setting));
870 if ((setting->name = kmalloc(strlen(name) + 1, GFP_KERNEL)) == NULL) 869 if ((setting->name = kmalloc(strlen(name) + 1, GFP_KERNEL)) == NULL)
871 goto abort; 870 goto abort;
872 strcpy(setting->name, name); 871 strcpy(setting->name, name);
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index a35a58bef1a4..1dafffa7e513 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -116,9 +116,8 @@ static dev_link_t *ide_attach(void)
116 DEBUG(0, "ide_attach()\n"); 116 DEBUG(0, "ide_attach()\n");
117 117
118 /* Create new ide device */ 118 /* Create new ide device */
119 info = kmalloc(sizeof(*info), GFP_KERNEL); 119 info = kzalloc(sizeof(*info), GFP_KERNEL);
120 if (!info) return NULL; 120 if (!info) return NULL;
121 memset(info, 0, sizeof(*info));
122 link = &info->link; link->priv = info; 121 link = &info->link; link->priv = info;
123 122
124 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 123 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
@@ -221,9 +220,8 @@ static void ide_config(dev_link_t *link)
221 220
222 DEBUG(0, "ide_config(0x%p)\n", link); 221 DEBUG(0, "ide_config(0x%p)\n", link);
223 222
224 stk = kmalloc(sizeof(*stk), GFP_KERNEL); 223 stk = kzalloc(sizeof(*stk), GFP_KERNEL);
225 if (!stk) goto err_mem; 224 if (!stk) goto err_mem;
226 memset(stk, 0, sizeof(*stk));
227 cfg = &stk->parse.cftable_entry; 225 cfg = &stk->parse.cftable_entry;
228 226
229 tuple.TupleData = (cisdata_t *)&stk->buf; 227 tuple.TupleData = (cisdata_t *)&stk->buf;
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index 127619a109ed..7b589d948bf9 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -1516,7 +1516,7 @@ static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase)
1516 1516
1517static void __devinit init_iops_hpt366(ide_hwif_t *hwif) 1517static void __devinit init_iops_hpt366(ide_hwif_t *hwif)
1518{ 1518{
1519 struct hpt_info *info = kmalloc(sizeof(struct hpt_info), GFP_KERNEL); 1519 struct hpt_info *info = kzalloc(sizeof(struct hpt_info), GFP_KERNEL);
1520 unsigned long dmabase = pci_resource_start(hwif->pci_dev, 4); 1520 unsigned long dmabase = pci_resource_start(hwif->pci_dev, 4);
1521 u8 did, rid; 1521 u8 did, rid;
1522 1522
@@ -1524,7 +1524,6 @@ static void __devinit init_iops_hpt366(ide_hwif_t *hwif)
1524 printk(KERN_WARNING "hpt366: out of memory.\n"); 1524 printk(KERN_WARNING "hpt366: out of memory.\n");
1525 return; 1525 return;
1526 } 1526 }
1527 memset(info, 0, sizeof(struct hpt_info));
1528 ide_set_hwifdata(hwif, info); 1527 ide_set_hwifdata(hwif, info);
1529 1528
1530 if(dmabase) { 1529 if(dmabase) {
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index e440036e651f..108fda83fea4 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -642,14 +642,13 @@ static void __devinit it821x_fixups(ide_hwif_t *hwif)
642 642
643static void __devinit init_hwif_it821x(ide_hwif_t *hwif) 643static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
644{ 644{
645 struct it821x_dev *idev = kmalloc(sizeof(struct it821x_dev), GFP_KERNEL); 645 struct it821x_dev *idev = kzalloc(sizeof(struct it821x_dev), GFP_KERNEL);
646 u8 conf; 646 u8 conf;
647 647
648 if(idev == NULL) { 648 if(idev == NULL) {
649 printk(KERN_ERR "it821x: out of memory, falling back to legacy behaviour.\n"); 649 printk(KERN_ERR "it821x: out of memory, falling back to legacy behaviour.\n");
650 goto fallback; 650 goto fallback;
651 } 651 }
652 memset(idev, 0, sizeof(struct it821x_dev));
653 ide_set_hwifdata(hwif, idev); 652 ide_set_hwifdata(hwif, idev);
654 653
655 pci_read_config_byte(hwif->pci_dev, 0x50, &conf); 654 pci_read_config_byte(hwif->pci_dev, 0x50, &conf);