Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2346424rwb; Mon, 19 Sep 2022 03:52:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4YWVVmPMVpaG9CLwEqvPrgtK1bUvM/2vGlHZc9V4NpunjgcAkmVoGDSndqbg9IRzljSnsx X-Received: by 2002:a17:907:80d:b0:73d:a576:dfbd with SMTP id wv13-20020a170907080d00b0073da576dfbdmr12503918ejb.402.1663584764021; Mon, 19 Sep 2022 03:52:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663584764; cv=none; d=google.com; s=arc-20160816; b=YEdGcITEGreOCXDEjnJPFx3tTxqDRN8QiCsxjGDGYKUdPX+QK9KURTtA/8NVJy7xjr qt6gWU3ez4E+j/aaJcBLsWG8qXRy0v+K1i3o/FrzhzbQNngMVlR0w8Ho8lXPx71OSnJa O00FhFf7j6BfT7eqOmnuGDKvRcdRrDk9k/X+QYblagLHPrkfYaSncnrbSeOtkCY3KOo8 tW96Zqh3wsIwFfHUtKF5kosBX+6cBdUVRihhhYLxUBChb1rjksPlk6h3tlHHQrWXB3NU gQTKNeCAnJ1EKxt+FCbn0RbaDtltqI9ANKj+wev1KZ2I3PrwIevYMP9Oy9OZKMfjvJVf 62Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YyW+y/rxVkRLgy/E4VN+LxIObo1zlA1F5pMRfpZjLbA=; b=tPxiKX7Ttd9/FJxEVS2WXM+Jn5+QPdskN1UYU7l5vMQl2LUFyXngjAVp0T3peK6nCh j3BPuQGYJdnvEFEV8p2eCunNp59Y5a0Dvw8rYsumPTCccay85/gBZgd0RyGRvCORGr9z sp01rR0T8bTTJ0rG2ZaMYrF7NOYSld1jQMmZJ8WpKyBuuOhESxDs9PpU8Qa5QU65zkTM ieF5LUYXEKHzCMdQvBcJLxUmawtT0CK130jsH4p5NlD36JnUhvA3dHMSbWXFB/9r7UrH qqiWaOAZegefFm4gWjFrdzqF4P04FnX/gmUpAZoAKtNFsPE5noxoLm+zhi5I/7XR4SOV qLNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b="N4/O/wcA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s19-20020a1709060c1300b007807f3d1e6dsi11434627ejf.599.2022.09.19.03.52.18; Mon, 19 Sep 2022 03:52:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b="N4/O/wcA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229826AbiISKrZ (ORCPT + 99 others); Mon, 19 Sep 2022 06:47:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229885AbiISKqu (ORCPT ); Mon, 19 Sep 2022 06:46:50 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DF82DF1; Mon, 19 Sep 2022 03:33:47 -0700 (PDT) Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EF22D9BA; Mon, 19 Sep 2022 12:33:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1663583625; bh=SuwW1EyzgQFtHXnkLYtahgvyBMXNK3cFjQnbN2kJ/jA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=N4/O/wcAZ+qraUEiBbOU/rymCJTkkfQ4cAj+iNBfH/hk0vtd/vp3c0CHepb84lLYv MkQGfJEqwQvg0rPtCLTmmq56WhZwXqnJoe4rNZ/DZ/bc5YScDJo+ghsBW4XGBAasPk +IiPU0AgyHrjBGQXvCYb3GgRgMFnj7Bz3zO36TmA= Date: Mon, 19 Sep 2022 13:33:31 +0300 From: Laurent Pinchart To: "Lad, Prabhakar" Cc: Krzysztof Kozlowski , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Maxime Ripard , Steve Longerbeam , Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Lad Prabhakar Subject: Re: [PATCH] media: dt-bindings: i2c: ovti,ov5640: Drop ref to video-interface-devices.yaml Message-ID: References: <20220916133521.73183-1-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 19, 2022 at 10:41:00AM +0100, Lad, Prabhakar wrote: > On Mon, Sep 19, 2022 at 10:37 AM Laurent Pinchart wrote: > > On Mon, Sep 19, 2022 at 10:35:21AM +0100, Lad, Prabhakar wrote: > > > On Mon, Sep 19, 2022 at 9:19 AM Krzysztof Kozlowski wrote: > > > > On 19/09/2022 10:08, Lad, Prabhakar wrote: > > > > > On Sun, Sep 18, 2022 at 12:06 AM Laurent Pinchart wrote: > > > > >> On Fri, Sep 16, 2022 at 02:35:21PM +0100, Prabhakar wrote: > > > > >>> From: Lad Prabhakar > > > > >>> > > > > >>> video-interface-devices.yaml isn't used so just drop it from the > > > > >>> DT binding doc. > > > > >>> > > > > >>> Signed-off-by: Lad Prabhakar > > > > >>> --- > > > > >>> Documentation/devicetree/bindings/media/i2c/ovti,ov5640.yaml | 3 --- > > > > >>> 1 file changed, 3 deletions(-) > > > > >>> > > > > >>> diff --git a/Documentation/devicetree/bindings/media/i2c/ovti,ov5640.yaml b/Documentation/devicetree/bindings/media/i2c/ovti,ov5640.yaml > > > > >>> index 540fd69ac39f..ce99aada75ad 100644 > > > > >>> --- a/Documentation/devicetree/bindings/media/i2c/ovti,ov5640.yaml > > > > >>> +++ b/Documentation/devicetree/bindings/media/i2c/ovti,ov5640.yaml > > > > >>> @@ -9,9 +9,6 @@ title: OmniVision OV5640 Image Sensor Device Tree Bindings > > > > >>> maintainers: > > > > >>> - Steve Longerbeam > > > > >>> > > > > >>> -allOf: > > > > >>> - - $ref: /schemas/media/video-interface-devices.yaml# > > > > >>> - > > > > >> > > > > >> The rotation property listed in this binding uses the definition from > > > > >> video-interface-devices.yaml. I don't think just dropping this is the > > > > >> right solution. Changing additionaProperties to unevaluatedProperties > > > > >> seems a better option. > > > > > > > > > > Agreed, I missed rotation was used from video-interface-devices.yaml. > > > > > Agreed the changing additionaProperties to unevaluatedProperties seems > > > > > a better option. > > > > > > > > The meaning of unevaluatedProperties:false would be here - accept other > > > > properties (not mentioned here explicitly) from referenced schema. If > > > > this is your actual intention for this binding, it makes sense. But if > > > > the intention in this binding was to disallow these other properties, > > > > then it would be wrong to change to unevaluatedProperties. > > > > > > > Thank you for the clarification. The intention is to disallow the property. > > > > Why should they be disallowed ? > > my bad! "rotation" property is supposed to be allowed so the earlier > comment to change to unevaluatedProperties holds good. It's not just the rotation. The other properties are allowed too. For the rotation property you need to list it explicitly in ovti,ov5640.yaml if you want to restrict the values it can take, but other properties from video-interface-devices.yaml for which no additional constraints are needed don't need to be listed in ovti,ov5640.yaml. additionalProperties and unevaluatedProperties are often misunderstood. DT bindings are a set of rules, and validation will pass *only* if *all* rules are valid. Let's consider the following: allOf: - $ref: /schemas/media/video-interface-devices.yaml# The allOf is valid if all of the elements in the list are valid. The $ref will essentially work as if the contents of video-interface-devices.yaml were copied in ovti,ov5640.yaml, under the corresponding allOf list entry (with a small but important difference, noted below). The file contains rotation: $ref: /schemas/types.yaml#/definitions/uint32 enum: [ 0, 90, 180, 270 ] so any "rotation" property in the device tree will be validated against this. ovti,ov5640.yaml also has properties: rotation: enum: - 0 - 180 which is a separate rule from the previous one. Both must be valid for validation to succeed, so this second rule essentially restricts the possible rotation values. The additionalProperties and unevaluatedProperties affect how properties that have no validation rule will be treated. With additionalProperties set to false, a property that has no validation rule in *this* schema will be considered invalid, even if it has a validation rule in another schema (either selected automatically through a "select" property in the other schema, or imported through an explicit $ref). So, in this particular example, even though video-interface-devices.yaml has, for instance, a rule for the lens-focus property, a DT that contains lens-focus will be considered as invalid as lens-focus is not validated by this schema. One way to allow the property would be to add properties: lens-focus: true in this schema. The contents of lens-focus would be validated by the rule in video-interface-devices.yaml, and the rule in this schema would always be valid ("true" is always valid). Another way to allow the property would be to replace additionalProperties with unevaluatedProperties. When set to false, unevaluatedProperties makes validation fail if any property has not been evaluated by *any* rule in this schema or any other schema. As lens-focus would be evaluated by video-interface-devices.yaml, that would be enough to consider it valid. This also means that *all* properties listed in video-interface-devices.yaml would then be valid. If you wanted that behaviour, but also wanted to reject specific properties, you could add properties: lens-focus: false in this schema. A lens-focus property in a DT would be valid when evaluated with the corresponding rule in video-interface-devices.yaml, but would be invalidated by the rule in this schema as "false" is always invalid. To conclude, setting additionalProperties to false creates a white listing mechanism that requires you to explicitly list in this schema all the properties you consider as valid with "foo: true", while setting unevaluatedProperties to false creates a black listing mechanism that requires you to explicitly list in this schema all the properties you consider as invalid with "foo: false". If multiple schemas that apply to the same device tree include rules for the same property, all those rules need to be valid for validation to pass, regardless of the value of additionalProperties and unevaluatedProperties. -- Regards, Laurent Pinchart