diff options
author | K. Y. Srinivasan <kys@microsoft.com> | 2011-04-22 17:55:14 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-04-25 19:22:53 -0400 |
commit | 9bd0859a246f5855ed8e4840711f6c4fc98e741a (patch) | |
tree | 140ee7303d1513f4120cb6564a9c054c0b51895f | |
parent | 3880914aa68fec748e634522bd2fef448b0ea3bb (diff) |
Staging: hv: Simplify blkvsc_init_rw()
Simplyfify blkvsc_init_rw() by using a single scsi command independent of
the start sector.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Hank Janssen <hjanssen@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/hv/blkvsc_drv.c | 58 |
1 files changed, 13 insertions, 45 deletions
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index b2cd04a7e060..5cf82f04a19b 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c | |||
@@ -305,53 +305,21 @@ static void blkvsc_init_rw(struct blkvsc_request *blkvsc_req) | |||
305 | 305 | ||
306 | blkvsc_req->cmd_len = 16; | 306 | blkvsc_req->cmd_len = 16; |
307 | 307 | ||
308 | if (blkvsc_req->sector_start > 0xffffffff) { | 308 | if (rq_data_dir(blkvsc_req->req)) { |
309 | if (rq_data_dir(blkvsc_req->req)) { | 309 | blkvsc_req->write = 1; |
310 | blkvsc_req->write = 1; | 310 | blkvsc_req->cmnd[0] = WRITE_16; |
311 | blkvsc_req->cmnd[0] = WRITE_16; | ||
312 | } else { | ||
313 | blkvsc_req->write = 0; | ||
314 | blkvsc_req->cmnd[0] = READ_16; | ||
315 | } | ||
316 | |||
317 | blkvsc_req->cmnd[1] |= | ||
318 | (blkvsc_req->req->cmd_flags & REQ_FUA) ? 0x8 : 0; | ||
319 | |||
320 | *(unsigned long long *)&blkvsc_req->cmnd[2] = | ||
321 | cpu_to_be64(blkvsc_req->sector_start); | ||
322 | *(unsigned int *)&blkvsc_req->cmnd[10] = | ||
323 | cpu_to_be32(blkvsc_req->sector_count); | ||
324 | } else if ((blkvsc_req->sector_count > 0xff) || | ||
325 | (blkvsc_req->sector_start > 0x1fffff)) { | ||
326 | if (rq_data_dir(blkvsc_req->req)) { | ||
327 | blkvsc_req->write = 1; | ||
328 | blkvsc_req->cmnd[0] = WRITE_10; | ||
329 | } else { | ||
330 | blkvsc_req->write = 0; | ||
331 | blkvsc_req->cmnd[0] = READ_10; | ||
332 | } | ||
333 | |||
334 | blkvsc_req->cmnd[1] |= | ||
335 | (blkvsc_req->req->cmd_flags & REQ_FUA) ? 0x8 : 0; | ||
336 | |||
337 | *(unsigned int *)&blkvsc_req->cmnd[2] = | ||
338 | cpu_to_be32(blkvsc_req->sector_start); | ||
339 | *(unsigned short *)&blkvsc_req->cmnd[7] = | ||
340 | cpu_to_be16(blkvsc_req->sector_count); | ||
341 | } else { | 311 | } else { |
342 | if (rq_data_dir(blkvsc_req->req)) { | 312 | blkvsc_req->write = 0; |
343 | blkvsc_req->write = 1; | 313 | blkvsc_req->cmnd[0] = READ_16; |
344 | blkvsc_req->cmnd[0] = WRITE_6; | ||
345 | } else { | ||
346 | blkvsc_req->write = 0; | ||
347 | blkvsc_req->cmnd[0] = READ_6; | ||
348 | } | ||
349 | |||
350 | *(unsigned int *)&blkvsc_req->cmnd[1] = | ||
351 | cpu_to_be32(blkvsc_req->sector_start) >> 8; | ||
352 | blkvsc_req->cmnd[1] &= 0x1f; | ||
353 | blkvsc_req->cmnd[4] = (unsigned char)blkvsc_req->sector_count; | ||
354 | } | 314 | } |
315 | |||
316 | blkvsc_req->cmnd[1] |= | ||
317 | (blkvsc_req->req->cmd_flags & REQ_FUA) ? 0x8 : 0; | ||
318 | |||
319 | *(unsigned long long *)&blkvsc_req->cmnd[2] = | ||
320 | cpu_to_be64(blkvsc_req->sector_start); | ||
321 | *(unsigned int *)&blkvsc_req->cmnd[10] = | ||
322 | cpu_to_be32(blkvsc_req->sector_count); | ||
355 | } | 323 | } |
356 | 324 | ||
357 | 325 | ||