From patchwork Mon Mar 20 14:44:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 95558 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp977967qgd; Mon, 20 Mar 2017 07:55:06 -0700 (PDT) X-Received: by 10.98.77.131 with SMTP id a125mr33938293pfb.90.1490021706766; Mon, 20 Mar 2017 07:55:06 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a12si17822071plt.291.2017.03.20.07.55.06; Mon, 20 Mar 2017 07:55:06 -0700 (PDT) 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 S1754261AbdCTOx3 (ORCPT + 7 others); Mon, 20 Mar 2017 10:53:29 -0400 Received: from mail-ot0-f193.google.com ([74.125.82.193]:34284 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753593AbdCTOw4 (ORCPT ); Mon, 20 Mar 2017 10:52:56 -0400 Received: by mail-ot0-f193.google.com with SMTP id x37so19547599ota.1; Mon, 20 Mar 2017 07:52:05 -0700 (PDT) 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=hN2mHxYDG2/pR0Bj0CoqnxARNtdthkkokiM3GX/RKJs=; b=g6xNcyta6OyUdC0jZk5A1uHW4nt+FFWLIvLpoi+wgoNNwPaGgxMMjTA404K582jq/C PxMVLEtaKyPHLFr4V3eIoYpZ5nh02aIzRXANK/Pia+onBq6aYKFb5cKZEZa0+7qwtod1 dx7GttjM1rgLPVUX9B4ERiWEddh37L9QWol+QW3HBQnkx0cLorXrAapv4tQaly1Aw83a RvMOM2JFWMsPCys9KD2XwhbU7Oo59UsJ+lT7ppTZ5kO9X/zYUTpEr8fxO57CiQb4qv4T oDc4nSW/9LWbYKQN9EXFI+pMBCMCeQi1hzjsOe78HztvAXcg+hXqgOB5i5mWYU0Rn66t Rwmg== X-Gm-Message-State: AFeK/H3F6DsGKkz+e6CFwr2/aF2m+2ZKTbDtfOOTu7+bI24OLzr3PXmgD7yd8tVWTs0jXg== X-Received: by 10.157.33.85 with SMTP id l21mr16759055otd.217.1490021063591; Mon, 20 Mar 2017 07:44:23 -0700 (PDT) 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 c55sm7536708otd.31.2017.03.20.07.44.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Mar 2017 07:44:23 -0700 (PDT) From: Rob Herring To: David Gibson Cc: devicetree@vger.kernel.org, devicetree-compiler@vger.kernel.org Subject: [PATCH v4 3/3] checks: Warn on node name unit-addresses with '0x' or leading 0s Date: Mon, 20 Mar 2017 09:44:18 -0500 Message-Id: <20170320144418.5021-4-robh@kernel.org> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170320144418.5021-1-robh@kernel.org> References: <20170320144418.5021-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. Reviewed-by: David Gibson Signed-off-by: Rob Herring --- v4: - Rebase to 1.4.4 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 diff --git a/checks.c b/checks.c index 33036b8dbbc2..7f9232158dd9 100644 --- a/checks.c +++ b/checks.c @@ -880,6 +880,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 */ @@ -951,6 +975,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>; + }; + }; +};