From nobody Sun Nov 24 05:37:08 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB40413A26F for ; Wed, 6 Nov 2024 21:26:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730928404; cv=none; b=K9W2BWaAEV1n7CCvUilgG/zf0tXlMJmKrPR1ZqH4oEYARrxCDxLlwrsFbOH64a57Ft4uXOMV6wwgWWqdxTQYcm4ULEsgMhLxgmurqhwjZ/xudpzbS5ynsEr1Sl3RX+52UEm/zB8FyjzQqkBYF2EMdJUO+LUNHX9x3qxKMgGZt4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730928404; c=relaxed/simple; bh=LHBtxJhLBykWSxx00mtqWlXXjjjtzn2Hz6+h64j7m6A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ADV2gqJsFtKrpi3mMsZjkeqRcRiSz7vrC7VwYUHr/VnBg6oiDPZNAMUirDPFvvUrCA+48+REUPs6tp9Dt7CsVFmCX/smKOsND40lwLcYPRZu/oenb2wrmqxo8fVfwIxISAWYLteopinwPpVCHUop1peq3MWjr+DUIuX/DJOkmJ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=T7v38/3y; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="T7v38/3y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47FE7C4CEC6; Wed, 6 Nov 2024 21:26:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730928403; bh=LHBtxJhLBykWSxx00mtqWlXXjjjtzn2Hz6+h64j7m6A=; h=From:To:Cc:Subject:Date:From; b=T7v38/3yK0uSWHnVsgInKyiUPs+SoGDfDPS9DuPtSPQ3dGIA8wEZtXFqy8s6jRAL1 Ak7OmesWGEaHpDhd8mXGc0RjoTFXacEY5YbTl3raPkiit9zeH07hIdh2NMuoiRGOF6 aikkXNa/qOM5zRMj1a1TnU+/gdpO+OPCDE4Ft/buVRDMTXQ9Ga1xx8RqSmhxADC29n DuvGFUz2L0vYfYTAezQnErDB3Tl8Pl9CLkEQDkAxkdcpyF+zwGoShooHBpoCgeKy94 AhuXpGKLgCkR2noXIOCI1jiIr2DaeMmTGXzAcLypbbV7aE0O87GO2Z8sWVF2MkfkSa Qi6xIiNF6Oyng== From: "Rob Herring (Arm)" To: Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Madhavan Srinivasan Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH] powerpc: 44x: Use for_each_of_range() iterator Date: Wed, 6 Nov 2024 15:26:39 -0600 Message-ID: <20241106212640.341677-1-robh@kernel.org> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Simplify the ppc44x PCI dma-ranges parsing to use the for_each_of_range() iterator. Signed-off-by: Rob Herring (Arm) --- arch/powerpc/platforms/44x/pci.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/platforms/44x/pci.c b/arch/powerpc/platforms/44x/= pci.c index db6d33ca753f..364aeb86ab64 100644 --- a/arch/powerpc/platforms/44x/pci.c +++ b/arch/powerpc/platforms/44x/pci.c @@ -94,10 +94,8 @@ static int __init ppc4xx_parse_dma_ranges(struct pci_con= troller *hose, struct resource *res) { u64 size; - const u32 *ranges; - int rlen; - int pna =3D of_n_addr_cells(hose->dn); - int np =3D pna + 5; + struct of_range_parser parser; + struct of_range range; =20 /* Default */ res->start =3D 0; @@ -105,18 +103,15 @@ static int __init ppc4xx_parse_dma_ranges(struct pci_= controller *hose, res->end =3D size - 1; res->flags =3D IORESOURCE_MEM | IORESOURCE_PREFETCH; =20 - /* Get dma-ranges property */ - ranges =3D of_get_property(hose->dn, "dma-ranges", &rlen); - if (ranges =3D=3D NULL) + if (of_pci_dma_range_parser_init(&parser, hose->dn)) goto out; =20 - /* Walk it */ - while ((rlen -=3D np * 4) >=3D 0) { - u32 pci_space =3D ranges[0]; - u64 pci_addr =3D of_read_number(ranges + 1, 2); - u64 cpu_addr =3D of_translate_dma_address(hose->dn, ranges + 3); - size =3D of_read_number(ranges + pna + 3, 2); - ranges +=3D np; + for_each_of_range(&parser, &range) { + u32 pci_space =3D range.flags; + u64 pci_addr =3D range.bus_addr; + u64 cpu_addr =3D range.cpu_addr; + size =3D range.size; + if (cpu_addr =3D=3D OF_BAD_ADDR || size =3D=3D 0) continue; =20 --=20 2.45.2