linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: axboe@kernel.dk
Cc: hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com,
	hch@infradead.org, jack@suse.cz, osandov@fb.com,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	Luis Chamberlain <mcgrof@kernel.org>
Subject: [RFC 09/12] block/ataflop: add a helper for removing disks
Date: Thu, 15 Jul 2021 13:59:17 -0700	[thread overview]
Message-ID: <20210715205920.2023980-10-mcgrof@kernel.org> (raw)
In-Reply-To: <20210715205920.2023980-1-mcgrof@kernel.org>

The del_gendisk() can be used now safely even if add_disk()
did not complete, and so using a helper allows other code to
use this later.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/block/ataflop.c | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index abb6fde0bd81..73eb80b58888 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -1988,6 +1988,23 @@ static int ataflop_alloc_disk(unsigned int drive, unsigned int type)
 
 static DEFINE_MUTEX(ataflop_probe_lock);
 
+static void atari_floppy_disk_remove(void)
+{
+	int i, type;
+
+	for (i = 0; i < FD_MAX_UNITS; i++) {
+		for (type = 0; type < NUM_DISK_MINORS; type++) {
+			if (!unit[i].disk[type])
+				continue;
+			del_gendisk(unit[i].disk[type]);
+			blk_cleanup_disk(unit[i].disk[0]);
+		}
+		blk_mq_free_tag_set(&unit[i].tag_set);
+	}
+	unregister_blkdev(FLOPPY_MAJOR, "fd");
+
+}
+
 static void ataflop_probe(dev_t dev)
 {
 	int drive = MINOR(dev) & 3;
@@ -2127,19 +2144,7 @@ __setup("floppy=", atari_floppy_setup);
 
 static void __exit atari_floppy_exit(void)
 {
-	int i, type;
-
-	for (i = 0; i < FD_MAX_UNITS; i++) {
-		for (type = 0; type < NUM_DISK_MINORS; type++) {
-			if (!unit[i].disk[type])
-				continue;
-			del_gendisk(unit[i].disk[type]);
-			blk_cleanup_disk(unit[i].disk[0]);
-		}
-		blk_mq_free_tag_set(&unit[i].tag_set);
-	}
-	unregister_blkdev(FLOPPY_MAJOR, "fd");
-
+	atari_floppy_disk_remove();
 	del_timer_sync(&fd_timer);
 	atari_stram_free( DMABuffer );
 }
-- 
2.27.0


  parent reply	other threads:[~2021-07-15 21:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15 20:59 [RFC 00/12] block: *add_disk*() driver conversions __register_blkdev() Luis Chamberlain
2021-07-15 20:59 ` [RFC 01/12] floppy: fix add_disk() assumption on exit Luis Chamberlain
2021-07-15 20:59 ` [RFC 02/12] floppy: use blk_cleanup_disk() Luis Chamberlain
2021-07-15 20:59 ` [RFC 03/12] floppy: add error handling support for add_disk() Luis Chamberlain
2021-07-15 20:59 ` [RFC 04/12] scsi/sd: use blk_cleanup_queue() insted of put_disk() Luis Chamberlain
2021-07-15 20:59 ` [RFC 05/12] scsi/sd: add error handling support for add_disk() Luis Chamberlain
2021-07-15 20:59 ` [RFC 06/12] scsi/sr: use blk_cleanup_disk() instead of put_disk() Luis Chamberlain
2021-07-15 20:59 ` [RFC 07/12] scsi/sr: add error handling support for add_disk() Luis Chamberlain
2021-07-15 20:59 ` [RFC 08/12] block/ataflop: use the blk_cleanup_disk() helper Luis Chamberlain
2021-07-15 20:59 ` Luis Chamberlain [this message]
2021-07-15 20:59 ` [RFC 10/12] block/ataflop add error handling support for add_disk() Luis Chamberlain
2021-07-15 20:59 ` [RFC 11/12] block/brd: " Luis Chamberlain
2021-07-15 20:59 ` [RFC 12/12] block: make probe in blk_request_module() return an error 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=20210715205920.2023980-10-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=hare@suse.de \
    --cc=hch@infradead.org \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=osandov@fb.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).