From nobody Fri Nov 7 03:56:42 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 154639814285735.90153696791856; Tue, 1 Jan 2019 19:02:22 -0800 (PST) Received: from localhost ([127.0.0.1]:41480 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1geWnV-0003ZD-Gu for importer@patchew.org; Tue, 01 Jan 2019 22:02:21 -0500 Received: from eggs.gnu.org ([208.118.235.92]:35861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1geWgT-0004Or-SJ for qemu-devel@nongnu.org; Tue, 01 Jan 2019 21:55:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1geWgR-0005Rg-Th for qemu-devel@nongnu.org; Tue, 01 Jan 2019 21:55:05 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:60316) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1geWgR-0005Qu-Ix for qemu-devel@nongnu.org; Tue, 01 Jan 2019 21:55:03 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 23F0E7456BA; Wed, 2 Jan 2019 03:54:43 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 9A0907456BC; Wed, 2 Jan 2019 03:54:42 +0100 (CET) Message-Id: In-Reply-To: References: From: BALATON Zoltan Date: Wed, 02 Jan 2019 03:06:38 +0100 To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:738:2001:2001::2001 Subject: [Qemu-devel] [PATCH 6/8] ppc4xx: Pass array index to function instead of pointer into the array 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: David Gibson 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" The sdram_set_bcr() function in ppc440_uc.c takes a pointer into an array then calculates its index from that. It's simpler and easier to just pass the index which simplifies both the function and its callers. Signed-off-by: BALATON Zoltan Reviewed-by: David Gibson --- hw/ppc/ppc440_uc.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/hw/ppc/ppc440_uc.c b/hw/ppc/ppc440_uc.c index e46f59fba8..60dbb35eee 100644 --- a/hw/ppc/ppc440_uc.c +++ b/hw/ppc/ppc440_uc.c @@ -564,28 +564,26 @@ static target_ulong sdram_size(uint32_t bcr) return size; } =20 -static void sdram_set_bcr(ppc440_sdram_t *sdram, - uint32_t *bcrp, uint32_t bcr, int enabled) +static void sdram_set_bcr(ppc440_sdram_t *sdram, int i, + uint32_t bcr, int enabled) { - unsigned n =3D bcrp - sdram->bcr; - - if (*bcrp & 1) { - /* Unmap RAM */ + if (sdram->bcr[i] & 1) { + /* First unmap RAM if enabled */ memory_region_del_subregion(get_system_memory(), - &sdram->containers[n]); - memory_region_del_subregion(&sdram->containers[n], - &sdram->ram_memories[n]); - object_unparent(OBJECT(&sdram->containers[n])); + &sdram->containers[i]); + memory_region_del_subregion(&sdram->containers[i], + &sdram->ram_memories[i]); + object_unparent(OBJECT(&sdram->containers[i])); } - *bcrp =3D bcr & 0xFFDEE001; + sdram->bcr[i] =3D bcr & 0xFFDEE001; if (enabled && (bcr & 1)) { - memory_region_init(&sdram->containers[n], NULL, "sdram-containers", + memory_region_init(&sdram->containers[i], NULL, "sdram-containers", sdram_size(bcr)); - memory_region_add_subregion(&sdram->containers[n], 0, - &sdram->ram_memories[n]); + memory_region_add_subregion(&sdram->containers[i], 0, + &sdram->ram_memories[i]); memory_region_add_subregion(get_system_memory(), sdram_base(bcr), - &sdram->containers[n]); + &sdram->containers[i]); } } =20 @@ -595,12 +593,10 @@ static void sdram_map_bcr(ppc440_sdram_t *sdram) =20 for (i =3D 0; i < sdram->nbanks; i++) { if (sdram->ram_sizes[i] !=3D 0) { - sdram_set_bcr(sdram, - &sdram->bcr[i], - sdram_bcr(sdram->ram_bases[i], sdram->ram_sizes[= i]), - 1); + sdram_set_bcr(sdram, i, sdram_bcr(sdram->ram_bases[i], + sdram->ram_sizes[i]), 1); } else { - sdram_set_bcr(sdram, &sdram->bcr[i], 0, 0); + sdram_set_bcr(sdram, i, 0, 0); } } } --=20 2.13.7