diff options
Diffstat (limited to 'drivers/scsi/sg.c')
-rw-r--r-- | drivers/scsi/sg.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 5a0a19322d01..a8b05ce5de52 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -44,7 +44,6 @@ static int sg_version_num = 30533; /* 2 digits for each component */ | |||
44 | #include <linux/poll.h> | 44 | #include <linux/poll.h> |
45 | #include <linux/smp_lock.h> | 45 | #include <linux/smp_lock.h> |
46 | #include <linux/moduleparam.h> | 46 | #include <linux/moduleparam.h> |
47 | #include <linux/devfs_fs_kernel.h> | ||
48 | #include <linux/cdev.h> | 47 | #include <linux/cdev.h> |
49 | #include <linux/seq_file.h> | 48 | #include <linux/seq_file.h> |
50 | #include <linux/blkdev.h> | 49 | #include <linux/blkdev.h> |
@@ -1361,7 +1360,7 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp) | |||
1361 | void *old_sg_dev_arr = NULL; | 1360 | void *old_sg_dev_arr = NULL; |
1362 | int k, error; | 1361 | int k, error; |
1363 | 1362 | ||
1364 | sdp = kmalloc(sizeof(Sg_device), GFP_KERNEL); | 1363 | sdp = kzalloc(sizeof(Sg_device), GFP_KERNEL); |
1365 | if (!sdp) { | 1364 | if (!sdp) { |
1366 | printk(KERN_WARNING "kmalloc Sg_device failure\n"); | 1365 | printk(KERN_WARNING "kmalloc Sg_device failure\n"); |
1367 | return -ENOMEM; | 1366 | return -ENOMEM; |
@@ -1373,12 +1372,11 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp) | |||
1373 | int tmp_dev_max = sg_nr_dev + SG_DEV_ARR_LUMP; | 1372 | int tmp_dev_max = sg_nr_dev + SG_DEV_ARR_LUMP; |
1374 | write_unlock_irqrestore(&sg_dev_arr_lock, iflags); | 1373 | write_unlock_irqrestore(&sg_dev_arr_lock, iflags); |
1375 | 1374 | ||
1376 | tmp_da = kmalloc(tmp_dev_max * sizeof(Sg_device *), GFP_KERNEL); | 1375 | tmp_da = kzalloc(tmp_dev_max * sizeof(Sg_device *), GFP_KERNEL); |
1377 | if (unlikely(!tmp_da)) | 1376 | if (unlikely(!tmp_da)) |
1378 | goto expand_failed; | 1377 | goto expand_failed; |
1379 | 1378 | ||
1380 | write_lock_irqsave(&sg_dev_arr_lock, iflags); | 1379 | 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 *)); | 1380 | memcpy(tmp_da, sg_dev_arr, sg_dev_max * sizeof(Sg_device *)); |
1383 | old_sg_dev_arr = sg_dev_arr; | 1381 | old_sg_dev_arr = sg_dev_arr; |
1384 | sg_dev_arr = tmp_da; | 1382 | sg_dev_arr = tmp_da; |
@@ -1391,7 +1389,6 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp) | |||
1391 | if (unlikely(k >= SG_MAX_DEVS)) | 1389 | if (unlikely(k >= SG_MAX_DEVS)) |
1392 | goto overflow; | 1390 | goto overflow; |
1393 | 1391 | ||
1394 | memset(sdp, 0, sizeof(*sdp)); | ||
1395 | SCSI_LOG_TIMEOUT(3, printk("sg_alloc: dev=%d \n", k)); | 1392 | SCSI_LOG_TIMEOUT(3, printk("sg_alloc: dev=%d \n", k)); |
1396 | sprintf(disk->disk_name, "sg%d", k); | 1393 | sprintf(disk->disk_name, "sg%d", k); |
1397 | disk->first_minor = k; | 1394 | disk->first_minor = k; |
@@ -1458,14 +1455,10 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf) | |||
1458 | k = error; | 1455 | k = error; |
1459 | sdp = sg_dev_arr[k]; | 1456 | sdp = sg_dev_arr[k]; |
1460 | 1457 | ||
1461 | devfs_mk_cdev(MKDEV(SCSI_GENERIC_MAJOR, k), | ||
1462 | S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, | ||
1463 | "%s/generic", scsidp->devfs_name); | ||
1464 | error = cdev_add(cdev, MKDEV(SCSI_GENERIC_MAJOR, k), 1); | 1458 | error = cdev_add(cdev, MKDEV(SCSI_GENERIC_MAJOR, k), 1); |
1465 | if (error) { | 1459 | if (error) |
1466 | devfs_remove("%s/generic", scsidp->devfs_name); | ||
1467 | goto out; | 1460 | goto out; |
1468 | } | 1461 | |
1469 | sdp->cdev = cdev; | 1462 | sdp->cdev = cdev; |
1470 | if (sg_sysfs_valid) { | 1463 | if (sg_sysfs_valid) { |
1471 | struct class_device * sg_class_member; | 1464 | struct class_device * sg_class_member; |
@@ -1555,7 +1548,6 @@ sg_remove(struct class_device *cl_dev, struct class_interface *cl_intf) | |||
1555 | class_device_destroy(sg_sysfs_class, MKDEV(SCSI_GENERIC_MAJOR, k)); | 1548 | class_device_destroy(sg_sysfs_class, MKDEV(SCSI_GENERIC_MAJOR, k)); |
1556 | cdev_del(sdp->cdev); | 1549 | cdev_del(sdp->cdev); |
1557 | sdp->cdev = NULL; | 1550 | sdp->cdev = NULL; |
1558 | devfs_remove("%s/generic", scsidp->devfs_name); | ||
1559 | put_disk(sdp->disk); | 1551 | put_disk(sdp->disk); |
1560 | sdp->disk = NULL; | 1552 | sdp->disk = NULL; |
1561 | if (NULL == sdp->headfp) | 1553 | if (NULL == sdp->headfp) |
@@ -1577,6 +1569,7 @@ MODULE_AUTHOR("Douglas Gilbert"); | |||
1577 | MODULE_DESCRIPTION("SCSI generic (sg) driver"); | 1569 | MODULE_DESCRIPTION("SCSI generic (sg) driver"); |
1578 | MODULE_LICENSE("GPL"); | 1570 | MODULE_LICENSE("GPL"); |
1579 | MODULE_VERSION(SG_VERSION_STR); | 1571 | MODULE_VERSION(SG_VERSION_STR); |
1572 | MODULE_ALIAS_CHARDEV_MAJOR(SCSI_GENERIC_MAJOR); | ||
1580 | 1573 | ||
1581 | MODULE_PARM_DESC(def_reserved_size, "size of buffer reserved for each fd"); | 1574 | MODULE_PARM_DESC(def_reserved_size, "size of buffer reserved for each fd"); |
1582 | MODULE_PARM_DESC(allow_dio, "allow direct I/O (default: 0 (disallow))"); | 1575 | MODULE_PARM_DESC(allow_dio, "allow direct I/O (default: 0 (disallow))"); |
@@ -2974,4 +2967,3 @@ static int sg_proc_seq_show_debug(struct seq_file *s, void *v) | |||
2974 | 2967 | ||
2975 | module_init(init_sg); | 2968 | module_init(init_sg); |
2976 | module_exit(exit_sg); | 2969 | module_exit(exit_sg); |
2977 | MODULE_ALIAS_CHARDEV_MAJOR(SCSI_GENERIC_MAJOR); | ||