Commit 94015080 authored by Matthew Wilcox's avatar Matthew Wilcox

sd: Convert to new IDA API

Allows us to remove an explicit spinlock.
Signed-off-by: default avatarMatthew Wilcox <willy@infradead.org>
parent 0f0a0e54
...@@ -123,7 +123,6 @@ static void scsi_disk_release(struct device *cdev); ...@@ -123,7 +123,6 @@ static void scsi_disk_release(struct device *cdev);
static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *); static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);
static void sd_print_result(const struct scsi_disk *, const char *, int); static void sd_print_result(const struct scsi_disk *, const char *, int);
static DEFINE_SPINLOCK(sd_index_lock);
static DEFINE_IDA(sd_index_ida); static DEFINE_IDA(sd_index_ida);
/* This semaphore is used to mediate the 0->1 reference get in the /* This semaphore is used to mediate the 0->1 reference get in the
...@@ -3339,16 +3338,8 @@ static int sd_probe(struct device *dev) ...@@ -3339,16 +3338,8 @@ static int sd_probe(struct device *dev)
if (!gd) if (!gd)
goto out_free; goto out_free;
do { index = ida_alloc(&sd_index_ida, GFP_KERNEL);
if (!ida_pre_get(&sd_index_ida, GFP_KERNEL)) if (index < 0) {
goto out_put;
spin_lock(&sd_index_lock);
error = ida_get_new(&sd_index_ida, &index);
spin_unlock(&sd_index_lock);
} while (error == -EAGAIN);
if (error) {
sdev_printk(KERN_WARNING, sdp, "sd_probe: memory exhausted.\n"); sdev_printk(KERN_WARNING, sdp, "sd_probe: memory exhausted.\n");
goto out_put; goto out_put;
} }
...@@ -3392,9 +3383,7 @@ static int sd_probe(struct device *dev) ...@@ -3392,9 +3383,7 @@ static int sd_probe(struct device *dev)
return 0; return 0;
out_free_index: out_free_index:
spin_lock(&sd_index_lock); ida_free(&sd_index_ida, index);
ida_remove(&sd_index_ida, index);
spin_unlock(&sd_index_lock);
out_put: out_put:
put_disk(gd); put_disk(gd);
out_free: out_free:
...@@ -3459,9 +3448,7 @@ static void scsi_disk_release(struct device *dev) ...@@ -3459,9 +3448,7 @@ static void scsi_disk_release(struct device *dev)
struct scsi_disk *sdkp = to_scsi_disk(dev); struct scsi_disk *sdkp = to_scsi_disk(dev);
struct gendisk *disk = sdkp->disk; struct gendisk *disk = sdkp->disk;
spin_lock(&sd_index_lock); ida_free(&sd_index_ida, sdkp->index);
ida_remove(&sd_index_ida, sdkp->index);
spin_unlock(&sd_index_lock);
disk->private_data = NULL; disk->private_data = NULL;
put_disk(disk); put_disk(disk);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment