]> nv-tegra.nvidia Code Review - linux-2.6.git/commit
libata-scsi: improve rbuf handling for simulated commands
authorTejun Heo <htejun@gmail.com>
Mon, 28 Apr 2008 08:48:51 +0000 (17:48 +0900)
committerJeff Garzik <jgarzik@redhat.com>
Tue, 29 Apr 2008 06:17:03 +0000 (02:17 -0400)
commit87340e98345155631f7a1a4d8d66cf0ab286cb1b
tree311ce808242cc06c65f976b4ce3c0c46c1110197
parentf0761be344f9b1cc4284b1d945933cd983c233a4
libata-scsi: improve rbuf handling for simulated commands

Buffer length handling in simulated commands is error-prone and full
of bugs.  There are a number of places where necessary length checks
are missing and if the output buffer is passed in as sglist, nothing
works.

This patch adds a static buffer ata_scsi_rbuf which is sufficiently
large to handle the larges output from simulated commands (4k
currently), let all simulte functions write to the buffer and removes
all length checks as we know that there always is enough buffer space.
Copying in (for ATAPI inquiry fix up) and out are handled by
sg_copy_to/from_buffer() behind ata_scsi_rbuf_get/put() interface
which handles sglist properly.

This patch is inspired from buffer length check fix patch from Petr
Vandrovec.

Updated to use sg_copy_to/from_buffer() as suggested by FUJITA
Tomonori.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Petr Vandrovec <petr@vmware.com>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
drivers/ata/libata-scsi.c