From patchwork Mon Feb 27 14:02:06 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: 657077 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp2381139wrb; Mon, 27 Feb 2023 06:28:25 -0800 (PST) X-Google-Smtp-Source: AK7set/a5WGbikHt0pOC3MYI83TexyO5cKJJwVewKxl3tsSqaDBACn9KrgngXvMR10uJ7khbMqrc X-Received: by 2002:a05:6214:20eb:b0:570:bf43:499 with SMTP id 11-20020a05621420eb00b00570bf430499mr43383929qvk.9.1677508105066; Mon, 27 Feb 2023 06:28:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677508105; cv=none; d=google.com; s=arc-20160816; b=rbtpvu5G2tTfh83AF1fn+wcsN6NB/pwLMbb9xz1Qnd0GckiDl9LbMtw8SBcbkVQirV 51ezmtuwndh9PtVFWbLAo4GbgYbM2MLCadWcDs7tB9hGYkRyntc6T3OxwWeJQoOrmvqP dZQdLlHYFk5MMvVI95p6yc8JNVUZTO/ay72X5CSwPJRV26edcbYtLocvCnyxyurmoljO Z2lzdpaB/D7vHmZWYx9MTwy5L/Un4PCphLfcl6cC/mBeDYhn6lRbzw0RmWWcKxSfF13o 4BNmE6L+msI+fWeQzp5j7BRUVsf8mvb7Kf08VRkOvJapNyY2ADWG/yPrkJJaYs/DQt1b Fukw== 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:to:from :dkim-signature; bh=uyj2N1V5KX2b0ID+h6AUIAfOe3fyRF4wROR42WY2Q44=; b=i9gHCnViwWWR7LpMMSgGj+cXL5IERDr1hgDTZyZJJcC2yRKLNl6bo3f2vyGsBy4TFU +9GEcTcwgFWVZeA7olVeih6UfRysL+Uld1xPBPTEM5JTbo+Dltq0fUAu6lNKLqk7i0Ww zFQP6+OcSix6A0zkNN5yJV+a5BEr2TLb0sBN2xvLui81nbyQVQCB1tj5TQXYl73m3QIg dKOtk15DT3RINHvWwQygscqqIIWAcIE6exB12tZRDEsDeeigs9qEvZFCW40jC40eeMxy 2aZzRUT3xJZFnYNUlYNfYRoryxk/GYc8xKF/lbmZyMtxlatf8wojsHiMAK3K2wxZjOnp Ttsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="AsNa9WX/"; 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 k1-20020a0cf581000000b0056ec16234f8si6417348qvm.350.2023.02.27.06.28.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Feb 2023 06:28:25 -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="AsNa9WX/"; 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 1pWeFY-0003dG-E3; Mon, 27 Feb 2023 09:13:08 -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 1pWeF2-0000Y7-Ol for qemu-devel@nongnu.org; Mon, 27 Feb 2023 09:12:36 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pWeEc-0001CS-KX for qemu-devel@nongnu.org; Mon, 27 Feb 2023 09:12:11 -0500 Received: by mail-wr1-x429.google.com with SMTP id j2so6355919wrh.9 for ; Mon, 27 Feb 2023 06:12:10 -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:to:from:from:to:cc:subject:date:message-id :reply-to; bh=uyj2N1V5KX2b0ID+h6AUIAfOe3fyRF4wROR42WY2Q44=; b=AsNa9WX/16QecpF96hurnU10OuXV4myfnh9bWP44tyseaErE6ppuW0Dh59PBJO5cp2 SlnCf8bpcJfCD6ugO+PkxBTbksTDDvtP7VOy8k7QuHt8ClVukfC4h5txuXr5HqT07dCK 2TCsizl9Q4kF8Z9y7m0QdzeYBEsWuwsGR1UoTv49ji7SEvjBH44oReztAGmnX/izC4+d 2PG2Aj7M86Fa7xiaNcpxeVbHKmWtCKrdUB3tNjrlvNyFo6qhTPG9pD4StoQcRMnJzz81 ix2PrPL2FG3VH5kgUovp+fFxHLLkpDox6+m1bVc7dW04hIKvsIV5hB+0Iukzo7Cmwfb2 dfzA== 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:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uyj2N1V5KX2b0ID+h6AUIAfOe3fyRF4wROR42WY2Q44=; b=M4LD0qImeNBePZJ8hjPeAfH3Acg+EmRo7NPpXZn+VwCb8MDvw1XyvCjmFpw7PJDA3f OvXF9KvNLOo0/T7gcz7sNLnpT5PNrF3eEBITcs84USrn6tok2DfToN81dFSaL6u0yVYJ YuWYsXyDZn8n/SMP90dKZH/K4xK+Vf9T0G9TEYRX3PM7K4FgU9SMHYg0sCxg7dOzNl1B Huq1+Rdx9E/XNK+uYt2pIPp4GWcyo0Kayr674M2o1V+0ZP7o0omTRYfippr7u34mZKyV AF1GI+I9N4WxoRMLInV1fCDQlet+bJKcPTCSBu+4bFi4GEC4iG2qMgeEKFZUXiC50j1d 3AYg== X-Gm-Message-State: AO0yUKVnWbIdmZ2AtembPtvTYRW+rL6BxLaE7nBE95eqgrWoQrmofr9e AePBf/+YS27otqko3xm2uwoTbN47cVCN9Ul5 X-Received: by 2002:a5d:5e8c:0:b0:2c3:d707:7339 with SMTP id ck12-20020a5d5e8c000000b002c3d7077339mr6942335wrb.6.1677507129727; Mon, 27 Feb 2023 06:12:09 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id n7-20020a5d4c47000000b002c5534db60bsm7088284wrt.71.2023.02.27.06.12.09 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 27 Feb 2023 06:12:09 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 119/126] hw/ide/via: Replace magic 2 value by ARRAY_SIZE / MAX_IDE_DEVS Date: Mon, 27 Feb 2023 15:02:06 +0100 Message-Id: <20230227140213.35084-110-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230227140213.35084-1-philmd@linaro.org> References: <20230227140213.35084-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.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=ham 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 From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Acked-by: John Snow Message-Id: <20210511041848.2743312-5-f4bug@amsat.org> Signed-off-by: Philippe Mathieu-Daudé --- hw/ide/via.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/ide/via.c b/hw/ide/via.c index ab9e43e244..177baea9a7 100644 --- a/hw/ide/via.c +++ b/hw/ide/via.c @@ -90,7 +90,7 @@ static void bmdma_setup_bar(PCIIDEState *d) int i; memory_region_init(&d->bmdma_bar, OBJECT(d), "via-bmdma-container", 16); - for(i = 0;i < 2; i++) { + for (i = 0; i < ARRAY_SIZE(d->bmdma); i++) { BMDMAState *bm = &d->bmdma[i]; memory_region_init_io(&bm->extra_io, OBJECT(d), &via_bmdma_ops, bm, @@ -122,7 +122,7 @@ static void via_ide_reset(DeviceState *dev) uint8_t *pci_conf = pd->config; int i; - for (i = 0; i < 2; i++) { + for (i = 0; i < ARRAY_SIZE(d->bus); i++) { ide_bus_reset(&d->bus[i]); } @@ -188,9 +188,9 @@ static void via_ide_realize(PCIDevice *dev, Error **errp) bmdma_setup_bar(d); pci_register_bar(dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &d->bmdma_bar); - qdev_init_gpio_in(ds, via_ide_set_irq, 2); - for (i = 0; i < 2; i++) { - ide_bus_init(&d->bus[i], sizeof(d->bus[i]), ds, i, 2); + qdev_init_gpio_in(ds, via_ide_set_irq, ARRAY_SIZE(d->bus)); + for (i = 0; i < ARRAY_SIZE(d->bus); i++) { + ide_bus_init(&d->bus[i], sizeof(d->bus[i]), ds, i, MAX_IDE_DEVS); ide_bus_init_output_irq(&d->bus[i], qdev_get_gpio_in(ds, i)); bmdma_init(&d->bus[i], &d->bmdma[i], d); @@ -204,7 +204,7 @@ static void via_ide_exitfn(PCIDevice *dev) PCIIDEState *d = PCI_IDE(dev); unsigned i; - for (i = 0; i < 2; ++i) { + for (i = 0; i < ARRAY_SIZE(d->bmdma); ++i) { memory_region_del_subregion(&d->bmdma_bar, &d->bmdma[i].extra_io); memory_region_del_subregion(&d->bmdma_bar, &d->bmdma[i].addr_ioport); }