From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C30F8C77B7C for ; Fri, 26 May 2023 05:56:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232211AbjEZF4v (ORCPT ); Fri, 26 May 2023 01:56:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229479AbjEZF4u (ORCPT ); Fri, 26 May 2023 01:56:50 -0400 Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A3B4E7 for ; Thu, 25 May 2023 22:56:49 -0700 (PDT) Received: by mail-qv1-xf2a.google.com with SMTP id 6a1803df08f44-623852980dfso3587956d6.0 for ; Thu, 25 May 2023 22:56:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1685080608; x=1687672608; h=in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:from:to:cc:subject:date:message-id:reply-to; bh=tgXESvvpBdKfPykD1OIAH+2kHSLLh3i8sS02spinTlU=; b=fJxx57TlNlWjJn+T/e88NSrjkoqniogo3I0rgINUA9fqZT+Kmz3/5fDOK+HAmAqfqa WMIvEf2mEXrCx/ikk5z4L3FhetP3ic5q21X3h0fMSpyQr1D+eu9Av65DM3Cjr6Tu5+DV Voo7/8EPx1pN9xz9r+nASVmwq648XUoJSd9DU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685080608; x=1687672608; h=in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tgXESvvpBdKfPykD1OIAH+2kHSLLh3i8sS02spinTlU=; b=Ub2geyac0QJJK18s0VkYTP+Pe/NSLTrMNkNjuvdDjGEKktxxZG6ZAhkiD3a+j5gAqT /2xUs9oXr1fa3Hj5JzIhWi33e42Ep3qN0JRQd5qSez2amO6MqQmNKfgnSynTru4fnmND LPEfTDwN92+eVFyyQBphOF0GwqbEBTk7pUyqa5FPnImxYwfLCCMwOyHZ3mPMyCSddgY9 jc+VfW7wDUEdTsNubzfiVjqUzUoU+D+XFPKa8KwJG7JsJexfkkegAaX9qCjkNht3+ZPx mnjPuDK5vCDl4cfxse2T82IgD1s3AI+XjHmO8jwb2s0IlcHV7DgFSE+aKihhrQxk7YUJ 5xXA== X-Gm-Message-State: AC+VfDwqW905tIgwX48ej4AqfqAM42fs/zkCBzcjXB9m/zC4+uuc7BoJ E8A15CBMmdjhfTAJ4qavU5hH9w== X-Google-Smtp-Source: ACHHUZ5aRUOapKQTIHnn28eRFWQCc52hzwhT8+n+QDGemkZA3kUbXyd7Wbz9emBYmeel93N56vRCwQ== X-Received: by 2002:a05:6214:19cd:b0:623:9f35:edd5 with SMTP id j13-20020a05621419cd00b006239f35edd5mr885875qvc.42.1685080608263; Thu, 25 May 2023 22:56:48 -0700 (PDT) Received: from bcacpedev-irv-3.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id a2-20020a0ce342000000b006238888dbffsm961108qvm.139.2023.05.25.22.56.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 May 2023 22:56:47 -0700 (PDT) Subject: Re: dt_binding_check report false alarm? To: Conor Dooley Cc: Conor Dooley , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, f.fainelli@gmail.com, Krzysztof Kozlowski , Rob Herring References: <20230525050241.3700-1-william.zhang@broadcom.com> <20230525-wrench-lushness-f9a1ad022798@wendy> <00604ffd-ccb3-e640-5457-1fa1ed663d26@broadcom.com> <20230525-unlearned-trusting-1ed0cf6a6364@spud> <20230525-mating-mutt-36a506094d38@spud> From: William Zhang Message-ID: <58dbfc50-45ac-389d-10aa-740aee150b16@broadcom.com> Date: Thu, 25 May 2023 22:56:45 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20230525-mating-mutt-36a506094d38@spud> Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="00000000000018e3b705fc9267bd" Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org --00000000000018e3b705fc9267bd Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 05/25/2023 11:12 AM, Conor Dooley wrote: > On Thu, May 25, 2023 at 10:10:46AM -0700, William Zhang wrote: >> >> >> On 05/25/2023 08:33 AM, Conor Dooley wrote: >>> On Thu, May 25, 2023 at 08:23:30AM -0700, William Zhang wrote: >>>> Sorry for the multiple emails. Our mail relay server was not working >>>> properly. >>> >>> I only got one /shrug >>> >> That's good. Maybe it only flushed queued email to internal email accounts. >> >>>> On 05/25/2023 06:23 AM, Conor Dooley wrote: >>>>> Hey William, >>>>> >>>>> On Wed, May 24, 2023 at 10:02:41PM -0700, William Zhang wrote: >>>>>> Hi, >>>>>> >>>>>> It seems dt_binding_check reports a false error when run on this >>>>>> modified yaml. I picked this simple file just to demostrate this issue. >>>>>> Basically I made the interrupts and interrupt-names as optional >>>>>> properties. But when there are two interrupts present, then >>>>>> interrupt-names are required. However in the example, I don't define >>>>>> interrupts and interrupt-name at all, the dt binding check reports error >>>>>> that interrupt-names are required: >>>>> >>>>> Rob and Krzysztof would know more than me, but since they're not >>>>> around... >>>>> >>>>>> diff --git a/Documentation/devicetree/bindings/crypto/fsl-imx-scc.yaml b/Documentation/devicetree/bindings/crypto/fsl-imx-scc.yaml >>>>>> index 563a31605d2b..c37a3a64a78c 100644 >>>>>> --- a/Documentation/devicetree/bindings/crypto/fsl-imx-scc.yaml >>>>>> +++ b/Documentation/devicetree/bindings/crypto/fsl-imx-scc.yaml >>>>>> @@ -32,11 +32,18 @@ properties: >>>>>> clock-names: >>>>>> const: ipg >>>>>> +allOf: >>>>>> + - if: >>>>>> + properties: >>>>>> + interrupts: >>>>>> + minItems: 2 >>>>> >>>>> ...I don't think you can actually do this and "minItems: 2" will always >>>>> evaluate to true because it is an assignment. Don't hold me to that >>>>> though! The standard pattern here is to do: >>>>> allOf: >>>>> - if: >>>>> properties: >>>>> compatible: >>>>> contains: >>>>> const: foo >>>>> then: >>>>> required: >>>>> - interrupt-names > >>>> Our device can use one or two interrupt, or choose to not use interrupt at >>>> all(polling mode). Interrupt names is only required when there are two >>>> interrupts(so the driver code can tell which is which). So I will need to >>>> check if it contains two interrupts. My check does work if I have two >>>> interrupt but don't have interrupt name, the check catches the error. If I >>>> have one interrupt without interrupt name, the check pass. Only when I does >>>> not have interrupt and interrupt name, it falsely report error. Looks to >>>> me that it does not treat minItem = 0 case properly. >>> >>> Right. I would not bother with the "only interrupt-names when 2 >>> interrupts" stuff & do the simple thing of always making it required >>> when you have interrupts. >>> Then you can use allOf and oneOf to allow for both schemes for the new >>> device and keep enforcement of 2 items for the existing one. > >> I agree it is better to keep it simple. Sorry I am still new to yaml but >> what is the best way to check if interrupt property exist? What I can think >> of is similar >> >> - if: >> properties: >> interrupts: >> minItems: 1 >> then: >> required: >> - interrupt-names >> >> But this still reports the same error when there is no interrupt. > > Yeah, you don't need to do something like that. > It's hard to say exactly without your actual patch, but I think you're > over complicating things :) > What you seem to want to do (from where I am sitting) is something like: > dependencies: > interrupts: interrupt-names > > and not put interrupts/interrupt-names in the required bit. > That way, if you have interrupts, you need to have interrupt-names too > but you can have neither. > > But yeah, without something resembling the "real" patch, rather than > hacking at the fsl one, it is kinda hard to say. > > Cheers, > Conor. > > Yeah this dependencies rule works and it is much simple. Just need to add the bracket around the interrupt-names to make it work: dependencies: interrupts: [interrupt-names] Do we have any document list all these supported keywords/rules/syntax for yaml dts? My file is actually brcm,brcmnand.yaml but it is little bit complicated to demonstrate the issue so just randomly pick this simple one. Thanks Conor, Robin and all the for help. Will submit an official patches for brcmnand.yaml change. >> >>>>>> + then: >>>>>> + required: >>>>>> + - interrupt-names >>>>>> + >>>>>> required: >>>>>> - compatible >>>>>> - reg >>>>>> - - interrupts >>>>>> - - interrupt-names >>>>>> - clocks >>>>>> - clock-names >>>>>> @@ -49,6 +56,4 @@ examples: >>>>>> reg = <0x53fac000 0x4000>; >>>>>> clocks = <&clks 111>; >>>>>> clock-names = "ipg"; >>>>>> - interrupts = <49>, <50>; >>>>>> - interrupt-names = "scm", "smn"; >>>>>> }; >>>>>> -- >>>>>> 2.34.1 >>>>>> >>>>> >>>>> >>> >>> > > --00000000000018e3b705fc9267bd Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIIQcAYJKoZIhvcNAQcCoIIQYTCCEF0CAQExDzANBglghkgBZQMEAgEFADALBgkqhkiG9w0BBwGg gg3HMIIFDTCCA/WgAwIBAgIQeEqpED+lv77edQixNJMdADANBgkqhkiG9w0BAQsFADBMMSAwHgYD VQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UE AxMKR2xvYmFsU2lnbjAeFw0yMDA5MTYwMDAwMDBaFw0yODA5MTYwMDAwMDBaMFsxCzAJBgNVBAYT AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMTEwLwYDVQQDEyhHbG9iYWxTaWduIEdDQyBS MyBQZXJzb25hbFNpZ24gMiBDQSAyMDIwMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA vbCmXCcsbZ/a0fRIQMBxp4gJnnyeneFYpEtNydrZZ+GeKSM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