aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sg.c
diff options
context:
space:
mode:
authorJes Sorensen <jes@sgi.com>2006-01-16 10:31:18 -0500
committer <jejb@mulgrave.il.steeleye.com>2006-02-27 23:55:02 -0500
commit24669f75a3231fa37444977c92d1f4838bec1233 (patch)
tree3b64076b7d031aa31b95caeb512fb7e68b5fd28f /drivers/scsi/sg.c
parentb9a33cebac70d6f67a769ce8d4078fee2b254ada (diff)
[SCSI] SCSI core kmalloc2kzalloc
Change the core SCSI code to use kzalloc rather than kmalloc+memset where possible. Signed-off-by: Jes Sorensen <jes@sgi.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/sg.c')
-rw-r--r--drivers/scsi/sg.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 2a547538d444..ecf2f6010e76 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1361,7 +1361,7 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
1361 void *old_sg_dev_arr = NULL; 1361 void *old_sg_dev_arr = NULL;
1362 int k, error; 1362 int k, error;
1363 1363
1364 sdp = kmalloc(sizeof(Sg_device), GFP_KERNEL); 1364 sdp = kzalloc(sizeof(Sg_device), GFP_KERNEL);
1365 if (!sdp) { 1365 if (!sdp) {
1366 printk(KERN_WARNING "kmalloc Sg_device failure\n"); 1366 printk(KERN_WARNING "kmalloc Sg_device failure\n");
1367 return -ENOMEM; 1367 return -ENOMEM;
@@ -1373,12 +1373,11 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
1373 int tmp_dev_max = sg_nr_dev + SG_DEV_ARR_LUMP; 1373 int tmp_dev_max = sg_nr_dev + SG_DEV_ARR_LUMP;
1374 write_unlock_irqrestore(&sg_dev_arr_lock, iflags); 1374 write_unlock_irqrestore(&sg_dev_arr_lock, iflags);
1375 1375
1376 tmp_da = kmalloc(tmp_dev_max * sizeof(Sg_device *), GFP_KERNEL); 1376 tmp_da = kzalloc(tmp_dev_max * sizeof(Sg_device *), GFP_KERNEL);
1377 if (unlikely(!tmp_da)) 1377 if (unlikely(!tmp_da))
1378 goto expand_failed; 1378 goto expand_failed;
1379 1379
1380 write_lock_irqsave(&sg_dev_arr_lock, iflags); 1380 write_lock_irqsave(&sg_dev_arr_lock, iflags);
1381 memset(tmp_da, 0, tmp_dev_max * sizeof(Sg_device *));
1382 memcpy(tmp_da, sg_dev_arr, sg_dev_max * sizeof(Sg_device *)); 1381 memcpy(tmp_da, sg_dev_arr, sg_dev_max * sizeof(Sg_device *));
1383 old_sg_dev_arr = sg_dev_arr; 1382 old_sg_dev_arr = sg_dev_arr;
1384 sg_dev_arr = tmp_da; 1383 sg_dev_arr = tmp_da;
@@ -1391,7 +1390,6 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
1391 if (unlikely(k >= SG_MAX_DEVS)) 1390 if (unlikely(k >= SG_MAX_DEVS))
1392 goto overflow; 1391 goto overflow;
1393 1392
1394 memset(sdp, 0, sizeof(*sdp));
1395 SCSI_LOG_TIMEOUT(3, printk("sg_alloc: dev=%d \n", k)); 1393 SCSI_LOG_TIMEOUT(3, printk("sg_alloc: dev=%d \n", k));
1396 sprintf(disk->disk_name, "sg%d", k); 1394 sprintf(disk->disk_name, "sg%d", k);
1397 disk->first_minor = k; 1395 disk->first_minor = k;