From nobody Mon Feb 9 19:26:43 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 143D4C77B60 for ; Tue, 28 Mar 2023 20:16:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229879AbjC1UQ1 (ORCPT ); Tue, 28 Mar 2023 16:16:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229806AbjC1UQS (ORCPT ); Tue, 28 Mar 2023 16:16:18 -0400 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 823653C3F; Tue, 28 Mar 2023 13:16:17 -0700 (PDT) Received: by mail-oi1-f179.google.com with SMTP id bi31so9932108oib.9; Tue, 28 Mar 2023 13:16:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680034577; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VpsM8Gyt+E2oU3DAGA2Cy9raNlOEiWzk+fnJGTbZemI=; b=Ax3ex1KHX/0ypZoxKFZlT5QACisbTcVH7G8usW8x8RfetiJg2szV8g03M9jZQoGAEZ eDCuHCIbHihTGRAOx4dooSssv6bPtkaAokldqCnUA3PpvsRgW7cfp0HOCMVoEIAGSgbu ippLNPcnO8juVoBioA50tU5m04/MybwiluoNfXKTXjaKXGcCjNPBWIGvuzPwiIQ9YRab 5iwWM/YJ+4WR/Fmwax0NgOlKQ2thTlaneZuMAu8MFDXvI2EIDWsu3r0MQpa7X8gt0BMZ 2LURSukIuGHr+pev6uWeLUrFdJumPmeSZbU71Vv1I/Kz/hGg3mcboGOqbQ7TW72v8OHW +cXA== X-Gm-Message-State: AO0yUKWNVCHwZ3HeU3OWIGu1xBMbCo0owyHATeDEVDB+EHeNnTxortyq 10Ddj+7VzUF5dL6L5BMsflw/gV9iVg== X-Google-Smtp-Source: AK7set9zxFcHUmej6FZI0b/r9kzi7HNM/sTT+QF7paaDfTXpKf0/Bz0qzrUkdUNA414JIRwtcEX/5g== X-Received: by 2002:a05:6808:de6:b0:387:1a46:8317 with SMTP id g38-20020a0568080de600b003871a468317mr7680846oic.13.1680034576781; Tue, 28 Mar 2023 13:16:16 -0700 (PDT) Received: from robh_at_kernel.org (66-90-144-107.dyn.grandenetworks.net. [66.90.144.107]) by smtp.gmail.com with ESMTPSA id v7-20020a4aaec7000000b00529cc3986c8sm2696062oon.40.2023.03.28.13.16.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Mar 2023 13:16:16 -0700 (PDT) Received: (nullmailer pid 3993710 invoked by uid 1000); Tue, 28 Mar 2023 20:16:10 -0000 From: Rob Herring Date: Tue, 28 Mar 2023 15:15:56 -0500 Subject: [PATCH 1/5] of: unittest: Add bus address range parsing tests MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230328-dt-address-helpers-v1-1-e2456c3e77ab@kernel.org> References: <20230328-dt-address-helpers-v1-0-e2456c3e77ab@kernel.org> In-Reply-To: <20230328-dt-address-helpers-v1-0-e2456c3e77ab@kernel.org> To: Michael Ellerman , Nicholas Piggin , Christophe Leroy , Stuart Yoder , Laurentiu Tudor , Benjamin Herrenschmidt Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org X-Mailer: b4 0.13-dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While there are tests for "dma-ranges" helpers, "ranges" is missing any tests. It's the same underlying code, but for completeness add a test for "ranges" parsing iterators. This is in preparation to add some additional "ranges" helpers. Signed-off-by: Rob Herring --- drivers/of/unittest.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 53 insertions(+) diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index b5a7a31d8bd2..1a45df1f354a 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -1008,6 +1008,58 @@ static void __init of_unittest_pci_dma_ranges(void) of_node_put(np); } =20 +static void __init of_unittest_bus_ranges(void) +{ + struct device_node *np; + struct of_range range; + struct of_range_parser parser; + int i =3D 0; + + np =3D of_find_node_by_path("/testcase-data/address-tests"); + if (!np) { + pr_err("missing testcase data\n"); + return; + } + + if (of_range_parser_init(&parser, np)) { + pr_err("missing ranges property\n"); + return; + } + + /* + * Get the "ranges" from the device tree + */ + for_each_of_range(&parser, &range) { + unittest(range.flags =3D=3D IORESOURCE_MEM, + "for_each_of_range wrong flags on node %pOF flags=3D%x (expected %x)\n", + np, range.flags, IORESOURCE_MEM); + if (!i) { + unittest(range.size =3D=3D 0x40000000, + "for_each_of_range wrong size on node %pOF size=3D%llx\n", + np, range.size); + unittest(range.cpu_addr =3D=3D 0x70000000, + "for_each_of_range wrong CPU addr (%llx) on node %pOF", + range.cpu_addr, np); + unittest(range.bus_addr =3D=3D 0x70000000, + "for_each_of_range wrong bus addr (%llx) on node %pOF", + range.pci_addr, np); + } else { + unittest(range.size =3D=3D 0x20000000, + "for_each_of_range wrong size on node %pOF size=3D%llx\n", + np, range.size); + unittest(range.cpu_addr =3D=3D 0xd0000000, + "for_each_of_range wrong CPU addr (%llx) on node %pOF", + range.cpu_addr, np); + unittest(range.bus_addr =3D=3D 0x00000000, + "for_each_of_range wrong bus addr (%llx) on node %pOF", + range.pci_addr, np); + } + i++; + } + + of_node_put(np); +} + static void __init of_unittest_parse_interrupts(void) { struct device_node *np; @@ -3644,6 +3696,7 @@ static int __init of_unittest(void) of_unittest_dma_get_max_cpu_address(); of_unittest_parse_dma_ranges(); of_unittest_pci_dma_ranges(); + of_unittest_bus_ranges(); of_unittest_match_node(); of_unittest_platform_populate(); of_unittest_overlay(); --=20 2.39.2