diff options
author | Michael Brown | 2009-07-08 00:00:11 +0200 |
---|---|---|
committer | Michael Brown | 2009-07-18 00:00:09 +0200 |
commit | 1d8d8ef2c8e6bd951416941a42e3e6302238330a (patch) | |
tree | 521e7ff15194ef417bb99f941fb3f200af349a29 /src/drivers/block/scsi.c | |
parent | [debug] Use a delimiter to break up DBG_HD() output (diff) | |
download | ipxe-1d8d8ef2c8e6bd951416941a42e3e6302238330a.tar.gz ipxe-1d8d8ef2c8e6bd951416941a42e3e6302238330a.tar.xz ipxe-1d8d8ef2c8e6bd951416941a42e3e6302238330a.zip |
[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.
Diffstat (limited to 'src/drivers/block/scsi.c')
-rw-r--r-- | src/drivers/block/scsi.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/drivers/block/scsi.c b/src/drivers/block/scsi.c index 5431233f..d6511c97 100644 --- a/src/drivers/block/scsi.c +++ b/src/drivers/block/scsi.c @@ -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; |