scsi: convert to idr_alloc()
Convert to the much saner new idr interface. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
70a9755d5f
commit
b98c52b572
@@ -4076,7 +4076,7 @@ static int st_probe(struct device *dev)
|
||||
struct st_modedef *STm;
|
||||
struct st_partstat *STps;
|
||||
struct st_buffer *buffer;
|
||||
int i, dev_num, error;
|
||||
int i, error;
|
||||
char *stp;
|
||||
|
||||
if (SDp->type != TYPE_TAPE)
|
||||
@@ -4178,27 +4178,17 @@ static int st_probe(struct device *dev)
|
||||
tpnt->blksize_changed = 0;
|
||||
mutex_init(&tpnt->lock);
|
||||
|
||||
if (!idr_pre_get(&st_index_idr, GFP_KERNEL)) {
|
||||
pr_warn("st: idr expansion failed\n");
|
||||
error = -ENOMEM;
|
||||
goto out_put_disk;
|
||||
}
|
||||
|
||||
idr_preload(GFP_KERNEL);
|
||||
spin_lock(&st_index_lock);
|
||||
error = idr_get_new(&st_index_idr, tpnt, &dev_num);
|
||||
error = idr_alloc(&st_index_idr, tpnt, 0, ST_MAX_TAPES + 1, GFP_NOWAIT);
|
||||
spin_unlock(&st_index_lock);
|
||||
if (error) {
|
||||
idr_preload_end();
|
||||
if (error < 0) {
|
||||
pr_warn("st: idr allocation failed: %d\n", error);
|
||||
goto out_put_disk;
|
||||
}
|
||||
|
||||
if (dev_num > ST_MAX_TAPES) {
|
||||
pr_err("st: Too many tape devices (max. %d).\n", ST_MAX_TAPES);
|
||||
goto out_put_index;
|
||||
}
|
||||
|
||||
tpnt->index = dev_num;
|
||||
sprintf(disk->disk_name, "st%d", dev_num);
|
||||
tpnt->index = error;
|
||||
sprintf(disk->disk_name, "st%d", tpnt->index);
|
||||
|
||||
dev_set_drvdata(dev, tpnt);
|
||||
|
||||
@@ -4218,9 +4208,8 @@ static int st_probe(struct device *dev)
|
||||
|
||||
out_remove_devs:
|
||||
remove_cdevs(tpnt);
|
||||
out_put_index:
|
||||
spin_lock(&st_index_lock);
|
||||
idr_remove(&st_index_idr, dev_num);
|
||||
idr_remove(&st_index_idr, tpnt->index);
|
||||
spin_unlock(&st_index_lock);
|
||||
out_put_disk:
|
||||
put_disk(disk);
|
||||
|
Reference in New Issue
Block a user