diff options
author | Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com> | 2012-10-30 03:36:07 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2012-10-30 03:36:07 -0400 |
commit | 1a4ae43e4feb570901667782678772fd31c1b125 (patch) | |
tree | fb918164c93bdae16f01fb4cf6823cb98fb875dd /drivers/block/floppy.c | |
parent | 8d3ab4ebfd7435bc248873de47d0ca23076c4973 (diff) |
floppy: remove dr, reuse drive on do_floppy_init
This is a small cleanup, that also may turn error handling of
unitialized disks more readable. We don't need a separate variable to
track allocated disks, remove dr and reuse drive variable instead.
Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block/floppy.c')
-rw-r--r-- | drivers/block/floppy.c | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index d54b234a1a67..1c49d7173966 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -4131,8 +4131,7 @@ static struct kobject *floppy_find(dev_t dev, int *part, void *data) | |||
4131 | 4131 | ||
4132 | static int __init do_floppy_init(void) | 4132 | static int __init do_floppy_init(void) |
4133 | { | 4133 | { |
4134 | int i, unit, drive; | 4134 | int i, unit, drive, err; |
4135 | int err, dr; | ||
4136 | 4135 | ||
4137 | set_debugt(); | 4136 | set_debugt(); |
4138 | interruptjiffies = resultjiffies = jiffies; | 4137 | interruptjiffies = resultjiffies = jiffies; |
@@ -4148,29 +4147,28 @@ static int __init do_floppy_init(void) | |||
4148 | if (!floppy_wq) | 4147 | if (!floppy_wq) |
4149 | return -ENOMEM; | 4148 | return -ENOMEM; |
4150 | 4149 | ||
4151 | for (dr = 0; dr < N_DRIVE; dr++) { | 4150 | for (drive = 0; drive < N_DRIVE; drive++) { |
4152 | disks[dr] = alloc_disk(1); | 4151 | disks[drive] = alloc_disk(1); |
4153 | if (!disks[dr]) { | 4152 | if (!disks[drive]) { |
4154 | err = -ENOMEM; | 4153 | err = -ENOMEM; |
4155 | goto out_put_disk; | 4154 | goto out_put_disk; |
4156 | } | 4155 | } |
4157 | 4156 | ||
4158 | disks[dr]->queue = blk_init_queue(do_fd_request, &floppy_lock); | 4157 | disks[drive]->queue = blk_init_queue(do_fd_request, &floppy_lock); |
4159 | if (!disks[dr]->queue) { | 4158 | if (!disks[drive]->queue) { |
4160 | put_disk(disks[dr]); | ||
4161 | err = -ENOMEM; | 4159 | err = -ENOMEM; |
4162 | goto out_put_disk; | 4160 | goto out_put_disk; |
4163 | } | 4161 | } |
4164 | 4162 | ||
4165 | blk_queue_max_hw_sectors(disks[dr]->queue, 64); | 4163 | blk_queue_max_hw_sectors(disks[drive]->queue, 64); |
4166 | disks[dr]->major = FLOPPY_MAJOR; | 4164 | disks[drive]->major = FLOPPY_MAJOR; |
4167 | disks[dr]->first_minor = TOMINOR(dr); | 4165 | disks[drive]->first_minor = TOMINOR(drive); |
4168 | disks[dr]->fops = &floppy_fops; | 4166 | disks[drive]->fops = &floppy_fops; |
4169 | sprintf(disks[dr]->disk_name, "fd%d", dr); | 4167 | sprintf(disks[drive]->disk_name, "fd%d", drive); |
4170 | 4168 | ||
4171 | init_timer(&motor_off_timer[dr]); | 4169 | init_timer(&motor_off_timer[drive]); |
4172 | motor_off_timer[dr].data = dr; | 4170 | motor_off_timer[drive].data = drive; |
4173 | motor_off_timer[dr].function = motor_off_callback; | 4171 | motor_off_timer[drive].function = motor_off_callback; |
4174 | } | 4172 | } |
4175 | 4173 | ||
4176 | err = register_blkdev(FLOPPY_MAJOR, "fd"); | 4174 | err = register_blkdev(FLOPPY_MAJOR, "fd"); |
@@ -4332,17 +4330,15 @@ out_unreg_region: | |||
4332 | out_unreg_blkdev: | 4330 | out_unreg_blkdev: |
4333 | unregister_blkdev(FLOPPY_MAJOR, "fd"); | 4331 | unregister_blkdev(FLOPPY_MAJOR, "fd"); |
4334 | out_put_disk: | 4332 | out_put_disk: |
4335 | while (dr--) { | 4333 | for (drive = 0; drive < N_DRIVE; drive++) { |
4336 | del_timer_sync(&motor_off_timer[dr]); | 4334 | if (!disks[drive]) |
4337 | if (disks[dr]->queue) { | 4335 | break; |
4338 | blk_cleanup_queue(disks[dr]->queue); | 4336 | if (disks[drive]->queue) { |
4339 | /* | 4337 | del_timer_sync(&motor_off_timer[drive]); |
4340 | * put_disk() is not paired with add_disk() and | 4338 | blk_cleanup_queue(disks[drive]->queue); |
4341 | * will put queue reference one extra time. fix it. | 4339 | disks[drive]->queue = NULL; |
4342 | */ | ||
4343 | disks[dr]->queue = NULL; | ||
4344 | } | 4340 | } |
4345 | put_disk(disks[dr]); | 4341 | put_disk(disks[drive]); |
4346 | } | 4342 | } |
4347 | destroy_workqueue(floppy_wq); | 4343 | destroy_workqueue(floppy_wq); |
4348 | return err; | 4344 | return err; |