scsi: move status to SCSIRequest.

Also add and use the scsi_req_complete() helper function for calling the
completion callback.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Gerd Hoffmann 2009-11-26 15:34:00 +01:00 committed by Anthony Liguori
parent 251882b7e4
commit ed3a34a3c8
4 changed files with 27 additions and 15 deletions

View file

@ -88,30 +88,28 @@ static void scsi_command_complete(void *opaque, int ret)
{
SCSIGenericReq *r = (SCSIGenericReq *)opaque;
SCSIGenericState *s = DO_UPCAST(SCSIGenericState, qdev, r->req.dev);
uint32_t tag;
int status;
s->driver_status = r->io_header.driver_status;
if (s->driver_status & SG_ERR_DRIVER_SENSE)
s->senselen = r->io_header.sb_len_wr;
if (ret != 0)
status = BUSY << 1;
r->req.status = BUSY << 1;
else {
if (s->driver_status & SG_ERR_DRIVER_TIMEOUT) {
status = BUSY << 1;
r->req.status = BUSY << 1;
BADF("Driver Timeout\n");
} else if (r->io_header.status)
status = r->io_header.status;
r->req.status = r->io_header.status;
else if (s->driver_status & SG_ERR_DRIVER_SENSE)
status = CHECK_CONDITION << 1;
r->req.status = CHECK_CONDITION << 1;
else
status = GOOD << 1;
r->req.status = GOOD << 1;
}
DPRINTF("Command complete 0x%p tag=0x%x status=%d\n",
r, r->req.tag, status);
tag = r->req.tag;
r->req.bus->complete(r->req.bus, SCSI_REASON_DONE, tag, status);
r, r->req.tag, r->req.status);
scsi_req_complete(&r->req);
scsi_remove_request(r);
}