diff options
Diffstat (limited to 'drivers/scsi/st.c')
| -rw-r--r-- | drivers/scsi/st.c | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 7f96f33c1bb1..d40e7c871c36 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
| @@ -35,7 +35,6 @@ static const char *verstr = "20050830"; | |||
| 35 | #include <linux/spinlock.h> | 35 | #include <linux/spinlock.h> |
| 36 | #include <linux/blkdev.h> | 36 | #include <linux/blkdev.h> |
| 37 | #include <linux/moduleparam.h> | 37 | #include <linux/moduleparam.h> |
| 38 | #include <linux/devfs_fs_kernel.h> | ||
| 39 | #include <linux/cdev.h> | 38 | #include <linux/cdev.h> |
| 40 | #include <linux/delay.h> | 39 | #include <linux/delay.h> |
| 41 | #include <linux/mutex.h> | 40 | #include <linux/mutex.h> |
| @@ -87,8 +86,9 @@ static int st_nr_dev; | |||
| 87 | static struct class *st_sysfs_class; | 86 | static struct class *st_sysfs_class; |
| 88 | 87 | ||
| 89 | MODULE_AUTHOR("Kai Makisara"); | 88 | MODULE_AUTHOR("Kai Makisara"); |
| 90 | MODULE_DESCRIPTION("SCSI Tape Driver"); | 89 | MODULE_DESCRIPTION("SCSI tape (st) driver"); |
| 91 | MODULE_LICENSE("GPL"); | 90 | MODULE_LICENSE("GPL"); |
| 91 | MODULE_ALIAS_CHARDEV_MAJOR(SCSI_TAPE_MAJOR); | ||
| 92 | 92 | ||
| 93 | /* Set 'perm' (4th argument) to 0 to disable module_param's definition | 93 | /* Set 'perm' (4th argument) to 0 to disable module_param's definition |
| 94 | * of sysfs parameters (which module_param doesn't yet support). | 94 | * of sysfs parameters (which module_param doesn't yet support). |
| @@ -3590,12 +3590,11 @@ static struct st_buffer * | |||
| 3590 | 3590 | ||
| 3591 | i = sizeof(struct st_buffer) + (max_sg - 1) * sizeof(struct scatterlist) + | 3591 | i = sizeof(struct st_buffer) + (max_sg - 1) * sizeof(struct scatterlist) + |
| 3592 | max_sg * sizeof(struct st_buf_fragment); | 3592 | max_sg * sizeof(struct st_buf_fragment); |
| 3593 | tb = kmalloc(i, priority); | 3593 | tb = kzalloc(i, priority); |
| 3594 | if (!tb) { | 3594 | if (!tb) { |
| 3595 | printk(KERN_NOTICE "st: Can't allocate new tape buffer.\n"); | 3595 | printk(KERN_NOTICE "st: Can't allocate new tape buffer.\n"); |
| 3596 | return NULL; | 3596 | return NULL; |
| 3597 | } | 3597 | } |
| 3598 | memset(tb, 0, i); | ||
| 3599 | tb->frp_segs = tb->orig_frp_segs = 0; | 3598 | tb->frp_segs = tb->orig_frp_segs = 0; |
| 3600 | tb->use_sg = max_sg; | 3599 | tb->use_sg = max_sg; |
| 3601 | tb->frp = (struct st_buf_fragment *)(&(tb->sg[0]) + max_sg); | 3600 | tb->frp = (struct st_buf_fragment *)(&(tb->sg[0]) + max_sg); |
| @@ -3924,14 +3923,13 @@ static int st_probe(struct device *dev) | |||
| 3924 | goto out_put_disk; | 3923 | goto out_put_disk; |
| 3925 | } | 3924 | } |
| 3926 | 3925 | ||
| 3927 | tmp_da = kmalloc(tmp_dev_max * sizeof(struct scsi_tape *), GFP_ATOMIC); | 3926 | tmp_da = kzalloc(tmp_dev_max * sizeof(struct scsi_tape *), GFP_ATOMIC); |
| 3928 | if (tmp_da == NULL) { | 3927 | if (tmp_da == NULL) { |
| 3929 | write_unlock(&st_dev_arr_lock); | 3928 | write_unlock(&st_dev_arr_lock); |
| 3930 | printk(KERN_ERR "st: Can't extend device array.\n"); | 3929 | printk(KERN_ERR "st: Can't extend device array.\n"); |
| 3931 | goto out_put_disk; | 3930 | goto out_put_disk; |
| 3932 | } | 3931 | } |
| 3933 | 3932 | ||
| 3934 | memset(tmp_da, 0, tmp_dev_max * sizeof(struct scsi_tape *)); | ||
| 3935 | if (scsi_tapes != NULL) { | 3933 | if (scsi_tapes != NULL) { |
| 3936 | memcpy(tmp_da, scsi_tapes, | 3934 | memcpy(tmp_da, scsi_tapes, |
| 3937 | st_dev_max * sizeof(struct scsi_tape *)); | 3935 | st_dev_max * sizeof(struct scsi_tape *)); |
| @@ -3948,13 +3946,12 @@ static int st_probe(struct device *dev) | |||
| 3948 | if (i >= st_dev_max) | 3946 | if (i >= st_dev_max) |
| 3949 | panic("scsi_devices corrupt (st)"); | 3947 | panic("scsi_devices corrupt (st)"); |
| 3950 | 3948 | ||
| 3951 | tpnt = kmalloc(sizeof(struct scsi_tape), GFP_ATOMIC); | 3949 | tpnt = kzalloc(sizeof(struct scsi_tape), GFP_ATOMIC); |
| 3952 | if (tpnt == NULL) { | 3950 | if (tpnt == NULL) { |
| 3953 | write_unlock(&st_dev_arr_lock); | 3951 | write_unlock(&st_dev_arr_lock); |
| 3954 | printk(KERN_ERR "st: Can't allocate device descriptor.\n"); | 3952 | printk(KERN_ERR "st: Can't allocate device descriptor.\n"); |
| 3955 | goto out_put_disk; | 3953 | goto out_put_disk; |
| 3956 | } | 3954 | } |
| 3957 | memset(tpnt, 0, sizeof(struct scsi_tape)); | ||
| 3958 | kref_init(&tpnt->kref); | 3955 | kref_init(&tpnt->kref); |
| 3959 | tpnt->disk = disk; | 3956 | tpnt->disk = disk; |
| 3960 | sprintf(disk->disk_name, "st%d", i); | 3957 | sprintf(disk->disk_name, "st%d", i); |
| @@ -4056,21 +4053,6 @@ static int st_probe(struct device *dev) | |||
| 4056 | do_create_class_files(tpnt, dev_num, mode); | 4053 | do_create_class_files(tpnt, dev_num, mode); |
| 4057 | } | 4054 | } |
| 4058 | 4055 | ||
| 4059 | for (mode = 0; mode < ST_NBR_MODES; ++mode) { | ||
| 4060 | /* Make sure that the minor numbers corresponding to the four | ||
| 4061 | first modes always get the same names */ | ||
| 4062 | i = mode << (4 - ST_NBR_MODE_BITS); | ||
| 4063 | /* Rewind entry */ | ||
| 4064 | devfs_mk_cdev(MKDEV(SCSI_TAPE_MAJOR, TAPE_MINOR(dev_num, mode, 0)), | ||
| 4065 | S_IFCHR | S_IRUGO | S_IWUGO, | ||
| 4066 | "%s/mt%s", SDp->devfs_name, st_formats[i]); | ||
| 4067 | /* No-rewind entry */ | ||
| 4068 | devfs_mk_cdev(MKDEV(SCSI_TAPE_MAJOR, TAPE_MINOR(dev_num, mode, 1)), | ||
| 4069 | S_IFCHR | S_IRUGO | S_IWUGO, | ||
| 4070 | "%s/mt%sn", SDp->devfs_name, st_formats[i]); | ||
| 4071 | } | ||
| 4072 | disk->number = devfs_register_tape(SDp->devfs_name); | ||
| 4073 | |||
| 4074 | sdev_printk(KERN_WARNING, SDp, | 4056 | sdev_printk(KERN_WARNING, SDp, |
| 4075 | "Attached scsi tape %s", tape_name(tpnt)); | 4057 | "Attached scsi tape %s", tape_name(tpnt)); |
| 4076 | printk(KERN_WARNING "%s: try direct i/o: %s (alignment %d B)\n", | 4058 | printk(KERN_WARNING "%s: try direct i/o: %s (alignment %d B)\n", |
| @@ -4124,13 +4106,9 @@ static int st_remove(struct device *dev) | |||
| 4124 | scsi_tapes[i] = NULL; | 4106 | scsi_tapes[i] = NULL; |
| 4125 | st_nr_dev--; | 4107 | st_nr_dev--; |
| 4126 | write_unlock(&st_dev_arr_lock); | 4108 | write_unlock(&st_dev_arr_lock); |
| 4127 | devfs_unregister_tape(tpnt->disk->number); | ||
| 4128 | sysfs_remove_link(&tpnt->device->sdev_gendev.kobj, | 4109 | sysfs_remove_link(&tpnt->device->sdev_gendev.kobj, |
| 4129 | "tape"); | 4110 | "tape"); |
| 4130 | for (mode = 0; mode < ST_NBR_MODES; ++mode) { | 4111 | for (mode = 0; mode < ST_NBR_MODES; ++mode) { |
| 4131 | j = mode << (4 - ST_NBR_MODE_BITS); | ||
| 4132 | devfs_remove("%s/mt%s", SDp->devfs_name, st_formats[j]); | ||
| 4133 | devfs_remove("%s/mt%sn", SDp->devfs_name, st_formats[j]); | ||
| 4134 | for (j=0; j < 2; j++) { | 4112 | for (j=0; j < 2; j++) { |
| 4135 | class_device_destroy(st_sysfs_class, | 4113 | class_device_destroy(st_sysfs_class, |
| 4136 | MKDEV(SCSI_TAPE_MAJOR, | 4114 | MKDEV(SCSI_TAPE_MAJOR, |
