[scsi] Make SCSI command issuing partially asynchronous

Move the icky call to step() from iscsi.c to scsi.c; this takes it at
least one step further away from where it really doesn't belong.
This commit is contained in:
Michael Brown
2009-07-07 23:00:11 +01:00
parent 51172783e2
commit 1d8d8ef2c8
4 changed files with 33 additions and 30 deletions

View File

@@ -23,6 +23,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <byteswap.h>
#include <errno.h>
#include <gpxe/blockdev.h>
#include <gpxe/process.h>
#include <gpxe/scsi.h>
/** @file
@@ -57,11 +58,22 @@ static int scsi_command ( struct scsi_device *scsi,
/* Clear sense response code before issuing command */
command->sense_response = 0;
/* Flag command as in-progress */
command->rc = -EINPROGRESS;
/* Issue SCSI command */
if ( ( rc = scsi->command ( scsi, command ) ) != 0 ) {
/* Something went wrong with the issuing mechanism,
* (rather than with the command itself)
*/
/* Something went wrong with the issuing mechanism */
DBG ( "SCSI %p " SCSI_CDB_FORMAT " err %s\n",
scsi, SCSI_CDB_DATA ( command->cdb ), strerror ( rc ) );
return rc;
}
/* Wait for command to complete */
while ( command->rc == -EINPROGRESS )
step();
if ( ( rc = command->rc ) != 0 ) {
/* Something went wrong with the command execution */
DBG ( "SCSI %p " SCSI_CDB_FORMAT " err %s\n",
scsi, SCSI_CDB_DATA ( command->cdb ), strerror ( rc ) );
return rc;