aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/st.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/st.c')
-rw-r--r--drivers/scsi/st.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 3e2b3717cb5c..86974471af68 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4076,7 +4076,7 @@ static int st_probe(struct device *dev)
4076 struct st_modedef *STm; 4076 struct st_modedef *STm;
4077 struct st_partstat *STps; 4077 struct st_partstat *STps;
4078 struct st_buffer *buffer; 4078 struct st_buffer *buffer;
4079 int i, dev_num, error; 4079 int i, error;
4080 char *stp; 4080 char *stp;
4081 4081
4082 if (SDp->type != TYPE_TAPE) 4082 if (SDp->type != TYPE_TAPE)
@@ -4178,27 +4178,17 @@ static int st_probe(struct device *dev)
4178 tpnt->blksize_changed = 0; 4178 tpnt->blksize_changed = 0;
4179 mutex_init(&tpnt->lock); 4179 mutex_init(&tpnt->lock);
4180 4180
4181 if (!idr_pre_get(&st_index_idr, GFP_KERNEL)) { 4181 idr_preload(GFP_KERNEL);
4182 pr_warn("st: idr expansion failed\n");
4183 error = -ENOMEM;
4184 goto out_put_disk;
4185 }
4186
4187 spin_lock(&st_index_lock); 4182 spin_lock(&st_index_lock);
4188 error = idr_get_new(&st_index_idr, tpnt, &dev_num); 4183 error = idr_alloc(&st_index_idr, tpnt, 0, ST_MAX_TAPES + 1, GFP_NOWAIT);
4189 spin_unlock(&st_index_lock); 4184 spin_unlock(&st_index_lock);
4190 if (error) { 4185 idr_preload_end();
4186 if (error < 0) {
4191 pr_warn("st: idr allocation failed: %d\n", error); 4187 pr_warn("st: idr allocation failed: %d\n", error);
4192 goto out_put_disk; 4188 goto out_put_disk;
4193 } 4189 }
4194 4190 tpnt->index = error;
4195 if (dev_num > ST_MAX_TAPES) { 4191 sprintf(disk->disk_name, "st%d", tpnt->index);
4196 pr_err("st: Too many tape devices (max. %d).\n", ST_MAX_TAPES);
4197 goto out_put_index;
4198 }
4199
4200 tpnt->index = dev_num;
4201 sprintf(disk->disk_name, "st%d", dev_num);
4202 4192
4203 dev_set_drvdata(dev, tpnt); 4193 dev_set_drvdata(dev, tpnt);
4204 4194
@@ -4218,9 +4208,8 @@ static int st_probe(struct device *dev)
4218 4208
4219out_remove_devs: 4209out_remove_devs:
4220 remove_cdevs(tpnt); 4210 remove_cdevs(tpnt);
4221out_put_index:
4222 spin_lock(&st_index_lock); 4211 spin_lock(&st_index_lock);
4223 idr_remove(&st_index_idr, dev_num); 4212 idr_remove(&st_index_idr, tpnt->index);
4224 spin_unlock(&st_index_lock); 4213 spin_unlock(&st_index_lock);
4225out_put_disk: 4214out_put_disk:
4226 put_disk(disk); 4215 put_disk(disk);