From nobody Fri Jun 7 00:35:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639826358; cv=none; d=zohomail.com; s=zohoarc; b=M/MPUnzCeyqQ2db/dfYL6/LbQ9Y++9fg5jC9VyRBUQQkmdPOAY83Xz8zlzvHPfqR3TRCcEuFKG7+cKByLzuPW4T5XqU+JDrAK/2pPR88McN3ozc6JHeJCqgAJhnB/6x+y1cRnuer0Gy/DE3fcZ6EWnYe7cQcbxAouSWBveNc+8M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639826358; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=xlpdcFiKk+QT53vi6eV0nYkKCyVWkrxaOucCuxeBwmg=; b=QoywPfVe2q+jCI02Xk8Cq6SsgaWedVPR8HD5pMP8pQ85I/djBf7EF3m7Ju7xRhEJC4TTnv7XSCr4SnBe4iC3cWUmrF0QQ1O0y4vZmqOvg126RHIz2Rjsb23WQ4FBre0LNbKh3xXI9vJW2w99rXVfoT7C5ah69sh4Aq4l3Z5m5oE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1639826358921881.8664548986203; Sat, 18 Dec 2021 03:19:18 -0800 (PST) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-500-XkGk3tv2P7i_aaaJvg2HqQ-1; Sat, 18 Dec 2021 06:19:16 -0500 Received: by mail-wm1-f72.google.com with SMTP id z199-20020a1c7ed0000000b003456affcffaso4338539wmc.2 for ; Sat, 18 Dec 2021 03:19:15 -0800 (PST) Return-Path: Return-Path: Received: from x1w.. (174.red-83-50-185.dynamicip.rima-tde.net. [83.50.185.174]) by smtp.gmail.com with ESMTPSA id u14sm10434757wrf.39.2021.12.18.03.19.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Dec 2021 03:19:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639826357; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xlpdcFiKk+QT53vi6eV0nYkKCyVWkrxaOucCuxeBwmg=; b=CP466IRGS6hjgKkDOefX0OrjShlKSfx9tXbA/jfaeuFre6g/scXzEFEoCb4fguZ0dCyrk0 M+Liipfu+RfDqSqBX1zuq9sd77zurE35PemTejJ8VdnUROv93PeVqf50S3+VZpMA5YU8tM +IgOWRB9L9AQz8QAreLwExtxjiiLo40= X-MC-Unique: XkGk3tv2P7i_aaaJvg2HqQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xlpdcFiKk+QT53vi6eV0nYkKCyVWkrxaOucCuxeBwmg=; b=i98opP4L0vvRM4aA+Xuhf1utrUK5/RCEeh+j+puv0RIWCSgVqRsEXha+TBmE22GiCO y+61t61xx5B9HQ2Gi9nQZouPrEstNQ3AA5eJ9kY1a5Gbi3mD2NrYJdUWvYfaqPvjPGst qEIuQGkBGTSsbFoDks7YE2BPcNGWuI15wNd1FN/xKimsw6UwJrrfOD+oKwSjgu+H47+F e7euZ8vWmZFChpvmUHvWBUSjCZz/FGmyCusZHWCyf+wRpN4AR6rXfDCZI3hu5UzuCfbR +oSEKbB0QEBZUZIS4J8TU825rcvx3IMpaquXEqDkF2cVX8wuXkSLBH9yPYzoiPvDfTxr e6lA== X-Gm-Message-State: AOAM533PzImoHvj2Ml8mg1oMUTEUYB65KM3G1xMLqTQPtzA2hOD5CNk5 bPv04SX3BJl4ooqdACwdPB2qr1w4McmDcg1EHxxyY0s/E/GCnUamncRUrDxuluc2pfSK4Vyi+EE CDZOeVN+A+IMZaQ== X-Received: by 2002:a05:600c:3d90:: with SMTP id bi16mr4670622wmb.42.1639826355008; Sat, 18 Dec 2021 03:19:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJywNiLYL4XiRs6jKG961HFnh3L4l5Y+ZVNwOXIRqTU1obt1gblcMdPWQrWhrwLGY+H7ercVLw== X-Received: by 2002:a05:600c:3d90:: with SMTP id bi16mr4670607wmb.42.1639826354829; Sat, 18 Dec 2021 03:19:14 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Paolo Bonzini , Hannes Reinecke , qemu-trivial@nongnu.org, Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v2] hw/scsi/megasas: Simplify using the ldst API Date: Sat, 18 Dec 2021 12:19:12 +0100 Message-Id: <20211218111912.1499377-1-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639826361414100001 This code is easier to review using the load/store API. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- v2: Fixed offset in megasas_setup_inquiry (rth) --- hw/scsi/megasas.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index 619b66ef0f3..9a4e9ba87e6 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -375,8 +375,7 @@ static int megasas_setup_inquiry(uint8_t *cdb, int pg, = int len) cdb[1] =3D 0x1; cdb[2] =3D pg; } - cdb[3] =3D (len >> 8) & 0xff; - cdb[4] =3D (len & 0xff); + stw_be_p(&cdb[3], len); return len; } =20 @@ -392,18 +391,8 @@ static void megasas_encode_lba(uint8_t *cdb, uint64_t = lba, } else { cdb[0] =3D READ_16; } - cdb[2] =3D (lba >> 56) & 0xff; - cdb[3] =3D (lba >> 48) & 0xff; - cdb[4] =3D (lba >> 40) & 0xff; - cdb[5] =3D (lba >> 32) & 0xff; - cdb[6] =3D (lba >> 24) & 0xff; - cdb[7] =3D (lba >> 16) & 0xff; - cdb[8] =3D (lba >> 8) & 0xff; - cdb[9] =3D (lba) & 0xff; - cdb[10] =3D (len >> 24) & 0xff; - cdb[11] =3D (len >> 16) & 0xff; - cdb[12] =3D (len >> 8) & 0xff; - cdb[13] =3D (len) & 0xff; + stq_be_p(&cdb[2], lba); + stl_be_p(&cdb[2 + 8], len); } =20 /* --=20 2.33.1