diff options
-rw-r--r-- | block/bsg-lib.c | 21 | ||||
-rw-r--r-- | drivers/scsi/scsi_transport_fc.c | 36 | ||||
-rw-r--r-- | drivers/scsi/scsi_transport_iscsi.c | 15 | ||||
-rw-r--r-- | include/linux/bsg-lib.h | 5 |
4 files changed, 25 insertions, 52 deletions
diff --git a/block/bsg-lib.c b/block/bsg-lib.c index 9d652a992316..c74acf426840 100644 --- a/block/bsg-lib.c +++ b/block/bsg-lib.c | |||
@@ -177,7 +177,7 @@ failjob_rls_job: | |||
177 | * | 177 | * |
178 | * Drivers/subsys should pass this to the queue init function. | 178 | * Drivers/subsys should pass this to the queue init function. |
179 | */ | 179 | */ |
180 | void bsg_request_fn(struct request_queue *q) | 180 | static void bsg_request_fn(struct request_queue *q) |
181 | __releases(q->queue_lock) | 181 | __releases(q->queue_lock) |
182 | __acquires(q->queue_lock) | 182 | __acquires(q->queue_lock) |
183 | { | 183 | { |
@@ -214,24 +214,24 @@ void bsg_request_fn(struct request_queue *q) | |||
214 | put_device(dev); | 214 | put_device(dev); |
215 | spin_lock_irq(q->queue_lock); | 215 | spin_lock_irq(q->queue_lock); |
216 | } | 216 | } |
217 | EXPORT_SYMBOL_GPL(bsg_request_fn); | ||
218 | 217 | ||
219 | /** | 218 | /** |
220 | * bsg_setup_queue - Create and add the bsg hooks so we can receive requests | 219 | * bsg_setup_queue - Create and add the bsg hooks so we can receive requests |
221 | * @dev: device to attach bsg device to | 220 | * @dev: device to attach bsg device to |
222 | * @q: request queue setup by caller | ||
223 | * @name: device to give bsg device | 221 | * @name: device to give bsg device |
224 | * @job_fn: bsg job handler | 222 | * @job_fn: bsg job handler |
225 | * @dd_job_size: size of LLD data needed for each job | 223 | * @dd_job_size: size of LLD data needed for each job |
226 | * | ||
227 | * The caller should have setup the reuqest queue with bsg_request_fn | ||
228 | * as the request_fn. | ||
229 | */ | 224 | */ |
230 | int bsg_setup_queue(struct device *dev, struct request_queue *q, | 225 | struct request_queue *bsg_setup_queue(struct device *dev, char *name, |
231 | char *name, bsg_job_fn *job_fn, int dd_job_size) | 226 | bsg_job_fn *job_fn, int dd_job_size) |
232 | { | 227 | { |
228 | struct request_queue *q; | ||
233 | int ret; | 229 | int ret; |
234 | 230 | ||
231 | q = blk_init_queue(bsg_request_fn, NULL); | ||
232 | if (!q) | ||
233 | return ERR_PTR(-ENOMEM); | ||
234 | |||
235 | q->queuedata = dev; | 235 | q->queuedata = dev; |
236 | q->bsg_job_size = dd_job_size; | 236 | q->bsg_job_size = dd_job_size; |
237 | q->bsg_job_fn = job_fn; | 237 | q->bsg_job_fn = job_fn; |
@@ -243,9 +243,10 @@ int bsg_setup_queue(struct device *dev, struct request_queue *q, | |||
243 | if (ret) { | 243 | if (ret) { |
244 | printk(KERN_ERR "%s: bsg interface failed to " | 244 | printk(KERN_ERR "%s: bsg interface failed to " |
245 | "initialize - register queue\n", dev->kobj.name); | 245 | "initialize - register queue\n", dev->kobj.name); |
246 | return ret; | 246 | blk_cleanup_queue(q); |
247 | return ERR_PTR(ret); | ||
247 | } | 248 | } |
248 | 249 | ||
249 | return 0; | 250 | return q; |
250 | } | 251 | } |
251 | EXPORT_SYMBOL_GPL(bsg_setup_queue); | 252 | EXPORT_SYMBOL_GPL(bsg_setup_queue); |
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index afcedec58d17..13dcb9ba823c 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c | |||
@@ -3765,7 +3765,6 @@ fc_bsg_hostadd(struct Scsi_Host *shost, struct fc_host_attrs *fc_host) | |||
3765 | struct device *dev = &shost->shost_gendev; | 3765 | struct device *dev = &shost->shost_gendev; |
3766 | struct fc_internal *i = to_fc_internal(shost->transportt); | 3766 | struct fc_internal *i = to_fc_internal(shost->transportt); |
3767 | struct request_queue *q; | 3767 | struct request_queue *q; |
3768 | int err; | ||
3769 | char bsg_name[20]; | 3768 | char bsg_name[20]; |
3770 | 3769 | ||
3771 | fc_host->rqst_q = NULL; | 3770 | fc_host->rqst_q = NULL; |
@@ -3776,24 +3775,14 @@ fc_bsg_hostadd(struct Scsi_Host *shost, struct fc_host_attrs *fc_host) | |||
3776 | snprintf(bsg_name, sizeof(bsg_name), | 3775 | snprintf(bsg_name, sizeof(bsg_name), |
3777 | "fc_host%d", shost->host_no); | 3776 | "fc_host%d", shost->host_no); |
3778 | 3777 | ||
3779 | q = blk_init_queue(bsg_request_fn, NULL); | 3778 | q = bsg_setup_queue(dev, bsg_name, fc_bsg_dispatch, i->f->dd_bsg_size); |
3780 | if (!q) { | 3779 | if (IS_ERR(q)) { |
3781 | dev_err(dev, | ||
3782 | "fc_host%d: bsg interface failed to initialize - no request queue\n", | ||
3783 | shost->host_no); | ||
3784 | return -ENOMEM; | ||
3785 | } | ||
3786 | |||
3787 | __scsi_init_queue(shost, q); | ||
3788 | err = bsg_setup_queue(dev, q, bsg_name, fc_bsg_dispatch, | ||
3789 | i->f->dd_bsg_size); | ||
3790 | if (err) { | ||
3791 | dev_err(dev, | 3780 | dev_err(dev, |
3792 | "fc_host%d: bsg interface failed to initialize - setup queue\n", | 3781 | "fc_host%d: bsg interface failed to initialize - setup queue\n", |
3793 | shost->host_no); | 3782 | shost->host_no); |
3794 | blk_cleanup_queue(q); | 3783 | return PTR_ERR(q); |
3795 | return err; | ||
3796 | } | 3784 | } |
3785 | __scsi_init_queue(shost, q); | ||
3797 | blk_queue_rq_timed_out(q, fc_bsg_job_timeout); | 3786 | blk_queue_rq_timed_out(q, fc_bsg_job_timeout); |
3798 | blk_queue_rq_timeout(q, FC_DEFAULT_BSG_TIMEOUT); | 3787 | blk_queue_rq_timeout(q, FC_DEFAULT_BSG_TIMEOUT); |
3799 | fc_host->rqst_q = q; | 3788 | fc_host->rqst_q = q; |
@@ -3825,27 +3814,18 @@ fc_bsg_rportadd(struct Scsi_Host *shost, struct fc_rport *rport) | |||
3825 | struct device *dev = &rport->dev; | 3814 | struct device *dev = &rport->dev; |
3826 | struct fc_internal *i = to_fc_internal(shost->transportt); | 3815 | struct fc_internal *i = to_fc_internal(shost->transportt); |
3827 | struct request_queue *q; | 3816 | struct request_queue *q; |
3828 | int err; | ||
3829 | 3817 | ||
3830 | rport->rqst_q = NULL; | 3818 | rport->rqst_q = NULL; |
3831 | 3819 | ||
3832 | if (!i->f->bsg_request) | 3820 | if (!i->f->bsg_request) |
3833 | return -ENOTSUPP; | 3821 | return -ENOTSUPP; |
3834 | 3822 | ||
3835 | q = blk_init_queue(bsg_request_fn, NULL); | 3823 | q = bsg_setup_queue(dev, NULL, fc_bsg_dispatch, i->f->dd_bsg_size); |
3836 | if (!q) { | 3824 | if (IS_ERR(q)) { |
3837 | dev_err(dev, "bsg interface failed to initialize - no request queue\n"); | ||
3838 | return -ENOMEM; | ||
3839 | } | ||
3840 | |||
3841 | __scsi_init_queue(shost, q); | ||
3842 | err = bsg_setup_queue(dev, q, NULL, fc_bsg_dispatch, i->f->dd_bsg_size); | ||
3843 | if (err) { | ||
3844 | dev_err(dev, "failed to setup bsg queue\n"); | 3825 | dev_err(dev, "failed to setup bsg queue\n"); |
3845 | blk_cleanup_queue(q); | 3826 | return PTR_ERR(q); |
3846 | return err; | ||
3847 | } | 3827 | } |
3848 | 3828 | __scsi_init_queue(shost, q); | |
3849 | blk_queue_prep_rq(q, fc_bsg_rport_prep); | 3829 | blk_queue_prep_rq(q, fc_bsg_rport_prep); |
3850 | blk_queue_rq_timed_out(q, fc_bsg_job_timeout); | 3830 | blk_queue_rq_timed_out(q, fc_bsg_job_timeout); |
3851 | blk_queue_rq_timeout(q, BLK_DEFAULT_SG_TIMEOUT); | 3831 | blk_queue_rq_timeout(q, BLK_DEFAULT_SG_TIMEOUT); |
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index 04ebe6e65b83..568c9f26a561 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c | |||
@@ -1537,25 +1537,18 @@ iscsi_bsg_host_add(struct Scsi_Host *shost, struct iscsi_cls_host *ihost) | |||
1537 | struct iscsi_internal *i = to_iscsi_internal(shost->transportt); | 1537 | struct iscsi_internal *i = to_iscsi_internal(shost->transportt); |
1538 | struct request_queue *q; | 1538 | struct request_queue *q; |
1539 | char bsg_name[20]; | 1539 | char bsg_name[20]; |
1540 | int ret; | ||
1541 | 1540 | ||
1542 | if (!i->iscsi_transport->bsg_request) | 1541 | if (!i->iscsi_transport->bsg_request) |
1543 | return -ENOTSUPP; | 1542 | return -ENOTSUPP; |
1544 | 1543 | ||
1545 | snprintf(bsg_name, sizeof(bsg_name), "iscsi_host%d", shost->host_no); | 1544 | snprintf(bsg_name, sizeof(bsg_name), "iscsi_host%d", shost->host_no); |
1546 | 1545 | q = bsg_setup_queue(dev, bsg_name, iscsi_bsg_host_dispatch, 0); | |
1547 | q = blk_init_queue(bsg_request_fn, NULL); | 1546 | if (IS_ERR(q)) { |
1548 | if (!q) | ||
1549 | return -ENOMEM; | ||
1550 | |||
1551 | __scsi_init_queue(shost, q); | ||
1552 | ret = bsg_setup_queue(dev, q, bsg_name, iscsi_bsg_host_dispatch, 0); | ||
1553 | if (ret) { | ||
1554 | shost_printk(KERN_ERR, shost, "bsg interface failed to " | 1547 | shost_printk(KERN_ERR, shost, "bsg interface failed to " |
1555 | "initialize - no request queue\n"); | 1548 | "initialize - no request queue\n"); |
1556 | blk_cleanup_queue(q); | 1549 | return PTR_ERR(q); |
1557 | return ret; | ||
1558 | } | 1550 | } |
1551 | __scsi_init_queue(shost, q); | ||
1559 | 1552 | ||
1560 | ihost->bsg_q = q; | 1553 | ihost->bsg_q = q; |
1561 | return 0; | 1554 | return 0; |
diff --git a/include/linux/bsg-lib.h b/include/linux/bsg-lib.h index 657a718c27d2..e34dde2da0ef 100644 --- a/include/linux/bsg-lib.h +++ b/include/linux/bsg-lib.h | |||
@@ -66,9 +66,8 @@ struct bsg_job { | |||
66 | 66 | ||
67 | void bsg_job_done(struct bsg_job *job, int result, | 67 | void bsg_job_done(struct bsg_job *job, int result, |
68 | unsigned int reply_payload_rcv_len); | 68 | unsigned int reply_payload_rcv_len); |
69 | int bsg_setup_queue(struct device *dev, struct request_queue *q, char *name, | 69 | struct request_queue *bsg_setup_queue(struct device *dev, char *name, |
70 | bsg_job_fn *job_fn, int dd_job_size); | 70 | bsg_job_fn *job_fn, int dd_job_size); |
71 | void bsg_request_fn(struct request_queue *q); | ||
72 | void bsg_job_put(struct bsg_job *job); | 71 | void bsg_job_put(struct bsg_job *job); |
73 | int __must_check bsg_job_get(struct bsg_job *job); | 72 | int __must_check bsg_job_get(struct bsg_job *job); |
74 | 73 | ||