From: Luis Chamberlain <mcgrof@kernel.org>
To: axboe@kernel.dk, efremov@linux.com, hch@lst.de
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
Luis Chamberlain <mcgrof@kernel.org>
Subject: [PATCH 09/14] swim: add a floppy registration bool which triggers del_gendisk()
Date: Fri, 3 Sep 2021 18:35:31 -0700 [thread overview]
Message-ID: <20210904013536.3181237-10-mcgrof@kernel.org> (raw)
In-Reply-To: <20210904013536.3181237-1-mcgrof@kernel.org>
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>
---
drivers/block/swim.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/block/swim.c b/drivers/block/swim.c
index 3deb9d9a59c0..b3ee3dad5a8c 100644
--- a/drivers/block/swim.c
+++ b/drivers/block/swim.c
@@ -184,6 +184,7 @@ struct floppy_state {
int track;
int ref_count;
+ bool registered;
struct gendisk *disk;
struct blk_mq_tag_set tag_set;
@@ -778,6 +779,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);
}
@@ -839,6 +843,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;
@@ -915,10 +920,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");
--
2.30.2
next prev parent reply other threads:[~2021-09-04 1:35 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-04 1:35 [PATCH 00/14] block: 6th batch of add_disk() error handling conversions Luis Chamberlain
2021-09-04 1:35 ` [PATCH 01/14] block/swim3: add error handling support for add_disk() Luis Chamberlain
2021-09-04 1:35 ` [PATCH 02/14] floppy: fix add_disk() assumption on exit due to new developments Luis Chamberlain
2021-09-04 1:35 ` [PATCH 03/14] floppy: use blk_cleanup_disk() Luis Chamberlain
2021-09-04 1:35 ` [PATCH 04/14] floppy: fix calling platform_device_unregister() on invalid drives Luis Chamberlain
2021-09-04 1:35 ` [PATCH 05/14] floppy: add error handling support for add_disk() Luis Chamberlain
2021-09-04 1:35 ` [PATCH 06/14] amiflop: " Luis Chamberlain
2021-09-04 1:35 ` [PATCH 07/14] swim: simplify using blk_cleanup_disk() on swim_remove() Luis Chamberlain
2021-09-04 1:35 ` [PATCH 08/14] swim: add helper for disk cleanup Luis Chamberlain
2021-09-04 1:35 ` Luis Chamberlain [this message]
2021-09-04 1:35 ` [PATCH 10/14] swim: add error handling support for add_disk() Luis Chamberlain
2021-09-04 1:35 ` [PATCH 11/14] block/ataflop: use the blk_cleanup_disk() helper Luis Chamberlain
2021-09-04 1:35 ` [PATCH 12/14] block/ataflop: add registration bool before calling del_gendisk() Luis Chamberlain
2021-09-04 1:35 ` [PATCH 13/14] block/ataflop: provide a helper for cleanup up an atari disk Luis Chamberlain
2021-09-04 1:35 ` [PATCH 14/14] block/ataflop add error handling support for add_disk() Luis Chamberlain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210904013536.3181237-10-mcgrof@kernel.org \
--to=mcgrof@kernel.org \
--cc=axboe@kernel.dk \
--cc=efremov@linux.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.