From patchwork Wed Jan 31 02:36:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 126306 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp292620ljc; Tue, 30 Jan 2018 18:38:09 -0800 (PST) X-Google-Smtp-Source: AH8x225Gr9oChtuwxxdae9ccCK7g/RYL0haxJAYg/Ca2RMtvHgBtUSON/9E6tebM2WFMXVQhNDLb X-Received: by 10.98.198.2 with SMTP id m2mr32203008pfg.113.1517366289118; Tue, 30 Jan 2018 18:38:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517366289; cv=none; d=google.com; s=arc-20160816; b=Ww6C/ziK0z0pq04PJIw2ppST4d3Onx0jQckXSZfMj2l032CUBiblcrIkKJl6OUH8lT KqRXIRsauGFF/k9/q4Vvp/E0pPOctE7u12St0E8qL0TFETMqcV/i6QrfzRh0PxDjNuEa hez6HugPEyWFaoxPnyTMbBptDTF9P6lOpiTSPnnBI31DU+0RSura1MJluOaqHwVB4ff5 n2VeiKJ0veli3sZRTZAl/SqN+40aEbQMDv3+bbT2i7muXFGMTxZ7p0VWxtxEkls4/UZ6 0UWrQJ6krKILrR82nfPQoF1UhkWFa/XqRVgCa6THnKd23mmgoJCF53wBV6l74rYThjGl 40Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=SkZ+zpUFJNAbCfzaFz68al90BxR/IVVto7xjJG42HZE=; b=iRB4LuqOAYzvxnqjfH8Drx7OelJO97mcP0LdosH0+GTh1d3p1OTokylAztjUMMjbD7 S0boC4PftDN/buPMAymjOF405fdKi/+f24kQ7UUW4h+nNyMrb4Xr4eLVCuGMltAAimo+ CDdQpok4MCpXc8Nihg/BISC1DNx8a5o1j9KOtBE4ebU38UYNNfkWiwi51k22BZiWE9PW JGfpnVZS/bO9IQuq1JUFBXJ1Yi+WkMpSU/tfXZfcv6yZ56yrebol4PwlNWzKSlrSRveS 7mGX7PdqP6a7m2vgIESZRs0MuvjmP41YZVEF6pruBIxePo3JXVNiPKGq2wliSD9aIica TdNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=AswY0FJk; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t12si848039pgo.110.2018.01.30.18.38.08; Tue, 30 Jan 2018 18:38:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=AswY0FJk; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752027AbeAaCiH (ORCPT + 6 others); Tue, 30 Jan 2018 21:38:07 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:37945 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753446AbeAaCgd (ORCPT ); Tue, 30 Jan 2018 21:36:33 -0500 Received: by mail-pg0-f67.google.com with SMTP id y27so8865611pgc.5 for ; Tue, 30 Jan 2018 18:36:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tqfmEbQPOgtzIm9LdGK35l+0oMPOC0IewQ+itnidCZI=; b=AswY0FJkh5O0tXC9MD4ao6oKIf92GfQWh5WbyxKBMKE7npXYFCrL59/zGVQka6j6Yj tSCllWKi2bWKn5K0hVojl1uUjKupcPfMlr/EU2SHrv5m+4pGSylPkUP/hIk45T/2lqQA MzAubgATPVfeH63XTIX6Au5HiSOK3jrixGQfo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tqfmEbQPOgtzIm9LdGK35l+0oMPOC0IewQ+itnidCZI=; b=R+xDWppwPf31AzdBKdpT4luaCqgs4hHx2r4upGKvMgxX6Jwg27plwqUj7V4dwFNNw1 k5dOaOcuI7KH6B9j7QiGuWSK3elUAhD2MZUnPPouZSOf2b8km0fn0UlDQxxJ90IDnD6W S4zQZuhEps1c/Q4Psu0CytGalKyIswo53rynU6muhHoC0pzCDBB4CVcJFl282GudOqSv zCOu87uoijwUZKrctplgNFkdZYmhw5s5LAEGZlhkE/PN8K5uw58Asr+EXsMJ7oXYzB5I gEfbJVbInCZIhkEnB0YakuBAIh/+5N+8knSHo57DII9yzuqTm5UrXdwLFDjtiDsKJIBd HxMg== X-Gm-Message-State: AKwxytfBvASmuP/PgMEoAnk+iabpkZRWHz10npQfBmg+D4BFpEpHptwr GlMSp06OZqlbROo3thWRvUpc9Q== X-Received: by 2002:a17:902:123:: with SMTP id 32-v6mr27204583plb.278.1517366192464; Tue, 30 Jan 2018 18:36:32 -0800 (PST) Received: from localhost.localdomain (pat_11.qualcomm.com. [192.35.156.11]) by smtp.gmail.com with ESMTPSA id z2sm24126828pgz.22.2018.01.30.18.36.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Jan 2018 18:36:31 -0800 (PST) From: Stephen Boyd To: Rob Herring , Frank Rowand Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Russell King - ARM Linux , devicetree-spec@vger.kernel.org, Pantelis Antoniou , Linus Walleij , Mark Brown Subject: [PATCH v5 3/4] of: unittest: Add phandle remapping test Date: Tue, 30 Jan 2018 18:36:17 -0800 Message-Id: <20180131023618.14292-4-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.14.GIT In-Reply-To: <20180131023618.14292-1-stephen.boyd@linaro.org> References: <20180131023618.14292-1-stephen.boyd@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Test the functionality of of_parse_phandle_with_args_map(). Cc: Pantelis Antoniou Cc: Linus Walleij Cc: Mark Brown Signed-off-by: Stephen Boyd --- drivers/of/unittest-data/tests-phandle.dtsi | 25 ++++++ drivers/of/unittest.c | 120 ++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) -- 2.14.GIT -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/of/unittest-data/tests-phandle.dtsi b/drivers/of/unittest-data/tests-phandle.dtsi index 3c2f09e56b61..6b33be4c4416 100644 --- a/drivers/of/unittest-data/tests-phandle.dtsi +++ b/drivers/of/unittest-data/tests-phandle.dtsi @@ -26,6 +26,18 @@ #phandle-cells = <3>; }; + provider4: provider4 { + #phandle-cells = <2>; + phandle-map = <0 1 &provider1 3>, + <4 0 &provider0>, + <16 5 &provider3 3 5 0>, + <200 8 &provider2 23 6>, + <19 0 &provider2 15 0>, + <2 3 &provider3 2 5 3>; + phandle-map-mask = <0xff 0xf>; + phandle-map-pass-thru = <0x0 0xf0>; + }; + consumer-a { phandle-list = <&provider1 1>, <&provider2 2 0>, @@ -44,6 +56,19 @@ unterminated-string = [40 41 42 43]; unterminated-string-list = "first", "second", [40 41 42 43]; }; + + consumer-b { + phandle-list = <&provider1 1>, + <&provider4 2 3>, + <0>, + <&provider4 4 0x100>, + <&provider4 0 0x61>, + <&provider0>, + <&provider4 19 0x20>; + phandle-list-bad-phandle = <12345678 0 0>; + phandle-list-bad-args = <&provider2 1 0>, + <&provider4 0>; + }; }; }; }; diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 0f8052f1355c..de27f62a8e8d 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -452,6 +452,125 @@ static void __init of_unittest_parse_phandle_with_args(void) unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); } +static void __init of_unittest_parse_phandle_with_args_map(void) +{ + struct device_node *np, *p0, *p1, *p2, *p3; + struct of_phandle_args args; + int i, rc; + + np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-b"); + if (!np) { + pr_err("missing testcase data\n"); + return; + } + + p0 = of_find_node_by_path("/testcase-data/phandle-tests/provider0"); + if (!p0) { + pr_err("missing testcase data\n"); + return; + } + + p1 = of_find_node_by_path("/testcase-data/phandle-tests/provider1"); + if (!p1) { + pr_err("missing testcase data\n"); + return; + } + + p2 = of_find_node_by_path("/testcase-data/phandle-tests/provider2"); + if (!p2) { + pr_err("missing testcase data\n"); + return; + } + + p3 = of_find_node_by_path("/testcase-data/phandle-tests/provider3"); + if (!p3) { + pr_err("missing testcase data\n"); + return; + } + + rc = of_count_phandle_with_args(np, "phandle-list", "#phandle-cells"); + unittest(rc == 7, "of_count_phandle_with_args() returned %i, expected 7\n", rc); + + for (i = 0; i < 8; i++) { + bool passed = true; + + rc = of_parse_phandle_with_args_map(np, "phandle-list", + "phandle", i, &args); + + /* Test the values from tests-phandle.dtsi */ + switch (i) { + case 0: + passed &= !rc; + passed &= (args.np == p1); + passed &= (args.args_count == 1); + passed &= (args.args[0] == 1); + break; + case 1: + passed &= !rc; + passed &= (args.np == p3); + passed &= (args.args_count == 3); + passed &= (args.args[0] == 2); + passed &= (args.args[1] == 5); + passed &= (args.args[2] == 3); + break; + case 2: + passed &= (rc == -ENOENT); + break; + case 3: + passed &= !rc; + passed &= (args.np == p0); + passed &= (args.args_count == 0); + break; + case 4: + passed &= !rc; + passed &= (args.np == p1); + passed &= (args.args_count == 1); + passed &= (args.args[0] == 3); + break; + case 5: + passed &= !rc; + passed &= (args.np == p0); + passed &= (args.args_count == 0); + break; + case 6: + passed &= !rc; + passed &= (args.np == p2); + passed &= (args.args_count == 2); + passed &= (args.args[0] == 15); + passed &= (args.args[1] == 0x20); + break; + case 7: + passed &= (rc == -ENOENT); + break; + default: + passed = false; + } + + unittest(passed, "index %i - data error on node %s rc=%i\n", + i, args.np->full_name, rc); + } + + /* Check for missing list property */ + rc = of_parse_phandle_with_args_map(np, "phandle-list-missing", + "phandle", 0, &args); + unittest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc); + + /* Check for missing cells,map,mask property */ + rc = of_parse_phandle_with_args_map(np, "phandle-list", + "phandle-missing", 0, &args); + unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); + + /* Check for bad phandle in list */ + rc = of_parse_phandle_with_args_map(np, "phandle-list-bad-phandle", + "phandle", 0, &args); + unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); + + /* Check for incorrectly formed argument list */ + rc = of_parse_phandle_with_args_map(np, "phandle-list-bad-args", + "phandle", 1, &args); + unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); +} + static void __init of_unittest_property_string(void) { const char *strings[4]; @@ -2354,6 +2473,7 @@ static int __init of_unittest(void) of_unittest_find_node_by_name(); of_unittest_dynamic(); of_unittest_parse_phandle_with_args(); + of_unittest_parse_phandle_with_args_map(); of_unittest_printf(); of_unittest_property_string(); of_unittest_property_copy();