Convert all open-coded hba_private = NULL + scsi_req_unref() pairs to scsi_req_unref_detach_hba().
Signed-off-by: Michael S. Tsirkin <[email protected]> --- hw/scsi/megasas.c | 3 +-- hw/scsi/mptsas.c | 3 +-- hw/scsi/ncr53c710.c | 6 ++---- hw/scsi/virtio-scsi.c | 3 +-- hw/ufs/lu.c | 3 +-- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index 9e712721f8..d64d39706b 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -599,8 +599,7 @@ static void megasas_complete_command(MegasasCmd *cmd) cmd->iov_size = 0; cmd->iov_offset = 0; - cmd->req->hba_private = NULL; - scsi_req_unref(cmd->req); + scsi_req_unref_detach_hba(cmd->req); cmd->req = NULL; megasas_unmap_frame(cmd->state, cmd); diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c index 5df124c0ce..6da8a740f3 100644 --- a/hw/scsi/mptsas.c +++ b/hw/scsi/mptsas.c @@ -260,8 +260,7 @@ static int mptsas_build_sgl(MPTSASState *s, MPTSASRequest *req, hwaddr req_addr) static void mptsas_free_request(MPTSASRequest *req) { if (req->sreq != NULL) { - req->sreq->hba_private = NULL; - scsi_req_unref(req->sreq); + scsi_req_unref_detach_hba(req->sreq); req->sreq = NULL; } qemu_sglist_destroy(&req->qsg); diff --git a/hw/scsi/ncr53c710.c b/hw/scsi/ncr53c710.c index 57967e7a84..b3345a43c2 100644 --- a/hw/scsi/ncr53c710.c +++ b/hw/scsi/ncr53c710.c @@ -756,11 +756,10 @@ void ncr710_request_cancelled(SCSIRequest *req) NCR710State *s = ncr710_from_scsi_bus(req->bus); NCR710Request *p = (NCR710Request *)req->hba_private; if (p) { - req->hba_private = NULL; p->req = NULL; ncr710_request_free(s, p); } - scsi_req_unref(req); + scsi_req_unref_detach_hba(req); } static int ncr710_queue_req(NCR710State *s, SCSIRequest *req, uint32_t len) @@ -801,13 +800,12 @@ void ncr710_command_complete(SCSIRequest *req, size_t resid) ncr710_set_phase(s, PHASE_ST); if (p) { - req->hba_private = NULL; if (p == s->current) { p->req = NULL; } else { ncr710_request_free(s, p); } - scsi_req_unref(req); + scsi_req_unref_detach_hba(req); } if (s->waiting == NCR710_WAIT_RESELECT || s->waiting == NCR710_WAIT_DMA) { diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index bf64d1231a..53c3c88460 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -123,8 +123,7 @@ static void virtio_scsi_complete_req(VirtIOSCSIReq *req, QemuMutex *vq_lock) } if (req->sreq) { - req->sreq->hba_private = NULL; - scsi_req_unref(req->sreq); + scsi_req_unref_detach_hba(req->sreq); } virtio_scsi_free_req(req); } diff --git a/hw/ufs/lu.c b/hw/ufs/lu.c index 13f4a90145..b2c2cadf7e 100644 --- a/hw/ufs/lu.c +++ b/hw/ufs/lu.c @@ -184,8 +184,7 @@ static void ufs_scsi_command_complete(SCSIRequest *scsi_req, size_t resid) ufs_complete_req(req, UFS_REQUEST_SUCCESS); - scsi_req->hba_private = NULL; - scsi_req_unref(scsi_req); + scsi_req_unref_detach_hba(scsi_req); } static QEMUSGList *ufs_get_sg_list(SCSIRequest *scsi_req) -- MST
