summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sg.c
diff options
context:
space:
mode:
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 5a0a19322d0..a8b05ce5de5 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 */
#include <linux/poll.h>
#include <linux/smp_lock.h>
#include <linux/moduleparam.h>
-#include <linux/devfs_fs_kernel.h>
#include <linux/cdev.h>
#include <linux/seq_file.h>
#include <linux/blkdev.h>
@@ -1361,7 +1360,7 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
void *old_sg_dev_arr = NULL;
int k, error;
- sdp = kmalloc(sizeof(Sg_device), GFP_KERNEL);
+ sdp = kzalloc(sizeof(Sg_device), GFP_KERNEL);
if (!sdp) {
printk(KERN_WARNING "kmalloc Sg_device failure\n");
return -ENOMEM;
@@ -1373,12 +1372,11 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
int tmp_dev_max = sg_nr_dev + SG_DEV_ARR_LUMP;
write_unlock_irqrestore(&sg_dev_arr_lock, iflags);
- tmp_da = kmalloc(tmp_dev_max * sizeof(Sg_device *), GFP_KERNEL);
+ tmp_da = kzalloc(tmp_dev_max * sizeof(Sg_device *), GFP_KERNEL);
if (unlikely(!tmp_da))
goto expand_failed;
write_lock_irqsave(&sg_dev_arr_lock, iflags);
- memset(tmp_da, 0, tmp_dev_max * sizeof(Sg_device *));
memcpy(tmp_da, sg_dev_arr, sg_dev_max * sizeof(Sg_device *));
old_sg_dev_arr = sg_dev_arr;
sg_dev_arr = tmp_da;
@@ -1391,7 +1389,6 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
if (unlikely(k >= SG_MAX_DEVS))
goto overflow;
- memset(sdp, 0, sizeof(*sdp));
SCSI_LOG_TIMEOUT(3, printk("sg_alloc: dev=%d \n", k));
sprintf(disk->disk_name, "sg%d", k);
disk->first_minor = k;
@@ -1458,14 +1455,10 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf)
k = error;
sdp = sg_dev_arr[k];
- devfs_mk_cdev(MKDEV(SCSI_GENERIC_MAJOR, k),
- S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP,
- "%s/generic", scsidp->devfs_name);
error = cdev_add(cdev, MKDEV(SCSI_GENERIC_MAJOR, k), 1);
- if (error) {
- devfs_remove("%s/generic", scsidp->devfs_name);
+ if (error)
goto out;
- }
+
sdp->cdev = cdev;
if (sg_sysfs_valid) {
struct class_device * sg_class_member;
@@ -1555,7 +1548,6 @@ sg_remove(struct class_device *cl_dev, struct class_interface *cl_intf)
class_device_destroy(sg_sysfs_class, MKDEV(SCSI_GENERIC_MAJOR, k));
cdev_del(sdp->cdev);
sdp->cdev = NULL;
- devfs_remove("%s/generic", scsidp->devfs_name);
put_disk(sdp->disk);
sdp->disk = NULL;
if (NULL == sdp->headfp)
@@ -1577,6 +1569,7 @@ MODULE_AUTHOR("Douglas Gilbert");
MODULE_DESCRIPTION("SCSI generic (sg) driver");
MODULE_LICENSE("GPL");
MODULE_VERSION(SG_VERSION_STR);
+MODULE_ALIAS_CHARDEV_MAJOR(SCSI_GENERIC_MAJOR);
MODULE_PARM_DESC(def_reserved_size, "size of buffer reserved for each fd");
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)
module_init(init_sg);
module_exit(exit_sg);
-MODULE_ALIAS_CHARDEV_MAJOR(SCSI_GENERIC_MAJOR);