Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1196645ybl; Wed, 18 Dec 2019 14:27:51 -0800 (PST) X-Google-Smtp-Source: APXvYqwbBnuVfIgFbzDJMthfDDqGwxLka6/6os0GS5mvAZJGdZEfdfCwR4ZzZj0Ag2vfab7XZn/W X-Received: by 2002:a9d:4e97:: with SMTP id v23mr4838249otk.201.1576708070872; Wed, 18 Dec 2019 14:27:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576708070; cv=none; d=google.com; s=arc-20160816; b=BTJRlQJEctHPIlihRDcmJ/6gKrUdrqVm8AhDD8u27Rmmm3KF+0nGjXgfetDF7C/lrz TdlBoz6NisMgOAykblJ3ovFO9BUt+ksFKHYPehbHuFyKyYn3uD4XhAwZwAyIWA3aSqST IWHkNCr+g/Sj25XsML4YOR5ZW1ioiEeGFhdGaLYPvkoeVE6/zjTzxLv6AEpnjsaEVrGE emw7hxoXPNB5qFyRR9I9px7NSnznKrr1d3oBc12ryNfYLjXitvk4LlbXiX43REz0t/0+ VTlEc5Wnw/m3Q/54XBnIeqMqIw8Tu/+NpDm/Ylayzb/TOdY5RTUKJcSuz91WaIfUD+Jh GHMA== 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=qbWs72DR5XCjtRMaVF/M12LG91Dcbzm+NrYCmOJf9Lc=; b=KOmtWOZza0/Oays081bwsQlQVPOeWwS1Jw5gNZ+isu+nR8DFsHT1+xr+UFzW2SGyKm /YfmNb+tHnuzPsiuAvl97dmHZSeEBIbJPidwNehcY6Y0HvxepiffDDB+0uH2s0wj+8Cv eBm8nil8p9IHZ31c3ksJEeGlMbKKrk1986x+jzOd+97wafQYJ1l62pUaE4hS1yaqn0yY H7UXqbLdhBGmZbOXLnpJ1lDgZs69jLsDEYq6+uDfuKaI7+BN0e9hzl7WMbwZmkHAGELk AMHTzWxxznXz07hb34MCLJHbKV3SALmxTMZN/eb9DznjvcVW2naUzcoI7mc2wA6BLnhv oH/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OZHoOkf1; 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 t142si2120175oih.242.2019.12.18.14.27.38; Wed, 18 Dec 2019 14:27:50 -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=OZHoOkf1; 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 S1726571AbfLRW1A (ORCPT + 99 others); Wed, 18 Dec 2019 17:27:00 -0500 Received: from mail-qv1-f67.google.com ([209.85.219.67]:37473 "EHLO mail-qv1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726387AbfLRW07 (ORCPT ); Wed, 18 Dec 2019 17:26:59 -0500 Received: by mail-qv1-f67.google.com with SMTP id f16so1427202qvi.4; Wed, 18 Dec 2019 14:26:58 -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=qbWs72DR5XCjtRMaVF/M12LG91Dcbzm+NrYCmOJf9Lc=; b=OZHoOkf1lqlbsaOVytx/DPVbIJ4Y4RNrRnNOBsWJ6dcfMbMlcZ7n+0XfDcT+K3t08T zC615ySso5IGKCAfkh6MdB/2310SS8ETuKJd7E7NT13g8NCxJEyii7IFaoRBAZQzfxqD 8MZxvCzVsglZniBhYzQR319BsQog2IXIP5RTmVzimyKm7jErJtVG1XkB83IBAnaTtNFQ dknJSx7p9lLTNk+V4NDLNsGr0naOcOKgXH169MW8aqr6xJ9a0Fenvzx72MQ2mWsrAiTU uT6gbG0gQruuORDjZjY+HgwvgD5mZh4HoQIx3IMG1Qk5r2QqA8dZnCcLC5IvWzGAlHWd k/AA== 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=qbWs72DR5XCjtRMaVF/M12LG91Dcbzm+NrYCmOJf9Lc=; b=Dqp6+pFNpU/F+Lbi44GZYlfcijjQ5wYAAscckmzhGxtm5Pfw1gBgFeWPvXPBzS6i6z 39UHzKrkodtO9nwjYQmR+X04R20g+u7PiwswadoBw3iq4mT0al+U/BgBXpd+65QfuzEq WFJcgXvp/HSyScNR3YDFTaHP6Q/B6Kv87xU+GXqQcAZbxj2l3Nv+RrqgiBVfGnYkboyY dsazSjsddhqK0D2VHGkowWyoCizlLjzOVR7DFghjUPA/Ed57a6BzSyzpCjh59lg0tZK2 ve5Wqroo7mi0zCBLebQw6Ghv15gbirgXRrsQSdtv6DEo5w+NwdsGYcdLQBZaMeQmxLi+ 7ozQ== X-Gm-Message-State: APjAAAX5+eG38FwtubZoGxsqHawEE5DDMpX/HiWRgzyleus/pyy0NyBo uo2bAyFk84LJ0smwKMB7rynlVAWCyPyoPcd1mGc= X-Received: by 2002:ad4:450a:: with SMTP id k10mr4512847qvu.136.1576708017893; Wed, 18 Dec 2019 14:26:57 -0800 (PST) MIME-Version: 1.0 References: <20191218042121.1471954-1-anarsoul@gmail.com> <20191218042121.1471954-3-anarsoul@gmail.com> <20191218220037.4g6pzdvrhroaj4qu@gilmour.lan> In-Reply-To: <20191218220037.4g6pzdvrhroaj4qu@gilmour.lan> From: Vasily Khoruzhick Date: Wed, 18 Dec 2019 14:27:00 -0800 Message-ID: Subject: Re: [PATCH v7 2/7] dt-bindings: thermal: add YAML schema for sun8i-thermal driver bindings To: Maxime Ripard Cc: Yangtao Li , Zhang Rui , Daniel Lezcano , Amit Kucheria , Rob Herring , Mark Rutland , Chen-Yu Tsai , Mauro Carvalho Chehab , "David S. Miller" , Greg Kroah-Hartman , Linux PM , devicetree , arm-linux , =?UTF-8?Q?Ond=C5=99ej_Jirman?= , linux-kernel 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 Wed, Dec 18, 2019 at 2:00 PM Maxime Ripard wrote: > > Hi, > > On Tue, Dec 17, 2019 at 08:21:16PM -0800, Vasily Khoruzhick wrote: > > From: Yangtao Li > > > > sun8i-thermal driver supports thermal sensor in wide range of Allwinner > > SoCs. Add YAML schema for its bindings. > > > > Signed-off-by: Yangtao Li > > Signed-off-by: Vasily Khoruzhick > > --- > > .../thermal/allwinner,sun8i-a83t-ths.yaml | 146 ++++++++++++++++++ > > 1 file changed, 146 insertions(+) > > create mode 100644 Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.yaml > > > > diff --git a/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.yaml b/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.yaml > > new file mode 100644 > > index 000000000000..8768c2450633 > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.yaml > > @@ -0,0 +1,146 @@ > > +# SPDX-License-Identifier: GPL-2.0 > > +%YAML 1.2 > > +--- > > +$id: http://devicetree.org/schemas/thermal/allwinner,sun8i-a83t-ths.yaml# > > +$schema: http://devicetree.org/meta-schemas/core.yaml# > > + > > +title: Allwinner SUN8I Thermal Controller Device Tree Bindings > > + > > +maintainers: > > + - Yangtao Li > > + > > +properties: > > + compatible: > > + enum: > > + - allwinner,sun8i-a83t-ths > > + - allwinner,sun8i-h3-ths > > + - allwinner,sun8i-r40-ths > > + - allwinner,sun50i-a64-ths > > + - allwinner,sun50i-h5-ths > > + - allwinner,sun50i-h6-ths > > + > > + reg: > > + maxItems: 1 > > + > > + interrupts: > > + maxItems: 1 > > + > > + resets: > > + maxItems: 1 > > + > > + nvmem-cells: > > + maxItems: 1 > > + description: Calibration data for thermal sensors > > + > > + nvmem-cell-names: > > + const: calibration > > + > > +allOf: > > + - if: > > + properties: > > + compatible: > > + contains: > > + const: allwinner,sun50i-h6-ths > > + > > + then: > > + properties: > > + clocks: > > + minItems: 1 > > + maxItems: 1 > > When minItems and maxItems are equal, you can only set one, the other > will be filled automatically. Is it documented anywhere? I have a feeling like I'm shooting in the dark. So far I've read Documentation/devicetree/writing-schema.rst, Documentation/devicetree/bindings/example-schema.yaml and few other schemas for inspiration but yet I don't have solid understanding how it's supposed to be written. Examples are pretty scarce and figuring out why certain construction doesn't work is pretty tricky. > > + > > + clock-names: > > + minItems: 1 > > + maxItems: 1 > > + items: > > + - const: bus > > And this can even be just > > clock-names: > const: bus OK > > + > > + else: > > + properties: > > + clocks: > > + minItems: 1 > > + maxItems: 2 > > + > > + clock-names: > > + minItems: 1 > > + maxItems: 2 > > + items: > > + - const: bus > > + - const: mod > > I'm not sure why you need the minItems set to 1 here though? > > it's always 2 for the !H6 case, right? > > if so, then we should even do something like: > > properties: > ... > > # This is needed because we will need to check both the H6 and !H6 > # case, and it must validate. So we make sure we match against the > # union of both cases. > clocks: > minItems: 1 > maxItems: 2 > items: > - description: Bus Clock > - description: Module Clock > > # Same story here > clock-names: > minItems: 1 > maxItems: 2 > items: > - const: bus > - const: mod > > allOf: > - if: > properties: > compatible: > contains: > const: allwinner,sun50i-h6-ths > > # Here we validate in the H6 case we only have one clock > then: > properties: > clocks: > maxItems: 1 > > clock-names: > maxItems: 1 > > # and here that in the other case we have two clocks, the names > # being validated by the schema above > else: > properties: > clocks: > maxItems: 2 > > clock-names: > maxItems: 2 > > # And now we can set this since all our properties will have been > # expressed in the upper level schema > additionalProperties: false OK > > + > > + - if: > > + properties: > > + compatible: > > + contains: > > + const: allwinner,sun8i-h3-ths > > + > > + then: > > + properties: > > + "#thermal-sensor-cells": > > + const: 0 > > + > > + else: > > + properties: > > + "#thermal-sensor-cells": > > + const: 1 > > Same thing here, you should have an enum accepting both values in the > upper schema, the condition here only making further checks. Also, in > the case where #thermal-sensor-cells is one, then you need to document > what that argument is. OK > > Thanks! > Maxime