提交 62858dac 编写于 作者: F FUJITA Tomonori 提交者: Jens Axboe

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: NFUJITA 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: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
上级 30c00eda
...@@ -673,24 +673,20 @@ static int sr_probe(struct device *dev) ...@@ -673,24 +673,20 @@ static int sr_probe(struct device *dev)
static void get_sectorsize(struct scsi_cd *cd) static void get_sectorsize(struct scsi_cd *cd)
{ {
unsigned char cmd[10]; unsigned char cmd[10];
unsigned char *buffer; unsigned char buffer[8];
int the_result, retries = 3; int the_result, retries = 3;
int sector_size; int sector_size;
struct request_queue *queue; struct request_queue *queue;
buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
if (!buffer)
goto Enomem;
do { do {
cmd[0] = READ_CAPACITY; cmd[0] = READ_CAPACITY;
memset((void *) &cmd[1], 0, 9); memset((void *) &cmd[1], 0, 9);
memset(buffer, 0, 8); memset(buffer, 0, sizeof(buffer));
/* Do the command and wait.. */ /* Do the command and wait.. */
the_result = scsi_execute_req(cd->device, cmd, DMA_FROM_DEVICE, the_result = scsi_execute_req(cd->device, cmd, DMA_FROM_DEVICE,
buffer, 8, NULL, SR_TIMEOUT, buffer, sizeof(buffer), NULL,
MAX_RETRIES); SR_TIMEOUT, MAX_RETRIES);
retries--; retries--;
...@@ -745,14 +741,8 @@ static void get_sectorsize(struct scsi_cd *cd) ...@@ -745,14 +741,8 @@ static void get_sectorsize(struct scsi_cd *cd)
queue = cd->device->request_queue; queue = cd->device->request_queue;
blk_queue_hardsect_size(queue, sector_size); blk_queue_hardsect_size(queue, sector_size);
out:
kfree(buffer);
return;
Enomem: return;
cd->capacity = 0x1fffff;
cd->device->sector_size = 2048; /* A guess, just in case */
goto out;
} }
static void get_capabilities(struct scsi_cd *cd) static void get_capabilities(struct scsi_cd *cd)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册