bsg: provide bsg_remove_queue() helper
authorJens Axboe <axboe@kernel.dk>
Fri, 26 Oct 2018 17:27:02 +0000 (11:27 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 7 Nov 2018 20:42:32 +0000 (13:42 -0700)
All drivers do unregister + cleanup, provide a helper for that.

Cc: linux-scsi@vger.kernel.org
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Tested-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Tested-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bsg-lib.c
drivers/scsi/scsi_transport_fc.c
drivers/scsi/scsi_transport_iscsi.c
drivers/scsi/scsi_transport_sas.c
drivers/scsi/ufs/ufs_bsg.c
include/linux/bsg-lib.h

index 1da011ec04e67cf797c3e2dd9d2039a6e00d08b4..3f2e9a1bae44149852e77d6a1642ebbc67e1c120 100644 (file)
@@ -296,6 +296,15 @@ static void bsg_exit_rq(struct request_queue *q, struct request *req)
        kfree(job->reply);
 }
 
+void bsg_remove_queue(struct request_queue *q)
+{
+       if (q) {
+               bsg_unregister_queue(q);
+               blk_cleanup_queue(q);
+       }
+}
+EXPORT_SYMBOL_GPL(bsg_remove_queue);
+
 /**
  * bsg_setup_queue - Create and add the bsg hooks so we can receive requests
  * @dev: device to attach bsg device to
index 98aaffb4c715b919f9d8b82903177bb7c6462e70..638f83ab04b262e22816a89e30af95822eb6e1bc 100644 (file)
@@ -3851,10 +3851,7 @@ fc_bsg_rportadd(struct Scsi_Host *shost, struct fc_rport *rport)
 static void
 fc_bsg_remove(struct request_queue *q)
 {
-       if (q) {
-               bsg_unregister_queue(q);
-               blk_cleanup_queue(q);
-       }
+       bsg_remove_queue(q);
 }
 
 
index 26b11a775be905dbb61a11a615fc1a3745958187..ff123023e5a58b2938f6f767a22799744b5a09cb 100644 (file)
@@ -1576,10 +1576,7 @@ static int iscsi_remove_host(struct transport_container *tc,
        struct Scsi_Host *shost = dev_to_shost(dev);
        struct iscsi_cls_host *ihost = shost->shost_data;
 
-       if (ihost->bsg_q) {
-               bsg_unregister_queue(ihost->bsg_q);
-               blk_cleanup_queue(ihost->bsg_q);
-       }
+       bsg_remove_queue(ihost->bsg_q);
        return 0;
 }
 
index cf6d47891d773fd33b8881eca19b58258e4ff3eb..692b46937e52320bc27924ad365affac7ae7f599 100644 (file)
@@ -246,11 +246,7 @@ static int sas_host_remove(struct transport_container *tc, struct device *dev,
        struct Scsi_Host *shost = dev_to_shost(dev);
        struct request_queue *q = to_sas_host_attrs(shost)->q;
 
-       if (q) {
-               bsg_unregister_queue(q);
-               blk_cleanup_queue(q);
-       }
-
+       bsg_remove_queue(q);
        return 0;
 }
 
index dd0e9700a74cc3d01648ca46956ad29508c9491d..775bb4e5e36eb0a0714d6f0b4c5b2dff0e0ff761 100644 (file)
@@ -157,7 +157,7 @@ void ufs_bsg_remove(struct ufs_hba *hba)
        if (!hba->bsg_queue)
                return;
 
-       bsg_unregister_queue(hba->bsg_queue);
+       bsg_remove_queue(hba->bsg_queue);
 
        device_del(bsg_dev);
        put_device(bsg_dev);
index b13ae143e7ef5c6212d997bc5cbe2a027a17bc03..9c9b134b1fa5f40bc1611d7723260a759438f7ac 100644 (file)
@@ -73,6 +73,7 @@ void bsg_job_done(struct bsg_job *job, int result,
                  unsigned int reply_payload_rcv_len);
 struct request_queue *bsg_setup_queue(struct device *dev, const char *name,
                bsg_job_fn *job_fn, rq_timed_out_fn *timeout, int dd_job_size);
+void bsg_remove_queue(struct request_queue *q);
 void bsg_job_put(struct bsg_job *job);
 int __must_check bsg_job_get(struct bsg_job *job);