Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8765048imu; Thu, 15 Nov 2018 17:35:38 -0800 (PST) X-Google-Smtp-Source: AJdET5cQlngn61WXxxbm7JZJm0JC6sv7LTtBk69V2A32g1ylyjhl+HQ8fbe693NExZ/1TehyZk0x X-Received: by 2002:a17:902:6113:: with SMTP id t19mr8453208plj.248.1542332138513; Thu, 15 Nov 2018 17:35:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542332138; cv=none; d=google.com; s=arc-20160816; b=Gg1Xg5QhodVzZj+P/Axa/eyNfsBBVnlvOPBz0i8T2mIv8UJ4mHFMG/gteqIdq+awKL WrQHcJT10qiXJVUqeKmmXphV57ua5gfge/mBYb1zKRgIhU/VMrqrgzMmk2mH5dHP19q/ JoZ8V7P0VVyp1uCnLMq/G0TSqliVpWnZuGa4e75Cm0ClaOzMlxBNQgEsZVtMkDT+OSxH gTcPiggxKZPDSX4RyolCBOGWs34w6zEppycLePX6HfVWLUoIuSEtSK2wqZcGCmS7j+Wi DoOc8hoIjXGQvlGQ8UJYbyb1w2THjgvaM9opsuy5iHVY/pHL3M7NfEhqZfBZ0JGFeOgT O18g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=4ayGo4v+DliufNSqgz1k1qfF5PRguotHdX7wl25usIg=; b=yKFhtqj5USx5u0NdDPPSsiSoRczucB0Tx/4kSYYz7rbWbPFOHOc3DsPE2m/OSqH31H kp+wYANjZY7Vqh5nk/Jwr3ET19Ak/sV5ptpRMi3b4xVo0Hsn6wMcJOMoXRHrz+rw07cL qoTvXnPZs2KI24yddxrwofzgAXru9osKAL+ArPpuQZPGAfjAFF7AF/nJUnzIYyr1GQxb xt0LtL0Us638mDGKcjRrHFrgNxZIVtNN+G2UzYTy+EcLOclOv43OUm3/1rHIA7SKFQvu a8LF1O3Iw0OFxQDec8Te1a8t54ANF3E6j2l9Im2qbTbFocaN3ujTQTGiCmhG3gZIcNDh DNIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NwJSKGOd; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g187si2188861pfc.43.2018.11.15.17.35.24; Thu, 15 Nov 2018 17:35:38 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NwJSKGOd; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727351AbeKPLpG (ORCPT + 99 others); Fri, 16 Nov 2018 06:45:06 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:46529 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726518AbeKPLpG (ORCPT ); Fri, 16 Nov 2018 06:45:06 -0500 Received: by mail-pf1-f196.google.com with SMTP id s9-v6so10555601pfm.13; Thu, 15 Nov 2018 17:34:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4ayGo4v+DliufNSqgz1k1qfF5PRguotHdX7wl25usIg=; b=NwJSKGOdUhYfHVKpYoYM5xxuJE4WvNS0eGSFt4pNeBaNrxarRNkJZVAK/T/yN+Nk7K LMgXmSTG2A3C68vfB4KZmjnhNaXZsRM5uthLFXVJz3Ea/G2B/s5/T/Dg7XU2v2XOehH7 U3YN5sHuYH5kBe6vQQjlWXndfZpVL3at0dwTRknli2ig5c4g0X7RpHdXV9b1R8zEBy2x kHqft28V3eqIJDWgp2PwxCLV1ulmxmVZFxxs33S4oxDP5uVDTo1JPhLDwzblhpKH12DF WvjUHwgo8OHUzOd5vONvDaCwsp8c4MbhdSVccQXxJPtE1nzc1s2KJA1IdE6tbgOv+noI iBhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4ayGo4v+DliufNSqgz1k1qfF5PRguotHdX7wl25usIg=; b=IE7MiOyDNXqfkBFs8nd2GbREENrJR2/gSZJQFGQ5doN7Ne/uEIRNKr3jLJq2Kb+xf5 wjgw7e47+7+/omg5GAVpxYOcek9itqkOGtk7qddyiayHF6Ulz8qBsOxqopXfhXpmjYTN KrIrl3zNNzh26fKsJDkkHnL1R+MIoErxL7RcxDjPChZw+QlWE8f9BO45+MGE7d+i0rxZ fLG1OLk1dq7UDqeQxxigRYLJLHeaYP3YGdo7AWityRjCv5Rt8XqFcm4IXhm2ELxRaJhC ejnxKJNJjrdNvB9WSmhXVV+S4YmpnkjjJ2ykQK85FotdTxFBDIMTgZf8A1UQ7IEPk415 rcvw== X-Gm-Message-State: AGRZ1gJlmlL7+nHvhcaA9oaf1dfBk8keq+hXRd/SvDtgtzMFSquObUD9 rtn/F+6lCzZzWhvfY3iOp0UuDranfhVnaY0r07E= X-Received: by 2002:a63:2c82:: with SMTP id s124mr7866298pgs.73.1542332085056; Thu, 15 Nov 2018 17:34:45 -0800 (PST) MIME-Version: 1.0 References: <20180418222905.10414-1-robh@kernel.org> In-Reply-To: From: "jonsmirl@gmail.com" Date: Thu, 15 Nov 2018 20:34:32 -0500 Message-ID: Subject: Re: [RFC PATCH] dt-bindings: add a jsonschema binding example To: robh@kernel.org Cc: Frank Rowand , devicetree@vger.kernel.org, devicetree-spec@vger.kernel.org, lkml , grant.likely@arm.com, Mark Rutland , geert+renesas@glider.be, Linus Walleij , Thierry Reding , Mark Brown , shawnguo@kernel.org, bjorn.andersson@linaro.org, Arnd Bergmann , sboyd@kernel.org, jic23@kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 15, 2018 at 6:42 PM Rob Herring wrote: > > On Wed, Nov 14, 2018 at 1:39 PM jonsmirl@gmail.com wrote: > > > > On Fri, Apr 20, 2018 at 9:36 PM Rob Herring wrote: > > > I share the concern as I doubt most kernel developers don't know > > > jsonschema. But then the alternative is us defining and writing our > > > own thing which is C like 'cause that's what kernel developers > > > understand. My hope is to simplify and restrict things enough that it > > > writing a binding doc is straightforward without being jsonschema > > > experts. That was the intent of this patch without going into all the > > > details behind it. > > > > When schemas were first discussed long, long ago the idea was to have > > a n arbitrator who controls the schema (like Grant/Rob) so there is no > > need for general schema design knowledge in random kernel developers. > > > > First a developer should try and build their device tree using the > > existing schema. Then only if they find that impossible to do so > > should they propose schema changes. The schema arbitrator would then > > look at those changes and work them into the existing schemas as > > needed. Doing this via an arbitrator will ensure consistency in the > > overall schema design while eliminating redundancy with slight > > variations (like we have now). > > > > Another side effect of schemas is that as they evolve and enforce > > commonality among driver implementation it will become possible to > > turn those in-common pieces into driver libraries. > > If we replace 'schemas' everywhere above with 'bindings', then this > pretty much describes the status quo today. Most device specific > bindings are a collection of standard bindings. Occasionally, we have > new common bindings. All the bindings get reviewed by me. The only > real change here is submitters have to have some level of > understanding of json-schema instead of just English (for writing free > form text). I think it will continue to largely be following existing > examples of other bindings. What used to happen is that drivers would be written out of tree without review of their bindings until mainline submission (if they submit them at all). With schema a driver writer who is working out of tree can use the schema to validate their new device tree entries before submitting them. That way they will know ahead of time if they are making up something non-standard. It will also give them the heads up that they can't just make up anything they want in the device tree and that they are going to have to defend their design when asking for the schema to be changed to support it. An example of where schema would have been initially valuable is in the i2c bindings which contain significant variation but the function is the same. Maybe we are thinking about schema differently. I had envisioned starting from a base generic schema that is capable of validating all possible legal Linux device trees. This schema is more strict that YAML syntax, but it obviously can't validate in detail. Someone working out of tree would always be able to validate against this schema. As this generic schema validates the device tree it will discover that it can utilize more strict schema fragments. So by providing these fragments you can validate to any desired level of conformance. The end of that process is the json-schema bindings file. But if those fragments are missing you can still validate, just not at a detailed level. A large set of schemas that work like this are used in ONVIF (security cameras). A flavor of SOAP. https://www.onvif.org/profiles/specifications/ These schemas are using XML stylesheets to make them pretty, use view source to see the actual schemas. The ONVIF schemas define points where vendors are allowed to insert arbitrary items (ANY elements) and then they will use a vendor supplied schema to validate the fragment if one is available. If not the generic schema is used to validate the basic structure of the vendor fragments. > > Rob -- Jon Smirl jonsmirl@gmail.com