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 0e0ca8fc7318..7405d0df95db 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> |
@@ -1332,7 +1331,7 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp) | |||
1332 | void *old_sg_dev_arr = NULL; | 1331 | void *old_sg_dev_arr = NULL; |
1333 | int k, error; | 1332 | int k, error; |
1334 | 1333 | ||
1335 | sdp = kmalloc(sizeof(Sg_device), GFP_KERNEL); | 1334 | sdp = kzalloc(sizeof(Sg_device), GFP_KERNEL); |
1336 | if (!sdp) { | 1335 | if (!sdp) { |
1337 | printk(KERN_WARNING "kmalloc Sg_device failure\n"); | 1336 | printk(KERN_WARNING "kmalloc Sg_device failure\n"); |
1338 | return -ENOMEM; | 1337 | return -ENOMEM; |
@@ -1344,12 +1343,11 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp) | |||
1344 | int tmp_dev_max = sg_nr_dev + SG_DEV_ARR_LUMP; | 1343 | int tmp_dev_max = sg_nr_dev + SG_DEV_ARR_LUMP; |
1345 | write_unlock_irqrestore(&sg_dev_arr_lock, iflags); | 1344 | write_unlock_irqrestore(&sg_dev_arr_lock, iflags); |
1346 | 1345 | ||
1347 | tmp_da = kmalloc(tmp_dev_max * sizeof(Sg_device *), GFP_KERNEL); | 1346 | tmp_da = kzalloc(tmp_dev_max * sizeof(Sg_device *), GFP_KERNEL); |
1348 | if (unlikely(!tmp_da)) | 1347 | if (unlikely(!tmp_da)) |
1349 | goto expand_failed; | 1348 | goto expand_failed; |
1350 | 1349 | ||
1351 | write_lock_irqsave(&sg_dev_arr_lock, iflags); | 1350 | write_lock_irqsave(&sg_dev_arr_lock, iflags); |
1352 | memset(tmp_da, 0, tmp_dev_max * sizeof(Sg_device *)); | ||
1353 | memcpy(tmp_da, sg_dev_arr, sg_dev_max * sizeof(Sg_device *)); | 1351 | memcpy(tmp_da, sg_dev_arr, sg_dev_max * sizeof(Sg_device *)); |
1354 | old_sg_dev_arr = sg_dev_arr; | 1352 | old_sg_dev_arr = sg_dev_arr; |
1355 | sg_dev_arr = tmp_da; | 1353 | sg_dev_arr = tmp_da; |
@@ -1362,7 +1360,6 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp) | |||
1362 | if (unlikely(k >= SG_MAX_DEVS)) | 1360 | if (unlikely(k >= SG_MAX_DEVS)) |
1363 | goto overflow; | 1361 | goto overflow; |
1364 | 1362 | ||
1365 | memset(sdp, 0, sizeof(*sdp)); | ||
1366 | SCSI_LOG_TIMEOUT(3, printk("sg_alloc: dev=%d \n", k)); | 1363 | SCSI_LOG_TIMEOUT(3, printk("sg_alloc: dev=%d \n", k)); |
1367 | sprintf(disk->disk_name, "sg%d", k); | 1364 | sprintf(disk->disk_name, "sg%d", k); |
1368 | disk->first_minor = k; | 1365 | disk->first_minor = k; |
@@ -1429,14 +1426,10 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf) | |||
1429 | k = error; | 1426 | k = error; |
1430 | sdp = sg_dev_arr[k]; | 1427 | sdp = sg_dev_arr[k]; |
1431 | 1428 | ||
1432 | devfs_mk_cdev(MKDEV(SCSI_GENERIC_MAJOR, k), | ||
1433 | S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, | ||
1434 | "%s/generic", scsidp->devfs_name); | ||
1435 | error = cdev_add(cdev, MKDEV(SCSI_GENERIC_MAJOR, k), 1); | 1429 | error = cdev_add(cdev, MKDEV(SCSI_GENERIC_MAJOR, k), 1); |
1436 | if (error) { | 1430 | if (error) |
1437 | devfs_remove("%s/generic", scsidp->devfs_name); | ||
1438 | goto out; | 1431 | goto out; |
1439 | } | 1432 | |
1440 | sdp->cdev = cdev; | 1433 | sdp->cdev = cdev; |
1441 | if (sg_sysfs_valid) { | 1434 | if (sg_sysfs_valid) { |
1442 | struct class_device * sg_class_member; | 1435 | struct class_device * sg_class_member; |
@@ -1526,7 +1519,6 @@ sg_remove(struct class_device *cl_dev, struct class_interface *cl_intf) | |||
1526 | class_device_destroy(sg_sysfs_class, MKDEV(SCSI_GENERIC_MAJOR, k)); | 1519 | class_device_destroy(sg_sysfs_class, MKDEV(SCSI_GENERIC_MAJOR, k)); |
1527 | cdev_del(sdp->cdev); | 1520 | cdev_del(sdp->cdev); |
1528 | sdp->cdev = NULL; | 1521 | sdp->cdev = NULL; |
1529 | devfs_remove("%s/generic", scsidp->devfs_name); | ||
1530 | put_disk(sdp->disk); | 1522 | put_disk(sdp->disk); |
1531 | sdp->disk = NULL; | 1523 | sdp->disk = NULL; |
1532 | if (NULL == sdp->headfp) | 1524 | if (NULL == sdp->headfp) |
@@ -1548,6 +1540,7 @@ MODULE_AUTHOR("Douglas Gilbert"); | |||
1548 | MODULE_DESCRIPTION("SCSI generic (sg) driver"); | 1540 | MODULE_DESCRIPTION("SCSI generic (sg) driver"); |
1549 | MODULE_LICENSE("GPL"); | 1541 | MODULE_LICENSE("GPL"); |
1550 | MODULE_VERSION(SG_VERSION_STR); | 1542 | MODULE_VERSION(SG_VERSION_STR); |
1543 | MODULE_ALIAS_CHARDEV_MAJOR(SCSI_GENERIC_MAJOR); | ||
1551 | 1544 | ||
1552 | MODULE_PARM_DESC(def_reserved_size, "size of buffer reserved for each fd"); | 1545 | MODULE_PARM_DESC(def_reserved_size, "size of buffer reserved for each fd"); |
1553 | MODULE_PARM_DESC(allow_dio, "allow direct I/O (default: 0 (disallow))"); | 1546 | MODULE_PARM_DESC(allow_dio, "allow direct I/O (default: 0 (disallow))"); |
@@ -2943,4 +2936,3 @@ static int sg_proc_seq_show_debug(struct seq_file *s, void *v) | |||
2943 | 2936 | ||
2944 | module_init(init_sg); | 2937 | module_init(init_sg); |
2945 | module_exit(exit_sg); | 2938 | module_exit(exit_sg); |
2946 | MODULE_ALIAS_CHARDEV_MAJOR(SCSI_GENERIC_MAJOR); | ||