aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wilcox <willy@infradead.org>2018-06-11 15:26:27 -0400
committerMatthew Wilcox <willy@infradead.org>2018-08-21 23:54:17 -0400
commit9401508012e2044ce841a57bc453c5746b671851 (patch)
tree6a7f5868d6245906fcc95999d1dd03f88c276bf9
parent0f0a0e54a2a15174535349db3a22355a6b1cf5fa (diff)
sd: Convert to new IDA API
Allows us to remove an explicit spinlock. Signed-off-by: Matthew Wilcox <willy@infradead.org>
-rw-r--r--drivers/scsi/sd.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 9421d9877730..8a493e64856c 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -123,7 +123,6 @@ static void scsi_disk_release(struct device *cdev);
123static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *); 123static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);
124static void sd_print_result(const struct scsi_disk *, const char *, int); 124static void sd_print_result(const struct scsi_disk *, const char *, int);
125 125
126static DEFINE_SPINLOCK(sd_index_lock);
127static DEFINE_IDA(sd_index_ida); 126static DEFINE_IDA(sd_index_ida);
128 127
129/* This semaphore is used to mediate the 0->1 reference get in the 128/* 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 if (!gd) 3338 if (!gd)
3340 goto out_free; 3339 goto out_free;
3341 3340
3342 do { 3341 index = ida_alloc(&sd_index_ida, GFP_KERNEL);
3343 if (!ida_pre_get(&sd_index_ida, GFP_KERNEL)) 3342 if (index < 0) {
3344 goto out_put;
3345
3346 spin_lock(&sd_index_lock);
3347 error = ida_get_new(&sd_index_ida, &index);
3348 spin_unlock(&sd_index_lock);
3349 } while (error == -EAGAIN);
3350
3351 if (error) {
3352 sdev_printk(KERN_WARNING, sdp, "sd_probe: memory exhausted.\n"); 3343 sdev_printk(KERN_WARNING, sdp, "sd_probe: memory exhausted.\n");
3353 goto out_put; 3344 goto out_put;
3354 } 3345 }
@@ -3392,9 +3383,7 @@ static int sd_probe(struct device *dev)
3392 return 0; 3383 return 0;
3393 3384
3394 out_free_index: 3385 out_free_index:
3395 spin_lock(&sd_index_lock); 3386 ida_free(&sd_index_ida, index);
3396 ida_remove(&sd_index_ida, index);
3397 spin_unlock(&sd_index_lock);
3398 out_put: 3387 out_put:
3399 put_disk(gd); 3388 put_disk(gd);
3400 out_free: 3389 out_free:
@@ -3459,9 +3448,7 @@ static void scsi_disk_release(struct device *dev)
3459 struct scsi_disk *sdkp = to_scsi_disk(dev); 3448 struct scsi_disk *sdkp = to_scsi_disk(dev);
3460 struct gendisk *disk = sdkp->disk; 3449 struct gendisk *disk = sdkp->disk;
3461 3450
3462 spin_lock(&sd_index_lock); 3451 ida_free(&sd_index_ida, sdkp->index);
3463 ida_remove(&sd_index_ida, sdkp->index);
3464 spin_unlock(&sd_index_lock);
3465 3452
3466 disk->private_data = NULL; 3453 disk->private_data = NULL;
3467 put_disk(disk); 3454 put_disk(disk);