Commit 62858dacc8dea55c5bdb474ccd8acb0657e23dd0
Committed by
Jens Axboe
1 parent
30c00eda73
Exists in
master
and in
7 other branches
scsi: sr avoids useless buffer allocation
blk_rq_map_kern can handle the stack buffers correctly (avoid DMA from/to the stack buffers by using the bounce buffer) so we don't need to complicate the code by allocating just 8 bytes. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Cc: James Bottomley <James.Bottomley@HansenPartnership.com> Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: Tejun Heo <htejun@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Showing 1 changed file with 5 additions and 15 deletions Side-by-side Diff
drivers/scsi/sr.c
... | ... | @@ -673,24 +673,20 @@ |
673 | 673 | static void get_sectorsize(struct scsi_cd *cd) |
674 | 674 | { |
675 | 675 | unsigned char cmd[10]; |
676 | - unsigned char *buffer; | |
676 | + unsigned char buffer[8]; | |
677 | 677 | int the_result, retries = 3; |
678 | 678 | int sector_size; |
679 | 679 | struct request_queue *queue; |
680 | 680 | |
681 | - buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); | |
682 | - if (!buffer) | |
683 | - goto Enomem; | |
684 | - | |
685 | 681 | do { |
686 | 682 | cmd[0] = READ_CAPACITY; |
687 | 683 | memset((void *) &cmd[1], 0, 9); |
688 | - memset(buffer, 0, 8); | |
684 | + memset(buffer, 0, sizeof(buffer)); | |
689 | 685 | |
690 | 686 | /* Do the command and wait.. */ |
691 | 687 | the_result = scsi_execute_req(cd->device, cmd, DMA_FROM_DEVICE, |
692 | - buffer, 8, NULL, SR_TIMEOUT, | |
693 | - MAX_RETRIES); | |
688 | + buffer, sizeof(buffer), NULL, | |
689 | + SR_TIMEOUT, MAX_RETRIES); | |
694 | 690 | |
695 | 691 | retries--; |
696 | 692 | |
697 | 693 | |
... | ... | @@ -745,14 +741,8 @@ |
745 | 741 | |
746 | 742 | queue = cd->device->request_queue; |
747 | 743 | blk_queue_hardsect_size(queue, sector_size); |
748 | -out: | |
749 | - kfree(buffer); | |
750 | - return; | |
751 | 744 | |
752 | -Enomem: | |
753 | - cd->capacity = 0x1fffff; | |
754 | - cd->device->sector_size = 2048; /* A guess, just in case */ | |
755 | - goto out; | |
745 | + return; | |
756 | 746 | } |
757 | 747 | |
758 | 748 | static void get_capabilities(struct scsi_cd *cd) |