diff options
-rw-r--r-- | drivers/scsi/scsi_lib.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 253c1a98d159..60f07b6a5ffc 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -246,15 +246,18 @@ void scsi_wait_req(struct scsi_request *sreq, const void *cmnd, void *buffer, | |||
246 | unsigned bufflen, int timeout, int retries) | 246 | unsigned bufflen, int timeout, int retries) |
247 | { | 247 | { |
248 | DECLARE_COMPLETION(wait); | 248 | DECLARE_COMPLETION(wait); |
249 | int write = sreq->sr_data_direction == DMA_TO_DEVICE; | ||
249 | struct request *req; | 250 | struct request *req; |
250 | 251 | ||
251 | if (bufflen) | 252 | req = blk_get_request(sreq->sr_device->request_queue, write, |
252 | req = blk_rq_map_kern(sreq->sr_device->request_queue, | 253 | __GFP_WAIT); |
253 | sreq->sr_data_direction == DMA_TO_DEVICE, | 254 | if (bufflen && blk_rq_map_kern(sreq->sr_device->request_queue, req, |
254 | buffer, bufflen, __GFP_WAIT); | 255 | buffer, bufflen, __GFP_WAIT)) { |
255 | else | 256 | sreq->sr_result = DRIVER_ERROR << 24; |
256 | req = blk_get_request(sreq->sr_device->request_queue, READ, | 257 | blk_put_request(req); |
257 | __GFP_WAIT); | 258 | return; |
259 | } | ||
260 | |||
258 | req->flags |= REQ_NOMERGE; | 261 | req->flags |= REQ_NOMERGE; |
259 | req->waiting = &wait; | 262 | req->waiting = &wait; |
260 | req->end_io = scsi_wait_req_end_io; | 263 | req->end_io = scsi_wait_req_end_io; |