diff options
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r-- | drivers/scsi/sd.c | 41 |
1 files changed, 8 insertions, 33 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index c7839f6c35cc..d277e8620e3e 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -3075,23 +3075,6 @@ static void sd_probe_async(void *data, async_cookie_t cookie) | |||
3075 | put_device(&sdkp->dev); | 3075 | put_device(&sdkp->dev); |
3076 | } | 3076 | } |
3077 | 3077 | ||
3078 | struct sd_devt { | ||
3079 | int idx; | ||
3080 | struct disk_devt disk_devt; | ||
3081 | }; | ||
3082 | |||
3083 | static void sd_devt_release(struct disk_devt *disk_devt) | ||
3084 | { | ||
3085 | struct sd_devt *sd_devt = container_of(disk_devt, struct sd_devt, | ||
3086 | disk_devt); | ||
3087 | |||
3088 | spin_lock(&sd_index_lock); | ||
3089 | ida_remove(&sd_index_ida, sd_devt->idx); | ||
3090 | spin_unlock(&sd_index_lock); | ||
3091 | |||
3092 | kfree(sd_devt); | ||
3093 | } | ||
3094 | |||
3095 | /** | 3078 | /** |
3096 | * sd_probe - called during driver initialization and whenever a | 3079 | * sd_probe - called during driver initialization and whenever a |
3097 | * new scsi device is attached to the system. It is called once | 3080 | * new scsi device is attached to the system. It is called once |
@@ -3113,7 +3096,6 @@ static void sd_devt_release(struct disk_devt *disk_devt) | |||
3113 | static int sd_probe(struct device *dev) | 3096 | static int sd_probe(struct device *dev) |
3114 | { | 3097 | { |
3115 | struct scsi_device *sdp = to_scsi_device(dev); | 3098 | struct scsi_device *sdp = to_scsi_device(dev); |
3116 | struct sd_devt *sd_devt; | ||
3117 | struct scsi_disk *sdkp; | 3099 | struct scsi_disk *sdkp; |
3118 | struct gendisk *gd; | 3100 | struct gendisk *gd; |
3119 | int index; | 3101 | int index; |
@@ -3139,13 +3121,9 @@ static int sd_probe(struct device *dev) | |||
3139 | if (!sdkp) | 3121 | if (!sdkp) |
3140 | goto out; | 3122 | goto out; |
3141 | 3123 | ||
3142 | sd_devt = kzalloc(sizeof(*sd_devt), GFP_KERNEL); | ||
3143 | if (!sd_devt) | ||
3144 | goto out_free; | ||
3145 | |||
3146 | gd = alloc_disk(SD_MINORS); | 3124 | gd = alloc_disk(SD_MINORS); |
3147 | if (!gd) | 3125 | if (!gd) |
3148 | goto out_free_devt; | 3126 | goto out_free; |
3149 | 3127 | ||
3150 | do { | 3128 | do { |
3151 | if (!ida_pre_get(&sd_index_ida, GFP_KERNEL)) | 3129 | if (!ida_pre_get(&sd_index_ida, GFP_KERNEL)) |
@@ -3161,11 +3139,6 @@ static int sd_probe(struct device *dev) | |||
3161 | goto out_put; | 3139 | goto out_put; |
3162 | } | 3140 | } |
3163 | 3141 | ||
3164 | atomic_set(&sd_devt->disk_devt.count, 1); | ||
3165 | sd_devt->disk_devt.release = sd_devt_release; | ||
3166 | sd_devt->idx = index; | ||
3167 | gd->disk_devt = &sd_devt->disk_devt; | ||
3168 | |||
3169 | error = sd_format_disk_name("sd", index, gd->disk_name, DISK_NAME_LEN); | 3142 | error = sd_format_disk_name("sd", index, gd->disk_name, DISK_NAME_LEN); |
3170 | if (error) { | 3143 | if (error) { |
3171 | sdev_printk(KERN_WARNING, sdp, "SCSI disk (sd) name length exceeded.\n"); | 3144 | sdev_printk(KERN_WARNING, sdp, "SCSI disk (sd) name length exceeded.\n"); |
@@ -3205,12 +3178,11 @@ static int sd_probe(struct device *dev) | |||
3205 | return 0; | 3178 | return 0; |
3206 | 3179 | ||
3207 | out_free_index: | 3180 | out_free_index: |
3208 | put_disk_devt(&sd_devt->disk_devt); | 3181 | spin_lock(&sd_index_lock); |
3209 | sd_devt = NULL; | 3182 | ida_remove(&sd_index_ida, index); |
3183 | spin_unlock(&sd_index_lock); | ||
3210 | out_put: | 3184 | out_put: |
3211 | put_disk(gd); | 3185 | put_disk(gd); |
3212 | out_free_devt: | ||
3213 | kfree(sd_devt); | ||
3214 | out_free: | 3186 | out_free: |
3215 | kfree(sdkp); | 3187 | kfree(sdkp); |
3216 | out: | 3188 | out: |
@@ -3271,7 +3243,10 @@ static void scsi_disk_release(struct device *dev) | |||
3271 | struct scsi_disk *sdkp = to_scsi_disk(dev); | 3243 | struct scsi_disk *sdkp = to_scsi_disk(dev); |
3272 | struct gendisk *disk = sdkp->disk; | 3244 | struct gendisk *disk = sdkp->disk; |
3273 | 3245 | ||
3274 | put_disk_devt(disk->disk_devt); | 3246 | spin_lock(&sd_index_lock); |
3247 | ida_remove(&sd_index_ida, sdkp->index); | ||
3248 | spin_unlock(&sd_index_lock); | ||
3249 | |||
3275 | disk->private_data = NULL; | 3250 | disk->private_data = NULL; |
3276 | put_disk(disk); | 3251 | put_disk(disk); |
3277 | put_device(&sdkp->device->sdev_gendev); | 3252 | put_device(&sdkp->device->sdev_gendev); |