Skip to content

Commit

Permalink
bsg: provide bsg_remove_queue() helper
Browse files Browse the repository at this point in the history
All drivers do unregister + cleanup, provide a helper for that.

Cc: [email protected]
Reviewed-by: Hannes Reinecke <[email protected]>
Reviewed-by: Johannes Thumshirn <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Tested-by: Benjamin Block <[email protected]>
Tested-by: Ming Lei <[email protected]>
Reviewed-by: Omar Sandoval <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Nov 7, 2018
1 parent aae3b06 commit 5e28b8d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
9 changes: 9 additions & 0 deletions block/bsg-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions drivers/scsi/scsi_transport_fc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down
5 changes: 1 addition & 4 deletions drivers/scsi/scsi_transport_iscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 1 addition & 5 deletions drivers/scsi/scsi_transport_sas.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/ufs/ufs_bsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions include/linux/bsg-lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 5e28b8d

Please sign in to comment.