From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="tRkcgQZv" Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AC5735B5 for ; Wed, 22 Nov 2023 01:09:19 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-9c41e95efcbso895047066b.3 for ; Wed, 22 Nov 2023 01:09:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700644157; x=1701248957; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=MDFjP3+fhsNw2akKUYyFDvgsffeDkDBRgEKMO0HpZCE=; b=tRkcgQZvk4r3sZ43QvVIfizcm3DuRF7HkDVKfBUKzXwl/B3Qw+DdOBtJin+zCO0sTs HvPNDyReX4Acrl35ufgk4ofX/C1lYp0AkRTtg+SWSTrD/kUqrNRPAT9HXBhiUCB4USHF WAlhEcQme492Zmj0FxIfY6frjHrAOgCKW14MCl89wxlP4l7k+kZkN5TYOs0BMEBpAdjb +jMNdU8yFf2ZCiaqBAW0VHSte/ohceNQyPSuP2RAC8qqmMBZ7XlxbL719SHxfrrjE26/ 3pD9n0ZfGvs73ZrIqXLyEGKBCSqsC35SFVDBQLJEvxlxKWp7Sjb0+yu7k8NULi5rqYO9 9+FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700644157; x=1701248957; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MDFjP3+fhsNw2akKUYyFDvgsffeDkDBRgEKMO0HpZCE=; b=NrPHbVYJ1sTbhWxu5BnhJ1rjrPtuypfNCduwD7NweOGDf1whJx7fBlcVcAQiWmAnT0 /Oq9g2GekLVVDX1mvl1x1Puox9MRZFWdNd/jI9qvV5F60ktfhJI13JH7TB/XiBQj+g2u /GI9LUyjwB654rr90E2M7pnHMGsfNq+/htJ3bM4wUmSjHDIGsV+jBM8tVqP9hQo1ZDb0 W2P0aW06J7amduMMffQx1WqboRay6Wo3rpl1AoCzu1eAkm0CTD+OSNB0yqUl4O7VBLwc 3zZ0hbvn7J8RTnv6erjDBBO4en2scUPtscDqZCxNPWIK7fvYG8sAD2gdVkjEvxt6pnP4 oW/w== X-Gm-Message-State: AOJu0Yy9X9HNhuCaGh5LF3BkKmXUY8ceWFVer4NM0NqLekvVNHooA2v9 PS13AsPdlQ0NsP3KpGuiZDaVCw== X-Google-Smtp-Source: AGHT+IFZl7wEgdnoEFdZt9B2cqKnVzkpgrZ9sNjK/LyuMgkAxnpNZnVfrON3J8adQtDbtSUeNatAmw== X-Received: by 2002:a17:906:f0c2:b0:9fc:1236:beff with SMTP id dk2-20020a170906f0c200b009fc1236beffmr1098949ejb.65.1700644157026; Wed, 22 Nov 2023 01:09:17 -0800 (PST) Received: from [192.168.1.20] ([178.197.218.100]) by smtp.gmail.com with ESMTPSA id o15-20020a17090637cf00b009fee12d0dcdsm3392502ejc.15.2023.11.22.01.09.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Nov 2023 01:09:16 -0800 (PST) Message-ID: <2ced2e38-e81d-4f9b-a6c0-6ac2d1a0fff9@linaro.org> Date: Wed, 22 Nov 2023 10:09:14 +0100 Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] docs: dt-bindings: add DTS Coding Style document Content-Language: en-US To: Michal Simek , Geert Uytterhoeven Cc: Dragan Simic , wens@kernel.org, =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Andrew Davis , Arnd Bergmann , Bjorn Andersson , Heiko Stuebner , Konrad Dybcio , Neil Armstrong , Nishanth Menon , Olof Johansson , linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-msm@vger.kernel.org References: <20231120084044.23838-1-krzysztof.kozlowski@linaro.org> <6b288a2e-d147-4bd3-b1d4-daf56295d939@gmail.com> <01f9ce3b-e6e5-4b05-bf7f-0b3a5f74910a@linaro.org> <7232a48b-b9ad-44b5-ae6a-d12dad70b3c4@linaro.org> <58a9caacc1226c7c3a2bdfe73ef1791f@manjaro.org> <808270d3-2274-4fb7-a397-38538503b67c@amd.com> From: Krzysztof Kozlowski Autocrypt: addr=krzysztof.kozlowski@linaro.org; keydata= xsFNBFVDQq4BEAC6KeLOfFsAvFMBsrCrJ2bCalhPv5+KQF2PS2+iwZI8BpRZoV+Bd5kWvN79 cFgcqTTuNHjAvxtUG8pQgGTHAObYs6xeYJtjUH0ZX6ndJ33FJYf5V3yXqqjcZ30FgHzJCFUu JMp7PSyMPzpUXfU12yfcRYVEMQrmplNZssmYhiTeVicuOOypWugZKVLGNm0IweVCaZ/DJDIH gNbpvVwjcKYrx85m9cBVEBUGaQP6AT7qlVCkrf50v8bofSIyVa2xmubbAwwFA1oxoOusjPIE J3iadrwpFvsZjF5uHAKS+7wHLoW9hVzOnLbX6ajk5Hf8Pb1m+VH/E8bPBNNYKkfTtypTDUCj NYcd27tjnXfG+SDs/EXNUAIRefCyvaRG7oRYF3Ec+2RgQDRnmmjCjoQNbFrJvJkFHlPeHaeS BosGY+XWKydnmsfY7SSnjAzLUGAFhLd/XDVpb1Een2XucPpKvt9ORF+48gy12F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/tHAcUF35hSJrvMJzPT/+u /oVmYDFZkbLlqs2XpWaVCo2jv8+iHxZZ9FL7F6AHFzqEFdqGnJQqmEApiRqH6b4jRBOgJ+cY qc+rJggwMQcJL9F+oDm3wX47nr6jIsEB5ZftdybIzpMZ5V9v45lUwmdnMrSzZVgC4jRGXzsU EViBQt2CopXtHtYfPAO5nAkIvKSNp3jmGxZw4aTc5xoAZBLo0OV+Ezo71pg3AYvq0a3/oGRG KQ06ztUMRrj8eVtpImjsWCd0bDWRaaR4vqhCHvAG9iWXZu4qh3ipie2Y0oSJygcZT7H3UZxq fyYKiqEmRuqsvv6dcbblD8ZLkz1EVZL6djImH5zc5x8qpVxlA0A0i23v5QvN00m6G9NFF0Le D2GYIS41Kv4Isx2dEFh+/Q== In-Reply-To: <808270d3-2274-4fb7-a397-38538503b67c@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 22/11/2023 09:57, Michal Simek wrote: > Hi Geert, > > On 11/22/23 09:53, Geert Uytterhoeven wrote: >> Hi Michal, >> >> On Wed, Nov 22, 2023 at 9:50 AM Michal Simek wrote: >>> On 11/22/23 09:29, Dragan Simic wrote: >>>> On 2023-11-22 09:21, Krzysztof Kozlowski wrote: >>>>> On 22/11/2023 09:09, Chen-Yu Tsai wrote: >>>>>> On Wed, Nov 22, 2023 at 4:05 PM Krzysztof Kozlowski >>>>>> wrote: >>>>>>> >>>>>>> On 21/11/2023 14:50, Rafał Miłecki wrote: >>>>>>>>> +Order of Properties in Device Node >>>>>>>>> +---------------------------------- >>>>>>>>> + >>>>>>>>> +Following order of properties in device nodes is preferred: >>>>>>>>> + >>>>>>>>> +1. compatible >>>>>>>>> +2. reg >>>>>>>>> +3. ranges >>>>>>>>> +4. Standard/common properties (defined by common bindings, e.g. without >>>>>>>>> + vendor-prefixes) >>>>>>>>> +5. Vendor-specific properties >>>>>>>>> +6. status (if applicable) >>>>>>>>> +7. Child nodes, where each node is preceded with a blank line >>>>>>>>> + >>>>>>>>> +The "status" property is by default "okay", thus it can be omitted. >>>>>>>> >>>>>>>> I think it would really help to include position of #address-cells and >>>>>>>> #size-cells here. In some files I saw them above "compatible" that seems >>>>>>>> unintuitive. Some prefer putting them at end which I think makes sense >>>>>>>> as they affect children nodes. >>>>>>>> >>>>>>>> Whatever you choose it'd be just nice to have things consistent. >>>>>>> >>>>>>> This is a standard/common property, thus it goes to (4) above. >>>>>> >>>>>> It's probably a mix, but AFAIK a lot of the device trees in tree have >>>>>> #*-cells after "status". In some cases they are added in the board >>>>>> .dts files, not the chip/module .dtsi files. >>>>> >>>>> Existing DTS is not a good example :) >>>>> >>>>>> >>>>>> +1 that it makes sense at the end as they affect child nodes. >>>>> >>>>> I still insist that status must be the last, because: >>>>> 1. Many SoC nodes have address/size cells but do not have any children >>>>> (I2C, SPI), so we put useless information at the end. >>>>> 2. Status should be the final information to say whether the node is >>>>> ready or is not. I read the node, check properties and then look at the end: >>>>> a. Lack of status means it is ready. >>>>> b. status=disabled means device still needs board resources/customization >>>> >>>> I agree with the "status" belonging to the very end, because it's both logical >>>> and much more readable. Also, "status" is expected to be modified in the >>>> dependent DT files, which makes it kind of volatile and even more deserving to >>>> be placed last. >>> >>> I am just curious if having status property at the end won't affect >>> execution/boot up time. Not sure how it is done in Linux but in U-Boot at least >>> (we want to have DTs in sync between Linux and U-Boot) of_find_property is >>> pretty much big loop over all properties. And status property defined at the end >>> means going over all of them to find it out to if device is present. >>> Not sure if Linux works in the same way but at least of_get_property is done in >>> the same way. >> >> As the default is "okay", you have to loop over all properties anyway. > > No doubt if you don't define status property that you need to loop over all of > them. We normally describe the whole SOC with pretty much all IPs status = > disabled and then in board file we are changing it to okay based on what it is > actually wired out. > It means on our systems all nodes have status properties. If you have it at > first you don't need to go over all. We never sacrificed code readability in favor of code execution speed, so neither should we do it here. If the speed is a problem, project can still add a flag to dtc to re-shuffle properties in FDT depending on its needs. Best regards, Krzysztof