aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/ulp/srp/ib_srp.c
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2011-01-13 14:02:25 -0500
committerRoland Dreier <rolandd@cisco.com>2011-01-13 17:00:43 -0500
commit695b83495e2fba9d3a883193cfc9d5eefa96a911 (patch)
tree23c03ec4fc840d6df5c038fe7eb49e224123f081 /drivers/infiniband/ulp/srp/ib_srp.c
parent4162cf64973df51fc885825bc9ca4d055891c49f (diff)
IB/srp: Test only once whether iu allocation succeeded
Merge the two tests in srp_queuecommand() of whether information unit allocation succeeded into one. An intended side effect of this change is that we fix the warning: drivers/infiniband/ulp/srp/ib_srp.c: In function 'srp_queuecommand': drivers/infiniband/ulp/srp/ib_srp.c:1116: warning: 'req' may be used uninitialized in this function (seen with CONFIG_CC_OPTIMIZE_FOR_SIZE=y at least with gcc 4.4.4) Signed-off-by: Bart Van Assche <bvanassche@acm.org> Acked-by: David Dillow <dillowda@ornl.gov> Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/ulp/srp/ib_srp.c')
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 4b62105ed1e8..b28c2b9db26b 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1132,15 +1132,12 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
1132 1132
1133 spin_lock_irqsave(&target->lock, flags); 1133 spin_lock_irqsave(&target->lock, flags);
1134 iu = __srp_get_tx_iu(target, SRP_IU_CMD); 1134 iu = __srp_get_tx_iu(target, SRP_IU_CMD);
1135 if (iu) {
1136 req = list_first_entry(&target->free_reqs, struct srp_request,
1137 list);
1138 list_del(&req->list);
1139 }
1140 spin_unlock_irqrestore(&target->lock, flags);
1141
1142 if (!iu) 1135 if (!iu)
1143 goto err; 1136 goto err_unlock;
1137
1138 req = list_first_entry(&target->free_reqs, struct srp_request, list);
1139 list_del(&req->list);
1140 spin_unlock_irqrestore(&target->lock, flags);
1144 1141
1145 dev = target->srp_host->srp_dev->dev; 1142 dev = target->srp_host->srp_dev->dev;
1146 ib_dma_sync_single_for_cpu(dev, iu->dma, srp_max_iu_len, 1143 ib_dma_sync_single_for_cpu(dev, iu->dma, srp_max_iu_len,
@@ -1185,6 +1182,8 @@ err_iu:
1185 1182
1186 spin_lock_irqsave(&target->lock, flags); 1183 spin_lock_irqsave(&target->lock, flags);
1187 list_add(&req->list, &target->free_reqs); 1184 list_add(&req->list, &target->free_reqs);
1185
1186err_unlock:
1188 spin_unlock_irqrestore(&target->lock, flags); 1187 spin_unlock_irqrestore(&target->lock, flags);
1189 1188
1190err: 1189err: