summaryrefslogtreecommitdiff
path: root/drivers/block/swim.c
diff options
context:
space:
mode:
authorLuis Chamberlain <mcgrof@kernel.org>2021-09-27 15:02:57 -0700
committerJens Axboe <axboe@kernel.dk>2021-10-18 14:41:37 -0600
commit9ef41effb9b65088053e31c741c2a1ec97190117 (patch)
treef32d37cad24ebce30a8d6fbdeac668ba259f1c1a /drivers/block/swim.c
parent4e9abe72530a2baf5f80d60e8d0bcdb84964d2e4 (diff)
swim: add a floppy registration bool which triggers del_gendisk()
Instead of calling del_gendisk() on exit alone, let's add a registration bool to the floppy disk state, this way this can be done on the shared caller, swim_cleanup_floppy_disk(). This will be more useful in subsequent patches. Right now, this just shuffles functionality out to a helper in a safe way. Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Link: https://lore.kernel.org/r/20210927220302.1073499-10-mcgrof@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block/swim.c')
-rw-r--r--drivers/block/swim.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/block/swim.c b/drivers/block/swim.c
index 4f87d1af7c60..eed453528f4c 100644
--- a/drivers/block/swim.c
+++ b/drivers/block/swim.c
@@ -185,6 +185,7 @@ struct floppy_state {
int track;
int ref_count;
+ bool registered;
struct gendisk *disk;
struct blk_mq_tag_set tag_set;
@@ -779,6 +780,9 @@ static void swim_cleanup_floppy_disk(struct floppy_state *fs)
if (!disk)
return;
+ if (fs->registered)
+ del_gendisk(fs->disk);
+
blk_cleanup_disk(disk);
blk_mq_free_tag_set(&fs->tag_set);
}
@@ -840,6 +844,7 @@ static int swim_floppy_init(struct swim_priv *swd)
swd->unit[drive].disk->private_data = &swd->unit[drive];
set_capacity(swd->unit[drive].disk, 2880);
add_disk(swd->unit[drive].disk);
+ swd->unit[drive].registered = true;
}
return 0;
@@ -916,10 +921,8 @@ static int swim_remove(struct platform_device *dev)
int drive;
struct resource *res;
- for (drive = 0; drive < swd->floppy_count; drive++) {
- del_gendisk(swd->unit[drive].disk);
+ for (drive = 0; drive < swd->floppy_count; drive++)
swim_cleanup_floppy_disk(&swd->unit[drive]);
- }
unregister_blkdev(FLOPPY_MAJOR, "fd");