Skip to content

Commit cdf4e29

Browse files
author
Lai Jiangshan
committed
scsi/sd: use ida_simple_get()
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
1 parent a1660bc commit cdf4e29

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

drivers/scsi/sd.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ static void scsi_disk_release(struct device *cdev);
116116
static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);
117117
static void sd_print_result(struct scsi_disk *, int);
118118

119-
static DEFINE_SPINLOCK(sd_index_lock);
120119
static DEFINE_IDA(sd_index_ida);
121120

122121
/* This semaphore is used to mediate the 0->1 reference get in the
@@ -2943,16 +2942,9 @@ static int sd_probe(struct device *dev)
29432942
if (!gd)
29442943
goto out_free;
29452944

2946-
do {
2947-
if (!ida_pre_get(&sd_index_ida, GFP_KERNEL))
2948-
goto out_put;
2949-
2950-
spin_lock(&sd_index_lock);
2951-
error = ida_get_new(&sd_index_ida, &index);
2952-
spin_unlock(&sd_index_lock);
2953-
} while (error == -EAGAIN);
2954-
2955-
if (error) {
2945+
index = ida_simple_get(&sd_index_ida, 0, 0, GFP_KERNEL);
2946+
if (index < 0) {
2947+
error = index;
29562948
sdev_printk(KERN_WARNING, sdp, "sd_probe: memory exhausted.\n");
29572949
goto out_put;
29582950
}
@@ -2995,9 +2987,7 @@ static int sd_probe(struct device *dev)
29952987
return 0;
29962988

29972989
out_free_index:
2998-
spin_lock(&sd_index_lock);
2999-
ida_remove(&sd_index_ida, index);
3000-
spin_unlock(&sd_index_lock);
2990+
ida_simple_remove(&sd_index_ida, index);
30012991
out_put:
30022992
put_disk(gd);
30032993
out_free:
@@ -3059,9 +3049,7 @@ static void scsi_disk_release(struct device *dev)
30593049
struct scsi_disk *sdkp = to_scsi_disk(dev);
30603050
struct gendisk *disk = sdkp->disk;
30613051

3062-
spin_lock(&sd_index_lock);
3063-
ida_remove(&sd_index_ida, sdkp->index);
3064-
spin_unlock(&sd_index_lock);
3052+
ida_simple_remove(&sd_index_ida, sdkp->index);
30653053

30663054
disk->private_data = NULL;
30673055
put_disk(disk);

0 commit comments

Comments
 (0)