From patchwork Tue Nov 12 06:41:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josua Mayer X-Patchwork-Id: 13871758 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E69F0D41D5F for ; Tue, 12 Nov 2024 06:47:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To: In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type: Subject:Date:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=DBP1lqm4a8r+XPGPyakaL2LkPPDwdDkPI1a+IG7CK6w=; b=Vk+66vV3VrlD2+6sP3oBz8JKtQ AByrAh4s1e5Izx4hQKkaQhz74S8d43YvADoiSqaiQJ85sdHakrGphgcpyY5ool8LpF8Oc+eh6Nhgz EEcLZDOhL9Jxv4du4lA3Fg2wCgde/XFtDbHRWNxaPsI+aClZRgfdaOQGSKM+912V9rSQTgkpEm+fT HYwzeUrz5fc8dMiuVkK+aG1GnrQuc+cN5eikYPNYqOJuoSSrxZH7OU5n6CgT4O18Oi4hXLUoJtLyK rMqLkJM4MK7GSrwx2GQCQ9tmzDTg8FecMuP7PJlz4Rve9S2mRE79X1GO/+EDPRVwTUVQh3M+0r3IK u6uUHKQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tAkgG-00000002Moa-4BeX; Tue, 12 Nov 2024 06:47:17 +0000 Received: from mail-vi1eur05on2071d.outbound.protection.outlook.com ([2a01:111:f403:2613::71d] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tAkbE-00000002M29-2NuJ for linux-arm-kernel@lists.infradead.org; Tue, 12 Nov 2024 06:42:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NeDKtHg33/2L5Xe4cSB/mcXz2NoWordWhM46Jv5UK/2cnDrTMgysPMrMU8fW/Vt66WmNg7kbvYwa47Ad2gdUQtE3mtLtjL4AIFXo8ldQCeByDhegTOH0aMJQ45OR0C3rTWO23zU4ElFVmRfFCBJ7o1D1t1Zcy8BRjDWzpBXXf3r8vc189wfXCdSn/OR9k1FqGM3ZzZA03bVSbK6lzhwSkWh7uyRsFZQws6Q3+ZfBi593QS6zMgHuyUxnzBzVVhNg6uaREhmmUW7OCRlRmrPG5+l/ndhIyYK7w6vbFEKTekk164lrgBiEOwv+1C/FGC7mLfhLF0daQmdt1k2YrDQWdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DBP1lqm4a8r+XPGPyakaL2LkPPDwdDkPI1a+IG7CK6w=; b=SekHJfsBPsz9cueSaShq+yqlCJOhRxaIB1PG+/r/4Q8wN/1s4+Eq0HrbnuqZFAy0dm4vvxHduJMO4SRfONc6PKnkmOq2IalQYhz3p6hOaTXjvz+01rBj+Udf2Rg3cW6sdyf1nE71JBwX/gvQyyym920wH/srHO4LMq5AIektXFOs+ZVj8EIueoDbqIbeYkbHGVAMG4iluiMLQpdS++wlpB79KViQfdcQ1Qd425Rd8um7ZOeE8v5UI7U0t9Aq+ZqUwZd03i3MXQ2/7N0bNWpbI2cnvGVVaZd6Ssx8aObaVdYIuNRGCvaIl+sremxVPyWekeizXNjwhzhuJ5DzeQ+6GQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=solid-run.com; dmarc=pass action=none header.from=solid-run.com; dkim=pass header.d=solid-run.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=solidrn.onmicrosoft.com; s=selector1-solidrn-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DBP1lqm4a8r+XPGPyakaL2LkPPDwdDkPI1a+IG7CK6w=; b=XZXcaUmKotSyIxgweOHbOmrfcTfJhEJk15LetMl3VJ/V0P9e1ZsTPOOaiY2RE7lB+NC9u3KOd4Wg1V8cvX8wGSDyor7+ae5nE6U5xVNs9zrTBS5+PTtAoo0+qcjbdomFwrRq4KsDcrvXMHC6sxy8li4eF4ZAkfCjgLYbzwyZT60= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=solid-run.com; Received: from AM9PR04MB7586.eurprd04.prod.outlook.com (2603:10a6:20b:2d5::17) by DU4PR04MB10959.eurprd04.prod.outlook.com (2603:10a6:10:586::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28; Tue, 12 Nov 2024 06:41:54 +0000 Received: from AM9PR04MB7586.eurprd04.prod.outlook.com ([fe80::c04e:8a97:516c:5529]) by AM9PR04MB7586.eurprd04.prod.outlook.com ([fe80::c04e:8a97:516c:5529%4]) with mapi id 15.20.8137.027; Tue, 12 Nov 2024 06:41:54 +0000 From: Josua Mayer Date: Tue, 12 Nov 2024 08:41:32 +0200 Subject: [PATCH 1/2] of: add support for value "false" to of_property_read_bool Message-Id: <20241112-am64-overlay-bool-v1-1-b9d1faff444e@solid-run.com> References: <20241112-am64-overlay-bool-v1-0-b9d1faff444e@solid-run.com> In-Reply-To: <20241112-am64-overlay-bool-v1-0-b9d1faff444e@solid-run.com> To: Rob Herring , Saravana Kannan , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Krzysztof Kozlowski , Conor Dooley Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Geert Uytterhoeven , Josua Mayer , Jon Nettleton , Yazan Shhady , rabeeh@solid-run.com X-Mailer: b4 0.14.2 X-ClientProxiedBy: PA7P264CA0446.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:398::29) To AM9PR04MB7586.eurprd04.prod.outlook.com (2603:10a6:20b:2d5::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB7586:EE_|DU4PR04MB10959:EE_ X-MS-Office365-Filtering-Correlation-Id: 423749e5-5507-4074-405c-08dd02e51900 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?eFwCBxs/qPJqhfHQZJsP5EGfdrmrk9b?= =?utf-8?q?EDszRN7cOKcBhRxFIbc1gi3GaAIfwTVtCDKTqDLiukfXXHDaWGh477jk4B4+K8NBE?= =?utf-8?q?entdya6xmE7LYg8PDnQr+ukqxEb/uxRhuhnshjG46Oa0ANeXuh4qZr+Q+yjyckvZ8?= =?utf-8?q?r8nRKRFUqZLAXErZwJ4VZuSt58suZNAx8q4fVLa19bY7RTT1x3KOvwOA+rmDDCB57?= =?utf-8?q?+QiZv5WKe0o8cFIJkIbjHxsmT0atq39R20LqVPMAnVstcS5HXbVth3BQnSXQ+xWvt?= =?utf-8?q?XA+M+hea22BcrSNLA2kQOO1/ZwTc7f9ILO/VGdEQj6Rw1wj6GCZ7FHnQRaHI3te0q?= =?utf-8?q?zgeT+w1DTTVO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ir+pFgpE6w2tX1spgT13iFLnuGYsTayrzY4JNpAyRyTpIHo7?= =?utf-8?q?9Teuyx9EFzpSN70ogK3xuB1tOJtc1s1YHdN+ygvNs3CABfqeYFHFWbOA=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB7586.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(366016)(1800799024)(52116014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?k62pTEqVQ5qkcvFOJWmd2ayv7XCq?= =?utf-8?q?sGkSYg6duXWpTdB8mCak5+vw4CdpAKw2XntJj6G5maKgY/ogEoVTWosywP7v0eyiG?= =?utf-8?q?FF4ZPWAwuLFLZWd4FZLeZRCwezSh0hUnGDV77sqS9pZR9TJA1NkiQP/fFSH3Grf3q?= =?utf-8?q?ssEc3COfhNtblFRhzZgv37Hr6iLa6DrbroRIMJJQLWCwGZiLHCRlVdnrIOfMcBJyw?= =?utf-8?q?l3DXAoK2edKB6lP15rnKQ5cxhACesu3hYyoaHtnEDyk8y27WdLOTIBrCq6tGp8V2N?= =?utf-8?q?sRWuSu9bCB93ux7Tw5SF8m899IQAZjYBBmG2+ZKlrpQuGJ+x5UNZX2D+U8XZDs/aV?= =?utf-8?q?JRfPUgv0PSNZJ4zaUUWX5j3f3+XCi4DTJgfvxVGrIBsgrhDKUjBs8omd3wGjR/S77?= =?utf-8?q?VC/IlxRt5WHv5kJSlhqAqiMxTEceGY3Jtz2zkVtBw4Sml/Waqx9mFdlZ7caUAb2Sp?= =?utf-8?q?+PV0TlrpqdDOJb2hBbtiKtL1sgkL5hxudc5Ch8GVohFcGcMDdJzA1rP/gU9kOoDiL?= =?utf-8?q?Tc0hMgmTUt0nLi6wRrqeLbrh9DSQC+4nNQyur8wdc0/D5ZLYS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uT0LOl5Ahfu9MX+ZBJ?= =?utf-8?q?Cmd0LXlsEu7QqarHxAMFRg/jL8ZIhw7/qEQD/Flx2HLrU4q6vtstCDUSp0Xtt/exW?= =?utf-8?q?/15hOmkxwBZu?= X-OriginatorOrg: solid-run.com X-MS-Exchange-CrossTenant-Network-Message-Id: 423749e5-5507-4074-405c-08dd02e51900 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB7586.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2024 06:41:54.8175 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a4a8aaf3-fd27-4e27-add2-604707ce5b82 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tYGuxNo9pV0+45AfaluW49HnFKjGY5Ze1SKxkSWJhP9HDZbjtABuyrQtDqf/n3VQsVEl42/6ciFn8bSktFrqKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU4PR04MB10959 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241111_224204_649237_9EAEDDEB X-CRM114-Status: GOOD ( 16.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Boolean type properties are usually considered true if present and false when they do not exist. This works well for many in-tree board dts and existing drivers. When users need to overrride boolean values from included dts includes, /delete-property/ is recommend. This however does not work in overlays (addons). Several places use string "true" ([1], [2], [3]) and one uses string "false" ([1]). This suggests that at some point the value of a type string property was to be taken into account during evaluation. Change of_property_read_bool to only return true if a property is both present, and not equal "false". Existing usage in drivers/of and include/linux/of.h are updated accordingly. Other places should be reviewed as needed wrt. changed semantics. [1] Documentation/devicetree/bindings/sound/rt5651.txt [2] Documentation/devicetree/bindings/sound/pcm3060.txt [3] arch/arm/boot/dts/ti/omap/am335x-baltos.dtsi Signed-off-by: Josua Mayer --- drivers/of/property.c | 2 +- include/linux/of.h | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/of/property.c b/drivers/of/property.c index 11b922fde7af167cc69f6dd89826219653cd1ee8..a51132b883fb3fa0b1a120bacb298abf72f67c5b 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -893,7 +893,7 @@ of_fwnode_device_get_dma_attr(const struct fwnode_handle *fwnode) static bool of_fwnode_property_present(const struct fwnode_handle *fwnode, const char *propname) { - return of_property_read_bool(to_of_node(fwnode), propname); + return of_property_present(to_of_node(fwnode), propname); } static int of_fwnode_property_read_int_array(const struct fwnode_handle *fwnode, diff --git a/include/linux/of.h b/include/linux/of.h index 85b60ac9eec50bb202aa774cab273e1d947e394d..ea65c7d1176194d6ce79432782361f2cdab84f8b 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -1247,14 +1247,15 @@ static inline int of_property_read_string_index(const struct device_node *np, * Search for a boolean property in a device node. Usage on non-boolean * property types is deprecated. * - * Return: true if the property exists false otherwise. + * Return: true if the property exists and value is not "false", + * false otherwise. */ static inline bool of_property_read_bool(const struct device_node *np, const char *propname) { - struct property *prop = of_find_property(np, propname, NULL); + int ret = of_property_match_string(np, propname, "false"); - return prop ? true : false; + return ret == -ENODATA ? true : false; } /** @@ -1268,7 +1269,9 @@ static inline bool of_property_read_bool(const struct device_node *np, */ static inline bool of_property_present(const struct device_node *np, const char *propname) { - return of_property_read_bool(np, propname); + struct property *prop = of_find_property(np, propname, NULL); + + return prop ? true : false; } /** @@ -1679,7 +1682,7 @@ static inline int of_reconfig_get_state_change(unsigned long action, * of_device_is_system_power_controller - Tells if system-power-controller is found for device_node * @np: Pointer to the given device_node * - * Return: true if present false otherwise + * Return: true if enabled, false otherwise */ static inline bool of_device_is_system_power_controller(const struct device_node *np) {