aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sg.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-03-22 13:47:24 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-22 13:47:24 -0500
commit2152f8536668a957ea3214735b4761e7b22ef7d8 (patch)
tree56723fc51445b1bc930c6400d4c00fd6fc831f88 /drivers/scsi/sg.c
parent7cae7e26f245151b9ccad868bf2edf8c8048d307 (diff)
parent30afc84cf7325e88fb9746340eba3c161080ff49 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (138 commits) [SCSI] libata: implement minimal transport template for ->eh_timed_out [SCSI] eliminate rphy allocation in favour of expander/end device allocation [SCSI] convert mptsas over to end_device/expander allocations [SCSI] allow displaying and setting of cache type via sysfs [SCSI] add scsi_mode_select to scsi_lib.c [SCSI] 3ware 9000 add big endian support [SCSI] qla2xxx: update MAINTAINERS [SCSI] scsi: move target_destroy call [SCSI] fusion - bump version [SCSI] fusion - expander hotplug suport in mptsas module [SCSI] fusion - exposing raid components in mptsas [SCSI] fusion - memory leak, and initializing fields [SCSI] fusion - exclosure misspelled [SCSI] fusion - cleanup mptsas event handling functions [SCSI] fusion - removing target_id/bus_id from the VirtDevice structure [SCSI] fusion - static fix's [SCSI] fusion - move some debug firmware event debug msgs to verbose level [SCSI] fusion - loginfo header update [SCSI] add scsi_reprobe_device [SCSI] megaraid_sas: fix extended timeout handling ...
Diffstat (limited to 'drivers/scsi/sg.c')
-rw-r--r--drivers/scsi/sg.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 0e0ca8fc731..7405d0df95d 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");
1548MODULE_DESCRIPTION("SCSI generic (sg) driver"); 1540MODULE_DESCRIPTION("SCSI generic (sg) driver");
1549MODULE_LICENSE("GPL"); 1541MODULE_LICENSE("GPL");
1550MODULE_VERSION(SG_VERSION_STR); 1542MODULE_VERSION(SG_VERSION_STR);
1543MODULE_ALIAS_CHARDEV_MAJOR(SCSI_GENERIC_MAJOR);
1551 1544
1552MODULE_PARM_DESC(def_reserved_size, "size of buffer reserved for each fd"); 1545MODULE_PARM_DESC(def_reserved_size, "size of buffer reserved for each fd");
1553MODULE_PARM_DESC(allow_dio, "allow direct I/O (default: 0 (disallow))"); 1546MODULE_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
2944module_init(init_sg); 2937module_init(init_sg);
2945module_exit(exit_sg); 2938module_exit(exit_sg);
2946MODULE_ALIAS_CHARDEV_MAJOR(SCSI_GENERIC_MAJOR);