devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 2/5] checks: add string list check
Date: Mon, 20 Nov 2017 11:10:34 +1100	[thread overview]
Message-ID: <20171120001034.GG19214@umbus.fritz.box> (raw)
In-Reply-To: <20171117144515.10870-3-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 4028 bytes --]

On Fri, Nov 17, 2017 at 08:45:12AM -0600, Rob Herring wrote:
> Add a check for string list properties with compatible being the first
> check.
> 
> Signed-off-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

Reviewed-by: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>

Not applying right now, while resolving queries on 1/5.

> ---
>  checks.c                   | 34 ++++++++++++++++++++++++++++++++++
>  tests/bad-string-props.dts |  8 ++++++++
>  tests/run_tests.sh         |  2 +-
>  3 files changed, 43 insertions(+), 1 deletion(-)
> 
> 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

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2017-11-20  0:10 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-17 14:45 [PATCH 0/5] Another batch of dtc checks Rob Herring
     [not found] ` <20171117144515.10870-1-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-11-17 14:45   ` [PATCH 1/5] checks: add a string checks for label, bootargs and stdout-path Rob Herring
     [not found]     ` <20171117144515.10870-2-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-11-20  0:09       ` David Gibson
     [not found]         ` <20171120000954.GF19214-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2017-11-20 17:26           ` Rob Herring
     [not found]             ` <CAL_JsqJUpgBC1awgTZgz3pwhYUL02ES=E-ogqVONxDFjg8eSag-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-22  3:12               ` David Gibson
2017-11-17 14:45   ` [PATCH 2/5] checks: add string list check Rob Herring
     [not found]     ` <20171117144515.10870-3-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-11-20  0:10       ` David Gibson [this message]
2017-11-17 14:45   ` [PATCH 3/5] checks: add string list check for *-names properties Rob Herring
     [not found]     ` <20171117144515.10870-4-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-11-17 15:12       ` Andre Przywara
     [not found]         ` <8eea3f9e-5512-dc6c-f755-58cc333db732-5wv7dgnIgG8@public.gmane.org>
2017-11-17 18:07           ` Rob Herring
     [not found]             ` <CAL_JsqLQwZ=grCDwjUORaE0NnmC_qJBBtJtT7X0-Z2BGujcfmA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-20  0:11               ` David Gibson
2017-11-20  0:10           ` David Gibson
2017-11-17 14:45   ` [PATCH 4/5] checks: check for #{size,address}-cells without child nodes Rob Herring
     [not found]     ` <20171117144515.10870-5-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-11-20  0:14       ` David Gibson
     [not found]         ` <20171120001438.GJ19214-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2017-11-20 16:22           ` Rob Herring
     [not found]             ` <CAL_JsqJoiBvD-QE5bgk5ob3qc65ar371xWxx-1D+fKGh7+P=Zw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-22  3:18               ` David Gibson
2017-11-17 14:45   ` [PATCH 5/5] checks: add aliases node checks Rob Herring
     [not found]     ` <20171117144515.10870-6-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-11-20  0:24       ` David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171120001034.GG19214@umbus.fritz.box \
    --to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
    --cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).