From patchwork Thu Feb 11 20:46:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 61807 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp433568lbl; Thu, 11 Feb 2016 12:47:14 -0800 (PST) X-Received: by 10.66.100.163 with SMTP id ez3mr69822187pab.5.1455223630151; Thu, 11 Feb 2016 12:47:10 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 198si14686050pfc.32.2016.02.11.12.47.09; Thu, 11 Feb 2016 12:47:10 -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 S1751417AbcBKUrI (ORCPT + 6 others); Thu, 11 Feb 2016 15:47:08 -0500 Received: from mail-ob0-f181.google.com ([209.85.214.181]:32806 "EHLO mail-ob0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751412AbcBKUrG (ORCPT ); Thu, 11 Feb 2016 15:47:06 -0500 Received: by mail-ob0-f181.google.com with SMTP id is5so91898297obc.0; Thu, 11 Feb 2016 12:47:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CuqBcDjqR2sA7nLNyxG0SOGsH0wmgYIhD3eigZRsHQM=; b=TiW8bid190lNGWy5TQV+oQ/PpSvIUw2l3zYKl5Jt0Fe81nrHfXEUNrUd7fi3lvBagu rfXLNKK7xrI6IMtyXgVEL2+bABWM74oB6bZyFzIUUJ0CaqmbySfEe0O49wMPiM/YTdlL 9L6UYFjMOOUmIXp5NRfnPTTl09rF/MOTBXyQA0sWgkILWWcauYyybzWEclDfWJpp7eOE klRk6E2LU3BjKXeJnyPLTA+mxiDOOHbda/LBpndkHarVL654H3oDtsiGXcjcOXTg2f1q FzikzLYiCpyqEWGcBJDbFMHi2f/MD7y73QliotDorgA4t4XeLOCPkAfrJdz6YF/sXGgd OT+Q== X-Gm-Message-State: AG10YORYEh53ODyAOFTU4Vc1YgLIHd2oshqUzuPGR3sa4xc7/uLaUngkg7DYHL7c/B/ukA== X-Received: by 10.182.87.194 with SMTP id ba2mr50043670obb.52.1455223625656; Thu, 11 Feb 2016 12:47:05 -0800 (PST) Received: from rob-hp-laptop.herring.priv (72-48-98-129.dyn.grandenetworks.net. [72.48.98.129]) by smtp.googlemail.com with ESMTPSA id co3sm6578422obb.15.2016.02.11.12.47.05 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 11 Feb 2016 12:47:05 -0800 (PST) From: Rob Herring To: David Gibson Cc: devicetree-compiler@vger.kernel.org, devicetree@vger.kernel.org, Stephen Warren Subject: [PATCH 2/2] Warn on node name unit-addresses with '0x' or leading 0s Date: Thu, 11 Feb 2016 14:46:59 -0600 Message-Id: <1455223619-16052-3-git-send-email-robh@kernel.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455223619-16052-1-git-send-email-robh@kernel.org> References: <1455223619-16052-1-git-send-email-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 never begin with 0x or leading 0s regardless of whether they have a bus specific address (i.e. one with commas) or not. Add warnings to check for these cases. Signed-off-by: Rob Herring --- checks.c | 10 ++++++++++ tests/run_tests.sh | 2 ++ tests/unit-addr-leading-0s.dts | 10 ++++++++++ tests/unit-addr-leading-0x.dts | 10 ++++++++++ 4 files changed, 32 insertions(+) create mode 100644 tests/unit-addr-leading-0s.dts create mode 100644 tests/unit-addr-leading-0x.dts -- 2.5.0 -- 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/checks.c b/checks.c index 4001b8c..300ab43 100644 --- a/checks.c +++ b/checks.c @@ -310,6 +310,16 @@ static void check_unit_address_vs_reg(struct check *c, struct node *dt, if (!unitname[0]) FAIL(c, "Node %s has a reg or ranges property, but no unit name", node->fullpath); + + if (strstr(unitname, "0x") == unitname) { + FAIL(c, "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, "Node %s unit name should not have leading 0s", + node->fullpath); } else { if (unitname[0]) FAIL(c, "Node %s has a unit name, but no reg property", diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 4b7a131..502caa6 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -445,6 +445,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_vs_reg + check_tests unit-addr-leading-0s.dts unit_address_vs_reg 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 0000000..7c8e2ce --- /dev/null +++ b/tests/unit-addr-leading-0s.dts @@ -0,0 +1,10 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + 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 0000000..7ed7254 --- /dev/null +++ b/tests/unit-addr-leading-0x.dts @@ -0,0 +1,10 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + node@0x1 { + reg = <1 0>; + }; +};