From patchwork Mon Feb 20 09:13:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 655065 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1296486wrc; Mon, 20 Feb 2023 01:29:50 -0800 (PST) X-Google-Smtp-Source: AK7set8HdN4EPdD/FUu5Wf1TMSzimN1E2ldfP6VquW8UZZCfvjx3rZLsfZp4XAW2K3TUL/dq8Kc0 X-Received: by 2002:a05:622a:494:b0:3b8:6ae9:b108 with SMTP id p20-20020a05622a049400b003b86ae9b108mr15041238qtx.27.1676885390292; Mon, 20 Feb 2023 01:29:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676885390; cv=none; d=google.com; s=arc-20160816; b=MTSdhVYmU4P5zks1H+QmHpUYZIbMCMCATOoH9Tfrop0Y6zWUJDCRef0QDBC0U1I9JP BEuMvpsHAqLUAaSsMabOrbx4C0apLd1wlQennPLRM8CYCvaqSg0YoAwrW8cZhRuzqsV3 IdI6fuzXnLklw6jKYU6y62a+7MApSUEAPXHxQ4ALU1b2gVNflg5hHl5mGLCEMTF0o9KL 3riJDAE+XJhwmUGeWevO7mvzYYdXTZ3SwcAMJfK3bWc6TGHxvwzxSVYVmuFxM8REI8p6 u8JLdmpfY3Y7glDK27Q0BEXotYDLB3sWFbBhCwWsckNGOEsARP6qZiiBAmMKWBvKkGkO ovJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JkD4ylCUPd/YYTKvkzbI+ReBZ+PYphiYSDNHJcbrxXw=; b=xBp+vgE/Ssj0AhdQa1xnPiCDssmJTzyJ8sW7ptS7/zI5qX+DvPvl/fKfa6TgWpwdjd 7zYV5qTKNONgFoQNf2VyMwJ2lIRmaFXJX3YhyqHJs7fs5qhq9ewFmlvDn0wn1kDUXeg5 51IwhO9KaN6qQvUJ4e68pIOAT5WMOCzElFF/p6AvMCNtXXhxyR4TKoMJmkGYsBLgRlUG 8raDJt+FStAtmMjFaE5Xm0h/95m0Km1AJ6b4R9FQjpEpvTnmV/VIAtr+mdCNBEN7cu2m LqdVpSSwpsF/ruzB+UhB4eBhqcMuD1duAx3RdyucDO2Z0Zhp3nSYoJu//28BCgQZ0vVG e2sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="PfUnD/Ir"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c29-20020a0ca9dd000000b0054ace222c06si1666529qvb.589.2023.02.20.01.29.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 01:29:50 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="PfUnD/Ir"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU2Ir-00020F-IV; Mon, 20 Feb 2023 04:17:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pU2H9-0007Y6-Bg for qemu-devel@nongnu.org; Mon, 20 Feb 2023 04:16:00 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pU2H7-0004MI-HV for qemu-devel@nongnu.org; Mon, 20 Feb 2023 04:15:59 -0500 Received: by mail-wm1-x332.google.com with SMTP id bg28so405092wmb.0 for ; Mon, 20 Feb 2023 01:15:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JkD4ylCUPd/YYTKvkzbI+ReBZ+PYphiYSDNHJcbrxXw=; b=PfUnD/IrABYau0XaQ92dv/4sRwiEfhCSs655lVSoDxgLHNT7XuxW50lHhSloPVQAtv 1fr80LwL0vJF0J8LuhkP1fPHzoIjiJ1yobgJMG6dEWVib21CiwKZaMe70RgXkuHxeDpt azQBqMKr8HauYTc5jsgx7neLwjcz9qQYokzmb24LcZZpu/KAGsHMQ+p1xnTAXy3csIml 4w5t13Y/eRzHzB98ZC+M4fSKRDYWLQpXx5owL7M3QrUyuhG2HkmF61VHVR5v8fopvOSc 3XylvJJkjgT3byPWzRxAovoGSHn+niHN9rvxn1iXAcpFGVVFoK0/a8I2vX/M01ulBe+c YlUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JkD4ylCUPd/YYTKvkzbI+ReBZ+PYphiYSDNHJcbrxXw=; b=rpQWMYUQZ1QeeQnlzkfjT15hSMquFXlIDWGTlSKktcNLYdhnKxDQevNYoevWJNwTgT Wy68N2ppXNI1HbA0+KqrByIjR4pKnDMPs2eIalX81MZ2id2pv2qWZEP43DGXtBB3Fg+n vA/pwUcN/xS/IXc/PmTbknHjEatV2zqQgZwGp9jyhLsvTruY+Y9StUqR3xW4/T0n4Ju2 7CE/PTT2O29dA2ariFvV5oYYuYHbWr/lrkVBGL3/WOpxfFQdG1j9Ddp5SXTezrkC3ZCe rSlcIJmqwyfP3EN0gTWJnigXLcCKZoev9CdogOYnzMQLumBFA3dk5oS9C7wZuxd3mIc5 +3aQ== X-Gm-Message-State: AO0yUKVqpKC5Q/K8bL3VCYk+U/upytjgEMEwKFfiN1nHmlJp6W3eHdvC T6m0MTtQpDE1hxsik6P3hoOUzprWnjuIk6mB X-Received: by 2002:a05:600c:706:b0:3e2:1368:e3a0 with SMTP id i6-20020a05600c070600b003e21368e3a0mr9518224wmn.18.1676884555970; Mon, 20 Feb 2023 01:15:55 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id a12-20020a05600c224c00b003dc53217e07sm13119110wmm.16.2023.02.20.01.15.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Feb 2023 01:15:55 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, John Snow , qemu-block@nongnu.org, qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v2 23/24] hw/ide/piix: Refactor pci_piix_init_ports as pci_piix_init_bus per bus Date: Mon, 20 Feb 2023 10:13:57 +0100 Message-Id: <20230220091358.17038-24-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230220091358.17038-1-philmd@linaro.org> References: <20230220091358.17038-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20230215112712.23110-21-philmd@linaro.org> Reviewed-by: Richard Henderson --- hw/ide/piix.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/hw/ide/piix.c b/hw/ide/piix.c index b74f1c77c4..acb4eaa27f 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -122,7 +122,7 @@ static void piix_ide_reset(DeviceState *dev) pci_set_byte(pci_conf + 0x20, 0x01); /* BMIBA: 20-23h */ } -static bool pci_piix_init_ports(PCIIDEState *d, Error **errp) +static bool pci_piix_init_bus(PCIIDEState *d, unsigned i, Error **errp) { static const struct { int iobase; @@ -132,24 +132,21 @@ static bool pci_piix_init_ports(PCIIDEState *d, Error **errp) {0x1f0, 0x3f6, 14}, {0x170, 0x376, 15}, }; - int i, ret; + int ret; - for (i = 0; i < 2; i++) { - ide_bus_init(&d->bus[i], sizeof(d->bus[i]), DEVICE(d), i, 2); - ret = ide_bus_init_ioport_isa(&d->bus[i], NULL, port_info[i].iobase, - port_info[i].iobase2); - if (ret) { - error_setg_errno(errp, -ret, "Failed to realize %s port %u", - object_get_typename(OBJECT(d)), i); - return false; - } - ide_bus_init_output_irq(&d->bus[i], - isa_get_irq(NULL, port_info[i].isairq)); - - bmdma_init(&d->bus[i], &d->bmdma[i], d); - d->bmdma[i].bus = &d->bus[i]; - ide_bus_register_restart_cb(&d->bus[i]); + ide_bus_init(&d->bus[i], sizeof(d->bus[i]), DEVICE(d), i, 2); + ret = ide_bus_init_ioport_isa(&d->bus[i], NULL, + port_info[i].iobase, port_info[i].iobase2); + if (ret) { + error_setg_errno(errp, -ret, "Failed to realize %s port %u", + object_get_typename(OBJECT(d)), i); + return false; } + ide_bus_init_output_irq(&d->bus[i], isa_get_irq(NULL, port_info[i].isairq)); + + bmdma_init(&d->bus[i], &d->bmdma[i], d); + d->bmdma[i].bus = &d->bus[i]; + ide_bus_register_restart_cb(&d->bus[i]); return true; } @@ -166,8 +163,10 @@ static void pci_piix_ide_realize(PCIDevice *dev, Error **errp) vmstate_register(VMSTATE_IF(dev), 0, &vmstate_ide_pci, d); - if (!pci_piix_init_ports(d, errp)) { - return; + for (unsigned i = 0; i < 2; i++) { + if (!pci_piix_init_bus(d, i, errp)) { + return; + } } }