From patchwork Tue Feb 28 22:43:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 94676 Delivered-To: patch@linaro.org Received: by 10.140.20.113 with SMTP id 104csp1532081qgi; Tue, 28 Feb 2017 14:50:04 -0800 (PST) X-Received: by 10.99.185.74 with SMTP id v10mr5158004pgo.98.1488322204794; Tue, 28 Feb 2017 14:50:04 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p2si2893910pgf.396.2017.02.28.14.50.04; Tue, 28 Feb 2017 14:50:04 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751800AbdB1Wtq (ORCPT + 7 others); Tue, 28 Feb 2017 17:49:46 -0500 Received: from mail-ot0-f196.google.com ([74.125.82.196]:36837 "EHLO mail-ot0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750957AbdB1Wtn (ORCPT ); Tue, 28 Feb 2017 17:49:43 -0500 Received: by mail-ot0-f196.google.com with SMTP id i1so2566107ota.3; Tue, 28 Feb 2017 14:49:33 -0800 (PST) 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=ezNCpJr1pgEqzn3YeWbTb6XHem655i4z2xoVqqJqdU8=; b=Ci+bHL6Q08H1cViieizymUvUGuHKDr3Dxsfn2YKAIEvXR/MihCYOmD2tGy6zA/sDo+ PSA8agFLgMo4vLnS1xzAj8fOGV72y+sbl4dDOZZTZqyBA1yC8mKMTQ7A8FrNSPi1Nvgf JzLGvHY0fJvk7lbrMs/XE1UwoIfOWXiFffs9ij5wbMe3a6Dbq1Q4ECJU5bn9Vg+MyCBI U1hc9DD5o/SGowXtiuhkpd7JFvsNCd+QdFkNAGFaFYpDFRJz4CemxEa8FvSPN9ASrObS 0AhcLYw6vgMQPsBOHnFdJMVsB/NzuMsL2xFJJbExYZmeMHiGja1JTwjaNFmE0qpV4ohf EO3g== X-Gm-Message-State: AMke39k8agUOmMSSGJtg2xnHnK52z9neFiUuDs3hc94Xy+HTtppn+fmRFHlclRE8BzVNFQ== X-Received: by 10.157.22.246 with SMTP id s51mr2916255ots.183.1488321794730; Tue, 28 Feb 2017 14:43:14 -0800 (PST) Received: from rob-hp-laptop.herring.priv (66-90-148-125.dyn.grandenetworks.net. [66.90.148.125]) by smtp.googlemail.com with ESMTPSA id j128sm1203053oif.32.2017.02.28.14.43.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Feb 2017 14:43:14 -0800 (PST) From: Rob Herring To: David Gibson Cc: devicetree-compiler@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v3 3/3] checks: Warn on node name unit-addresses with '0x' or leading 0s Date: Tue, 28 Feb 2017 16:43:10 -0600 Message-Id: <20170228224310.14162-4-robh@kernel.org> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170228224310.14162-1-robh@kernel.org> References: <20170228224310.14162-1-robh@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Node name unit-addresses should generally never begin with 0x or leading 0s. Add warnings to check for these cases, but only for nodes without a known bus type as there should be better bus specific checks of the unit address in those cases. Any unit addresses that don't follow the general rule will need to add a new bus type. There aren't any known ones ATM. Signed-off-by: Rob Herring --- v3: - Only run check if bus type is not set (moving to the end of the series as a result). The bus bridge checks also must be a dependency. v2: - Split into separate check from unit_address_vs_reg checks.c | 25 +++++++++++++++++++++++++ tests/run_tests.sh | 2 ++ tests/unit-addr-leading-0s.dts | 12 ++++++++++++ tests/unit-addr-leading-0x.dts | 12 ++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 tests/unit-addr-leading-0s.dts create mode 100644 tests/unit-addr-leading-0x.dts -- 2.10.1 -- 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 Reviewed-by: David Gibson diff --git a/checks.c b/checks.c index c4865b4c8da0..537c27dc4082 100644 --- a/checks.c +++ b/checks.c @@ -883,6 +883,30 @@ static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct no } WARNING(simple_bus_reg, check_simple_bus_reg, NULL, ®_format, &simple_bus_bridge); +static void check_unit_address_format(struct check *c, struct dt_info *dti, + struct node *node) +{ + const char *unitname = get_unitname(node); + + if (node->parent && node->parent->bus) + return; + + if (!unitname[0]) + return; + + if (!strncmp(unitname, "0x", 2)) { + FAIL(c, dti, "Node %s unit name should not have leading \"0x\"", + node->fullpath); + /* skip over 0x for next test */ + unitname += 2; + } + if (unitname[0] == '0' && isxdigit(unitname[1])) + FAIL(c, dti, "Node %s unit name should not have leading 0s", + node->fullpath); +} +WARNING(unit_address_format, check_unit_address_format, NULL, + &node_name_format, &pci_bridge, &simple_bus_bridge); + /* * Style checks */ @@ -954,6 +978,7 @@ static struct check *check_table[] = { &addr_size_cells, ®_format, &ranges_format, &unit_address_vs_reg, + &unit_address_format, &pci_bridge, &pci_device_reg, diff --git a/tests/run_tests.sh b/tests/run_tests.sh index ed489dbdd269..0f5c3db79b80 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -540,6 +540,8 @@ dtc_tests () { check_tests obsolete-chosen-interrupt-controller.dts obsolete_chosen_interrupt_controller check_tests reg-without-unit-addr.dts unit_address_vs_reg check_tests unit-addr-without-reg.dts unit_address_vs_reg + check_tests unit-addr-leading-0x.dts unit_address_format + check_tests unit-addr-leading-0s.dts unit_address_format run_sh_test dtc-checkfails.sh node_name_chars -- -I dtb -O dtb bad_node_char.dtb run_sh_test dtc-checkfails.sh node_name_format -- -I dtb -O dtb bad_node_format.dtb run_sh_test dtc-checkfails.sh prop_name_chars -- -I dtb -O dtb bad_prop_char.dtb diff --git a/tests/unit-addr-leading-0s.dts b/tests/unit-addr-leading-0s.dts new file mode 100644 index 000000000000..cc017e9431a2 --- /dev/null +++ b/tests/unit-addr-leading-0s.dts @@ -0,0 +1,12 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + bus { + node@001 { + reg = <1 0>; + }; + }; +}; diff --git a/tests/unit-addr-leading-0x.dts b/tests/unit-addr-leading-0x.dts new file mode 100644 index 000000000000..74f19678c98c --- /dev/null +++ b/tests/unit-addr-leading-0x.dts @@ -0,0 +1,12 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + bus { + node@0x1 { + reg = <1 0>; + }; + }; +};