Commit deae1138 authored by Luis Chamberlain's avatar Luis Chamberlain Committed by Jens Axboe

block/ataflop: provide a helper for cleanup up an atari disk

Instead of using two separate code paths for cleaning up an atari disk,
use one. We take the more careful approach to check for *all* disk
types, as is done on exit. The init path didn't have that check as
the alternative disk types are only probed for later, they are not
initialized by default.

Yes, there is a shared tag for all disks.
Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20210927220302.1073499-14-mcgrof@kernel.orgSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 573effb2
...@@ -2010,6 +2010,20 @@ static void ataflop_probe(dev_t dev) ...@@ -2010,6 +2010,20 @@ static void ataflop_probe(dev_t dev)
mutex_unlock(&ataflop_probe_lock); mutex_unlock(&ataflop_probe_lock);
} }
static void atari_cleanup_floppy_disk(struct atari_floppy_struct *fs)
{
int type;
for (type = 0; type < NUM_DISK_MINORS; type++) {
if (!fs->disk[type])
continue;
if (fs->registered[type])
del_gendisk(fs->disk[type]);
blk_cleanup_disk(fs->disk[type]);
}
blk_mq_free_tag_set(&fs->tag_set);
}
static int __init atari_floppy_init (void) static int __init atari_floppy_init (void)
{ {
int i; int i;
...@@ -2080,10 +2094,8 @@ static int __init atari_floppy_init (void) ...@@ -2080,10 +2094,8 @@ static int __init atari_floppy_init (void)
return 0; return 0;
err: err:
while (--i >= 0) { while (--i >= 0)
blk_cleanup_disk(unit[i].disk[0]); atari_cleanup_floppy_disk(&unit[i]);
blk_mq_free_tag_set(&unit[i].tag_set);
}
unregister_blkdev(FLOPPY_MAJOR, "fd"); unregister_blkdev(FLOPPY_MAJOR, "fd");
out_unlock: out_unlock:
...@@ -2132,18 +2144,10 @@ __setup("floppy=", atari_floppy_setup); ...@@ -2132,18 +2144,10 @@ __setup("floppy=", atari_floppy_setup);
static void __exit atari_floppy_exit(void) static void __exit atari_floppy_exit(void)
{ {
int i, type; int i;
for (i = 0; i < FD_MAX_UNITS; i++) { for (i = 0; i < FD_MAX_UNITS; i++)
for (type = 0; type < NUM_DISK_MINORS; type++) { atari_cleanup_floppy_disk(&unit[i]);
if (!unit[i].disk[type])
continue;
if (unit[i].registered[type])
del_gendisk(unit[i].disk[type]);
blk_cleanup_disk(unit[i].disk[type]);
}
blk_mq_free_tag_set(&unit[i].tag_set);
}
unregister_blkdev(FLOPPY_MAJOR, "fd"); unregister_blkdev(FLOPPY_MAJOR, "fd");
del_timer_sync(&fd_timer); del_timer_sync(&fd_timer);
......
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