Received: by 10.192.165.148 with SMTP id m20csp479613imm; Fri, 20 Apr 2018 09:48:32 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+upAZmjiWWrKtBkrsFupUQur6onNbR1mgqfqHOM9h2/gNAeHgLoDYvSr3PgKGWGxmzxwKf X-Received: by 10.99.158.85 with SMTP id r21mr9163131pgo.312.1524242912064; Fri, 20 Apr 2018 09:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524242912; cv=none; d=google.com; s=arc-20160816; b=m4sdhbUF6NJmB/jjM28HiyOuW2zeOa/5UjKZ0kSbFM86TeVnUCzTEWXDpXUjVEjUdh clF2iOiFHZMoWSlXcqeuM8yy5M95KPPS6rrMPFuy202nTRP7Z0PU/mhuZ5TLNMK3pOVH wucQMPFvwpI0bYzu29wbBSbxNXuDpF9gAG30pfUi/1lf3pEaYQum0AYAWdC1mapOSrqz YMUQxCarmGJ6ukOKsu/W/7/0wuzxbIz3NJpOUmwV8kHHeaLf54Fsefo3Btr8jWCqvB1p 0AixmCG6vUKE46cwmwUehzyTY65urGzQOlsEW51dHpOmmt8RKRuQE9sg6lH+G3fdFNzx zk/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:dmarc-filter:arc-authentication-results; bh=WaPHMGCMG27viEbOELkNd6B8v9JVJrpIPkTfENK1dDc=; b=0MUnUk+IDmPv03lx3iOseqBiTxjIVtvu5WaXCvLlCO36gT25ld4M/olDYYoHDg3h9o U+y8ApXXNWxTf1tWqNmDEkDtHFZzo3GZBUKMGzeVxStn/eVP0IEqDQTQ7Pcsn90iX/LI aVQFOzGLsIAt82K6iT9Z+VjYwjL64J/lxcQizU4mRkwxla16e8stHP9PKBvoAp2ojvjZ Nx4+FFZyUsMd0tmUh/TYueuCxUA+iINr32oKo1jPgXk/iYK2iEaXM7XUcSqXdW5db9fI ms3vt/IPAMBepgTJtsS0LR2oZy1i/UXqnSDwuSxJeZBP+ldnxT83oMqA+TX23PJxV2mx BcYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 k76si5895180pfb.146.2018.04.20.09.48.16; Fri, 20 Apr 2018 09:48:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752241AbeDTQrI convert rfc822-to-8bit (ORCPT + 99 others); Fri, 20 Apr 2018 12:47:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:35218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750841AbeDTQrG (ORCPT ); Fri, 20 Apr 2018 12:47:06 -0400 Received: from localhost (unknown [104.132.1.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D40AF2178F; Fri, 20 Apr 2018 16:47:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D40AF2178F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=sboyd@kernel.org Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: Rob Herring , devicetree-spec@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org From: Stephen Boyd In-Reply-To: <20180418222905.10414-1-robh@kernel.org> Cc: grant.likely@arm.com, frowand.list@gmail.com, mark.rutland@arm.com, Geert Uytterhoeven , Linus Walleij , Thierry Reding , Mark Brown , shawnguo@kernel.org, Bjorn Andersson , Arnd Bergmann , Jonathan Cameron References: <20180418222905.10414-1-robh@kernel.org> Message-ID: <152424282214.46528.2511757264045171935@swboyd.mtv.corp.google.com> User-Agent: alot/0.7 Subject: Re: [RFC PATCH] dt-bindings: add a jsonschema binding example Date: Fri, 20 Apr 2018 09:47:02 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Rob Herring (2018-04-18 15:29:05) > diff --git a/Documentation/devicetree/bindings/example-schema.yaml b/Documentation/devicetree/bindings/example-schema.yaml > new file mode 100644 > index 000000000000..fe0a3bd1668e > --- /dev/null > +++ b/Documentation/devicetree/bindings/example-schema.yaml > @@ -0,0 +1,149 @@ > +# SPDX-License-Identifier: BSD-2-Clause > +# Copyright 2018 Linaro Ltd. > +%YAML 1.2 > +--- > +# All the top-level keys are standard json-schema keywords except for > +# 'maintainers' and 'select' > + > +# $id is a unique idenifier based on the filename > +$id: "http://devicetree.org/schemas/example-schema.yaml#" > +$schema: "http://devicetree.org/meta-schemas/core.yaml#" > + > +# Only 1 version supported for now > +version: 1 > + > +title: An example schema annotated with jsonschema details > + > +maintainers: > + - Rob Herring > + > +description: | > + A more detailed multi-line description of the binding. > + > + Details about the hardware device and any links to datasheets can go here. > + > + The end of the description is marked by indentation less than the first line > + in the description. > + > +select: false > + # 'select' is a schema applied to a DT node to determine if this binding > + # schema should be applied to the node. It is optional and by default the > + # possible compatible strings are extracted and used to match. Can we get a concrete example here? > + > +properties: [...] > + > + interrupts: > + # Either 1 or 2 interrupts can be present > + minItems: 1 > + maxItems: 2 > + items: > + - description: tx or combined interrupt > + - description: rx interrupt > + > + description: | The '|' is needed to make yaml happy? > + A variable number of interrupts warrants a description of what conditions > + affect the number of interrupts. Otherwise, descriptions on standard > + properties are not necessary. > + > + interrupt-names: > + # minItems must be specified here because the default would be 2 > + minItems: 1 > + items: > + - const: "tx irq" > + - const: "rx irq" > + > + # Property names starting with '#' must be quoted > + '#interrupt-cells': > + # A simple case where the value must always be '2'. > + # The core schema handles that this must be a single integer. > + const: 2 > + > + interrupt-controller: {} Does '{}' mean nothing to see here? > + # The core checks this is a boolean, so just have to list it here to be > + # valid for this binding. > + > + clock-frequency: > + # The type is set in the core schema. Per device schema only need to set > + # constraints on the possible values. > + minimum: 100 > + maximum: 400000 > + # The value that should be used if the property is not present > + default: 200 > + The 'default' field is neat. I look forward to the compiler using the schema to insert defaults into the dtb if the properties aren't present in the input file. > + foo-gpios: > + maxItems: 1 > + description: A connection of the 'foo' gpio line. > + > + vendor,int-property: > + description: Vendor specific properties must have a description > + type: integer # A type is also required > + enum: [2, 4, 6, 8, 10] > + > + vendor,bool-property: > + description: Vendor specific properties must have a description > + type: boolean > + > +required: > + - compatible > + - reg > + - interrupts > + - interrupt-controller Can the required or optional parts go under each property instead of having a different section? Or does that make the schema parser difficult to implement? It may also make sense to negate this and specify only the optional properties, or to require both optional and required lists to make things more explicit at the cost of some verbosity. > + > +examples: > + - | > + /{ Is the first slash required here? > + compatible = "vendor,soc4-ip", "vendor,soc1-ip"; > + reg = <0x1000 0x80>, > + <0x3000 0x80>; > + reg-names = "core", "aux"; > + interrupts = <10>; > + interrupt-controller; > + };