From nobody Fri Nov 7 17:09:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548454504304490.1989707981372; Fri, 25 Jan 2019 14:15:04 -0800 (PST) Received: from localhost ([127.0.0.1]:51417 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gn9kb-0002bX-Ar for importer@patchew.org; Fri, 25 Jan 2019 17:15:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gn9co-0005Gd-V2 for qemu-devel@nongnu.org; Fri, 25 Jan 2019 17:07:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gn9cn-0006dk-OR for qemu-devel@nongnu.org; Fri, 25 Jan 2019 17:06:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43116) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gn9cm-0006aO-2f for qemu-devel@nongnu.org; Fri, 25 Jan 2019 17:06:56 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CC8D75A1FB; Fri, 25 Jan 2019 22:06:54 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-168.bos.redhat.com [10.18.17.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4137B61520; Fri, 25 Jan 2019 22:06:54 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org Date: Fri, 25 Jan 2019 17:06:45 -0500 Message-Id: <20190125220648.28164-6-jsnow@redhat.com> In-Reply-To: <20190125220648.28164-1-jsnow@redhat.com> References: <20190125220648.28164-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 25 Jan 2019 22:06:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/8] sii3112: Remove duplicated code and use PCI IDE ops instead X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: BALATON Zoltan Parts of the SiI3112 mmio are identical to PCI IDE registers so we can use the corresponding functions that were factored out into ide/pci.c. This removes code duplication and simplifies the SiI3112 model which also helped to spot a copy paste error where reading status of the 2nd channel read the 1st channel instead. This is also fixed here. Signed-off-by: BALATON Zoltan Tested-by: Mark Cave-Ayland Reviewed-by: John Snow Message-id: 793b6a7934ef2bba26b8d066bec446019efa6c5d.1547166960.git.balaton= @eik.bme.hu Signed-off-by: John Snow --- hw/ide/sii3112.c | 52 ++++++++---------------------------------------- 1 file changed, 8 insertions(+), 44 deletions(-) diff --git a/hw/ide/sii3112.c b/hw/ide/sii3112.c index 743a50ed51..59db09cfe4 100644 --- a/hw/ide/sii3112.c +++ b/hw/ide/sii3112.c @@ -88,35 +88,19 @@ static uint64_t sii3112_reg_read(void *opaque, hwaddr a= ddr, val |=3D (uint32_t)d->i.bmdma[1].status << 16; break; case 0x80 ... 0x87: - if (size =3D=3D 1) { - val =3D ide_ioport_read(&d->i.bus[0], addr - 0x80); - } else if (addr =3D=3D 0x80) { - val =3D (size =3D=3D 2) ? ide_data_readw(&d->i.bus[0], 0) : - ide_data_readl(&d->i.bus[0], 0); - } else { - val =3D (1ULL << (size * 8)) - 1; - } + val =3D pci_ide_data_le_ops.read(&d->i.bus[0], addr - 0x80, size); break; case 0x8a: - val =3D (size =3D=3D 1) ? ide_status_read(&d->i.bus[0], 4) : - (1ULL << (size * 8)) - 1; + val =3D pci_ide_cmd_le_ops.read(&d->i.bus[0], 2, size); break; case 0xa0: val =3D d->regs[0].confstat; break; case 0xc0 ... 0xc7: - if (size =3D=3D 1) { - val =3D ide_ioport_read(&d->i.bus[1], addr - 0xc0); - } else if (addr =3D=3D 0xc0) { - val =3D (size =3D=3D 2) ? ide_data_readw(&d->i.bus[1], 0) : - ide_data_readl(&d->i.bus[1], 0); - } else { - val =3D (1ULL << (size * 8)) - 1; - } + val =3D pci_ide_data_le_ops.read(&d->i.bus[1], addr - 0xc0, size); break; case 0xca: - val =3D (size =3D=3D 1) ? ide_status_read(&d->i.bus[0], 4) : - (1ULL << (size * 8)) - 1; + val =3D pci_ide_cmd_le_ops.read(&d->i.bus[1], 2, size); break; case 0xe0: val =3D d->regs[1].confstat; @@ -186,36 +170,16 @@ static void sii3112_reg_write(void *opaque, hwaddr ad= dr, bmdma_addr_ioport_ops.write(&d->i.bmdma[1], addr - 12, val, size); break; case 0x80 ... 0x87: - if (size =3D=3D 1) { - ide_ioport_write(&d->i.bus[0], addr - 0x80, val); - } else if (addr =3D=3D 0x80) { - if (size =3D=3D 2) { - ide_data_writew(&d->i.bus[0], 0, val); - } else { - ide_data_writel(&d->i.bus[0], 0, val); - } - } + pci_ide_data_le_ops.write(&d->i.bus[0], addr - 0x80, val, size); break; case 0x8a: - if (size =3D=3D 1) { - ide_cmd_write(&d->i.bus[0], 4, val); - } + pci_ide_cmd_le_ops.write(&d->i.bus[0], 2, val, size); break; case 0xc0 ... 0xc7: - if (size =3D=3D 1) { - ide_ioport_write(&d->i.bus[1], addr - 0xc0, val); - } else if (addr =3D=3D 0xc0) { - if (size =3D=3D 2) { - ide_data_writew(&d->i.bus[1], 0, val); - } else { - ide_data_writel(&d->i.bus[1], 0, val); - } - } + pci_ide_data_le_ops.write(&d->i.bus[1], addr - 0xc0, val, size); break; case 0xca: - if (size =3D=3D 1) { - ide_cmd_write(&d->i.bus[1], 4, val); - } + pci_ide_cmd_le_ops.write(&d->i.bus[1], 2, val, size); break; case 0x100: d->regs[0].scontrol =3D val & 0xfff; --=20 2.17.2