@@ -116,7 +116,6 @@ static void scsi_disk_release(struct device *cdev);
116
116
static void sd_print_sense_hdr (struct scsi_disk * , struct scsi_sense_hdr * );
117
117
static void sd_print_result (struct scsi_disk * , int );
118
118
119
- static DEFINE_SPINLOCK (sd_index_lock );
120
119
static DEFINE_IDA (sd_index_ida );
121
120
122
121
/* This semaphore is used to mediate the 0->1 reference get in the
@@ -2943,16 +2942,9 @@ static int sd_probe(struct device *dev)
2943
2942
if (!gd )
2944
2943
goto out_free ;
2945
2944
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 ;
2956
2948
sdev_printk (KERN_WARNING , sdp , "sd_probe: memory exhausted.\n" );
2957
2949
goto out_put ;
2958
2950
}
@@ -2995,9 +2987,7 @@ static int sd_probe(struct device *dev)
2995
2987
return 0 ;
2996
2988
2997
2989
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 );
3001
2991
out_put :
3002
2992
put_disk (gd );
3003
2993
out_free :
@@ -3059,9 +3049,7 @@ static void scsi_disk_release(struct device *dev)
3059
3049
struct scsi_disk * sdkp = to_scsi_disk (dev );
3060
3050
struct gendisk * disk = sdkp -> disk ;
3061
3051
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 );
3065
3053
3066
3054
disk -> private_data = NULL ;
3067
3055
put_disk (disk );
0 commit comments