From patchwork Thu Oct 17 03:53:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rusty Russell X-Patchwork-Id: 284077 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A64712C00B6 for ; Thu, 17 Oct 2013 15:01:44 +1100 (EST) Received: from localhost ([::1]:50225 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWemM-0002Xo-L6 for incoming@patchwork.ozlabs.org; Thu, 17 Oct 2013 00:01:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59629) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWejj-0007ab-Jn for qemu-devel@nongnu.org; Wed, 16 Oct 2013 23:59:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VWeji-0001Er-Lt for qemu-devel@nongnu.org; Wed, 16 Oct 2013 23:58:59 -0400 Received: from ozlabs.org ([2402:b800:7003:1:1::1]:33238) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWeji-0001Ec-29 for qemu-devel@nongnu.org; Wed, 16 Oct 2013 23:58:58 -0400 Received: by ozlabs.org (Postfix, from userid 1011) id E5EF32C00DC; Thu, 17 Oct 2013 14:58:50 +1100 (EST) From: Rusty Russell To: "Marc Zyngier" , qemu-devel@nongnu.org Date: Thu, 17 Oct 2013 14:23:41 +1030 Message-Id: <1381982022-19291-7-git-send-email-rusty@rustcorp.com.au> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1381982022-19291-1-git-send-email-rusty@rustcorp.com.au> References: <1381982022-19291-1-git-send-email-rusty@rustcorp.com.au> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2402:b800:7003:1:1::1 Cc: Rusty Russell Subject: [Qemu-devel] [PATCH 6/7] hw/scsi/virtio-scsi: use virtio wrappers to access headers. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Note that st*_raw and ld*_raw are effectively replaced by st*_p and ld*_p. Signed-off-by: Rusty Russell Reviewed-by: Anthony Liguori --- hw/scsi/virtio-scsi.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 26d95a1..e581dd0 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -18,6 +18,7 @@ #include #include #include +#include "hw/virtio/virtio-access.h" typedef struct VirtIOSCSIReq { VirtIOSCSI *dev; @@ -309,12 +310,12 @@ static void virtio_scsi_command_complete(SCSIRequest *r, uint32_t status, req->resp.cmd->response = VIRTIO_SCSI_S_OK; req->resp.cmd->status = status; if (req->resp.cmd->status == GOOD) { - req->resp.cmd->resid = tswap32(resid); + req->resp.cmd->resid = virtio_tswap32(resid); } else { req->resp.cmd->resid = 0; sense_len = scsi_req_get_sense(r, req->resp.cmd->sense, VIRTIO_SCSI_SENSE_SIZE); - req->resp.cmd->sense_len = tswap32(sense_len); + req->resp.cmd->sense_len = virtio_tswap32(sense_len); } virtio_scsi_complete_req(req); } @@ -410,16 +411,16 @@ static void virtio_scsi_get_config(VirtIODevice *vdev, VirtIOSCSIConfig *scsiconf = (VirtIOSCSIConfig *)config; VirtIOSCSICommon *s = VIRTIO_SCSI_COMMON(vdev); - stl_raw(&scsiconf->num_queues, s->conf.num_queues); - stl_raw(&scsiconf->seg_max, 128 - 2); - stl_raw(&scsiconf->max_sectors, s->conf.max_sectors); - stl_raw(&scsiconf->cmd_per_lun, s->conf.cmd_per_lun); - stl_raw(&scsiconf->event_info_size, sizeof(VirtIOSCSIEvent)); - stl_raw(&scsiconf->sense_size, s->sense_size); - stl_raw(&scsiconf->cdb_size, s->cdb_size); - stw_raw(&scsiconf->max_channel, VIRTIO_SCSI_MAX_CHANNEL); - stw_raw(&scsiconf->max_target, VIRTIO_SCSI_MAX_TARGET); - stl_raw(&scsiconf->max_lun, VIRTIO_SCSI_MAX_LUN); + virtio_stl_p(&scsiconf->num_queues, s->conf.num_queues); + virtio_stl_p(&scsiconf->seg_max, 128 - 2); + virtio_stl_p(&scsiconf->max_sectors, s->conf.max_sectors); + virtio_stl_p(&scsiconf->cmd_per_lun, s->conf.cmd_per_lun); + virtio_stl_p(&scsiconf->event_info_size, sizeof(VirtIOSCSIEvent)); + virtio_stl_p(&scsiconf->sense_size, s->sense_size); + virtio_stl_p(&scsiconf->cdb_size, s->cdb_size); + virtio_stw_p(&scsiconf->max_channel, VIRTIO_SCSI_MAX_CHANNEL); + virtio_stw_p(&scsiconf->max_target, VIRTIO_SCSI_MAX_TARGET); + virtio_stl_p(&scsiconf->max_lun, VIRTIO_SCSI_MAX_LUN); } static void virtio_scsi_set_config(VirtIODevice *vdev, @@ -428,14 +429,14 @@ static void virtio_scsi_set_config(VirtIODevice *vdev, VirtIOSCSIConfig *scsiconf = (VirtIOSCSIConfig *)config; VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(vdev); - if ((uint32_t) ldl_raw(&scsiconf->sense_size) >= 65536 || - (uint32_t) ldl_raw(&scsiconf->cdb_size) >= 256) { + if ((uint32_t) virtio_ldl_p(&scsiconf->sense_size) >= 65536 || + (uint32_t) virtio_ldl_p(&scsiconf->cdb_size) >= 256) { error_report("bad data written to virtio-scsi configuration space"); exit(1); } - vs->sense_size = ldl_raw(&scsiconf->sense_size); - vs->cdb_size = ldl_raw(&scsiconf->cdb_size); + vs->sense_size = virtio_ldl_p(&scsiconf->sense_size); + vs->cdb_size = virtio_ldl_p(&scsiconf->cdb_size); } static uint32_t virtio_scsi_get_features(VirtIODevice *vdev,