From patchwork Fri Nov 17 14:45:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 119155 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp606505qgn; Fri, 17 Nov 2017 06:45:21 -0800 (PST) X-Google-Smtp-Source: AGs4zMZdmYLPSugCIQ8InAcvL7X2v6XH7Lz81d7OvuTlkC9zhC792YQOeByVV3yTIHfCIogCXjpn X-Received: by 10.84.245.22 with SMTP id i22mr1226391pll.123.1510929921805; Fri, 17 Nov 2017 06:45:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510929921; cv=none; d=google.com; s=arc-20160816; b=atCAPN1qKQAWePu8df46m5LJY5slJd+8LicFhXQYhcNAwx6YiM6uFPvP/Hz5p+WuuC H3B3ZB87Ex8ma5gJT4ZMtVu+M2u98uymZEq2zoGap/G4hswY0K37jTn6KL/ObbtXFR/a VKPH4SSOALVOzDUsJQZ0tVX63b41zaOyjXpow5fqjze4Otjl5homZz8zlsAD7hoarjL6 Si1790VkeRecZbjux2zUtXyzR+Gy4v+MHocEcEv9g1Y4iZDqZAfRbqKVY72Y35Bn33/F +jg1c/ai63cmEw3Ml6ynNeQfjpdzdXHc8vyivGVkytG3YnVLA3mm6xQVi14Lafn6WUXE n0PQ== 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:arc-authentication-results; bh=s4DGpd8F8+z+90ABOpYyhrHKynKGHHnqWmHzUNJno3A=; b=pt/HsruI6QZo7Opgpt2F8S+hhBqcd+qlNTytWWqkm+pvO+DrVdG3RxUh9YxR+FZhKE shM3bh4pmXArJLXc9xRmRkNIwt314mTT2N3JdyjxX0DeoVOty4Q2uconV0q9FPyGRTIn 1KR26RI1oFpRCrAf/Wfjz+19xADv15wsRQ9c/NbMLGiXCcMqFa75R7RiQG3h0KjLY1d0 G9FarIy4R3qcjiQoxF41N6VhsEMwVj9zl6+ejP+sgh8isNxxAlIG39C8Ljd1OkfNrro/ 1A5mNw+Y5iPEohxZfJPWtyp3n3tsraeEJV32tcOIFb6UMmq8fU95GCYfWyxBHAuwK/zi Qsrg== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8si3129534pfa.310.2017.11.17.06.45.21; Fri, 17 Nov 2017 06:45:21 -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 S964974AbdKQOpU (ORCPT + 6 others); Fri, 17 Nov 2017 09:45:20 -0500 Received: from mail-ot0-f193.google.com ([74.125.82.193]:38663 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030297AbdKQOpT (ORCPT ); Fri, 17 Nov 2017 09:45:19 -0500 Received: by mail-ot0-f193.google.com with SMTP id b49so2177059otj.5; Fri, 17 Nov 2017 06:45:18 -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=Q4ZEifLASPHbm6/ux1S/lfGTEIudQjt9BuSPz9pEKWk=; b=Sz3vap8OOfYYsfRlLiM23BRY2fHNX06S9U1fajqtY94kowIGAPOKobU2bmFFBOTEwD YP8wCdWqpovoBrfbI5r8+El7zaLb+u0xTAWq/vqSlXQq8qFhdNVAcMsXx+GNvDBRvjL2 AtOFug5AynJVxXw18H/PvDiRdSzNMI1oW/j711xQUnGSDdAteFQkogaxbi9ixCsREDwu 403ylYlvlXfvXPl7GYhri0bkSY+/ELiRBRDHN2+lxyZn7pJqLHwPp2hvkw8EtWVlVE9Z FIhFR5l2zvIO0ZjFItKl8ynLiD635dmJ1I2mhPtLB4+eVv/OphMY3W5WPDBVp1EP3bLc bUXA== X-Gm-Message-State: AJaThX4uYjWBy4J4WHLrlVFB4abln1OjK35qB0MDBw0nVWhXkXCVE5Pt Jam2UFfMpRgME5TdYhHbqtKGYqg= X-Received: by 10.157.3.43 with SMTP id 40mr1592300otv.156.1510929918264; Fri, 17 Nov 2017 06:45:18 -0800 (PST) Received: from xps15.herring.priv (216-188-254-6.dyn.grandenetworks.net. [216.188.254.6]) by smtp.googlemail.com with ESMTPSA id i6sm1529906oiy.37.2017.11.17.06.45.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Nov 2017 06:45:17 -0800 (PST) From: Rob Herring To: devicetree-compiler@vger.kernel.org Cc: devicetree@vger.kernel.org Subject: [PATCH 2/5] checks: add string list check Date: Fri, 17 Nov 2017 08:45:12 -0600 Message-Id: <20171117144515.10870-3-robh@kernel.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171117144515.10870-1-robh@kernel.org> References: <20171117144515.10870-1-robh@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add a check for string list properties with compatible being the first check. Signed-off-by: Rob Herring --- checks.c | 34 ++++++++++++++++++++++++++++++++++ tests/bad-string-props.dts | 8 ++++++++ tests/run_tests.sh | 2 +- 3 files changed, 43 insertions(+), 1 deletion(-) -- 2.14.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 a4a9d37ca19b..4e23f29486bb 100644 --- a/checks.c +++ b/checks.c @@ -179,6 +179,36 @@ static void check_is_string(struct check *c, struct dt_info *dti, #define ERROR_IF_NOT_STRING(nm, propname) \ ERROR(nm, check_is_string, (propname)) +static void check_is_string_list(struct check *c, struct dt_info *dti, + struct node *node) +{ + int rem, l; + struct property *prop; + char *propname = c->data; + char *str; + + prop = get_property(node, propname); + if (!prop) + return; /* Not present, assumed ok */ + + str = prop->val.val; + rem = prop->val.len; + while (rem > 0) { + l = strnlen(str, rem); + if (l == rem) { + FAIL(c, dti, "\"%s\" property in %s is not a string list", + propname, node->fullpath); + break; + } + rem -= l + 1; + str += l + 1; + } +} +#define WARNING_IF_NOT_STRING_LIST(nm, propname) \ + WARNING(nm, check_is_string_list, (propname)) +#define ERROR_IF_NOT_STRING_LIST(nm, propname) \ + ERROR(nm, check_is_string_list, (propname)) + static void check_is_cell(struct check *c, struct dt_info *dti, struct node *node) { @@ -590,6 +620,8 @@ WARNING_IF_NOT_STRING(label_is_string, "label"); WARNING_IF_NOT_STRING(bootargs_is_string, "bootargs"); WARNING_IF_NOT_STRING(stdout_path_is_string, "stdout-path"); +WARNING_IF_NOT_STRING_LIST(compatible_is_string_list, "compatible"); + static void fixup_addr_size_cells(struct check *c, struct dt_info *dti, struct node *node) { @@ -1241,6 +1273,8 @@ static struct check *check_table[] = { &device_type_is_string, &model_is_string, &status_is_string, &label_is_string, &bootargs_is_string, &stdout_path_is_string, + &compatible_is_string_list, + &property_name_chars_strict, &node_name_chars_strict, diff --git a/tests/bad-string-props.dts b/tests/bad-string-props.dts index 9b5a7a1736ee..5e226ce0c736 100644 --- a/tests/bad-string-props.dts +++ b/tests/bad-string-props.dts @@ -7,4 +7,12 @@ bootargs = <0xdeadbeef>; stdout-path = <0xdeadbeef>; label = <0xdeadbeef>; + + node1 { + compatible = <0xdeadbeef>; + }; + + node2 { + compatible = "good", <0xdeadbeef>; + }; }; diff --git a/tests/run_tests.sh b/tests/run_tests.sh index c610aaeb053e..f492cf78ae84 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -546,7 +546,7 @@ dtc_tests () { check_tests bad-name-property.dts name_properties check_tests bad-ncells.dts address_cells_is_cell size_cells_is_cell interrupt_cells_is_cell - check_tests bad-string-props.dts device_type_is_string model_is_string status_is_string bootargs_is_string stdout_path_is_string label_is_string + check_tests bad-string-props.dts device_type_is_string model_is_string status_is_string bootargs_is_string stdout_path_is_string label_is_string compatible_is_string_list check_tests bad-reg-ranges.dts reg_format ranges_format check_tests bad-empty-ranges.dts ranges_format check_tests reg-ranges-root.dts reg_format ranges_format