From patchwork Mon Dec 11 03:03:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13486583 X-Patchwork-Delegate: kieran@bingham.xyz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=renesas.com header.i=@renesas.com header.b="YCWnTDzZ" Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01on2126.outbound.protection.outlook.com [40.107.113.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D00ACE; Sun, 10 Dec 2023 19:03:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CB24vPZOdWpHHkmixmNRv+BRD242/YtwSiy3MAZYwHk8YmygnpwdH7YBBh/qQ/7hcVyBJNcYCC+tHWP9XCQPS5VbWjVwdr6gv+R7IorHD4HfwIcIjT8Ylh7iWH8dFGVJe+Chfg/nBrEJeNoGTJJd7bVwQq8LJVnAdHDoBJkW/FANEvDYAKADLdlnRc9ewYSyQDON+62oOLvyKoYNFB0JdRKIvvyGwGipjqUaNvexnixXXBMYY1ZKScDZGBgog7Wnko02V9IX2SVxyVBiuIpBTu7mGIE7u2n796lV4CnmGh5cJMqMRdmrdTgC0PaWu8UfHPfljzVvSOc+EibmU2txtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=r13OWdxPFLvNkCATiQvwBjyKSaerWJzbIouZsgZlUWw=; b=Nzl3lWFj/dC5drcirlUqf5F0B/vlESKENhMnQc7ST6qm/BctCv2zOc6Y9QK8pXcD5JFhH5o15wEqmfRilcNgbi3AdGPi7NgE5ZOCMiPuWedvDounYanS4l1gaPDWYhUKa5+4JK1n8hSiUyBDqZ+yRWFnIZx8hwvVYFBQfU5Pi+XvCv0YewKpntYCk8Odk+lARCEjmcAm+txVhjQBucJIN8H7OC1SSiglY9uN74wrRvYzNfA65veEasURwimxUpoNZzPAbkD3ifMHKUwZihTo2VlTG4B5OsiqJqD1y4YWMgOJfZ/MMI7zv+NcqR7DJnhJX1RzCcPEAt2achq2RfKhmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=renesas.com; dmarc=pass action=none header.from=renesas.com; dkim=pass header.d=renesas.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesas.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r13OWdxPFLvNkCATiQvwBjyKSaerWJzbIouZsgZlUWw=; b=YCWnTDzZ++Su63nfNlM70xLrEX1pL9n9GKZiqAucOIKkb4KPdX544h0ztrdnAT8yirkhGqVBoUR8Nj21lL8De/Chs+uo3+oZEMCeIHwgx+jjGBiYq0sWB30mmudax6q07q2q/RvUOd16k7barFioJv8lFomveywftn/QCiHXCAQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=renesas.com; Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) by TYCPR01MB11269.jpnprd01.prod.outlook.com (2603:1096:400:3c0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.21; Mon, 11 Dec 2023 03:03:18 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::5732:673b:846c:ed92]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::5732:673b:846c:ed92%4]) with mapi id 15.20.7091.020; Mon, 11 Dec 2023 03:03:18 +0000 Message-ID: <87sf49o2yx.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v4 3/4] of: add for_each_reserved_child_of_node() User-Agent: Wanderlust/2.15.9 Emacs/27.1 Mule/6.0 To: Frank Rowand , Geert Uytterhoeven , Michael Turquette , Rob Herring , Stephen Boyd Cc: Rob Herring , devicetree@vger.kernel.org, linux-clk@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Aymeric Aillet , Yusuke Goda In-Reply-To: <87wmtlo2zs.wl-kuninori.morimoto.gx@renesas.com> References: <87wmtlo2zs.wl-kuninori.morimoto.gx@renesas.com> Date: Mon, 11 Dec 2023 03:03:18 +0000 X-ClientProxiedBy: TYAPR04CA0007.apcprd04.prod.outlook.com (2603:1096:404:15::19) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|TYCPR01MB11269:EE_ X-MS-Office365-Filtering-Correlation-Id: e891d529-ed1c-44f7-1b91-08dbf9f5b9fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DX/mSaTq8aX2XDf6fcIYo+8AqvcHgQ3SeEnmi3rh2n6Amg6LHlt4cKCJdz3xEDu/zc0RE3Rs/+FmruNIxUJyodcsBBZVRjJZq4PB9UaC0B+7l9PVF/YevK+P/EkziDuIPc4lRlgaMLa6eNgvKNUPtiMp6DPYmwE8FteXTVDpUO2P2aVOYmsTYuTwLDU5rgW4FQE9mx7oEk5hagI9i0GTbwRPaG8SEUW8GA2y53SwwDOghbdEV79vKUHRl3DukMWsJQJ5TDm9illeGx0UVrDtFvUgXN7gW9kUi3U0fnrcUlp0ORhPJ0KHULGjwsDRKC/W4PXQPKd7LEbzKRw3NGjeP7hgU7XelVWFVhwAZz2Vdolt5hK0jLVx5I40DPGazawnPg+9tm9D29aB7IFct3sP37Uc5XSWWJO8AaWriSwAfUYOxlsKJs7AqWDgYW2VqYcy9/IRb/kjYMT8cYD9wAw+xs1EUMmt9IW06NCak95dzYykokugf9FXhx0DXy3PLX+kPnBT13dx5efViKk/7ItbyF7ZGqyDrNrv/HQ8vtvHIxUDXfm78LCLjo5Pr3tt8aOqKafuW4uZiytO5IDE9McSGFyCzicHk8yvc/f3gK7yCcsjF85tIPDYHAy6uzesW00Y X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYCPR01MB10914.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(366004)(396003)(136003)(376002)(346002)(230922051799003)(451199024)(64100799003)(1800799012)(186009)(6512007)(6506007)(5660300002)(26005)(2616005)(107886003)(36756003)(7416002)(54906003)(66476007)(66556008)(66946007)(6486002)(2906002)(83380400001)(41300700001)(38350700005)(478600001)(86362001)(8676002)(8936002)(4326008)(52116002)(110136005)(316002)(38100700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zmpCW2w0SAHhCwX7HXLOBkmmlSJoyQXJ752HqN9LaVyCDzRjn+SD/bX2DoCtWcWhQ19nh/N+2MyTshGsb4D3kd0Z68sasFROxRWBo32Pxwnx+cZ+IAiqHOnWRoXZPVyZchTqmsSyhzv+yV8WjTiivkVaZGtpj0E6ySJG54l93mMpGcj9oir3vGfEV6hq/gzByfOIOYBG8sKCsWcuONEpN4Vuigghf9xYAT8FgFgD3UleTkZkReDFBFJvwZl3m7KU5iBOVAv/xPgLJfUjE21Rhi3jTneULEwYIDFXfQGbFm7kR3/kmFMNEHE7XoQf5yzXKmTJDq0tG6ezdsm22ctParkPpnSsHSHs9RTv8fwsNvHZWj9Y5WX2p2/nea4t7eXLpqHcQitKoduIooo1OWNUNJov/20YbSj9I/CizYQjLkzUAHyFrRwF9bCTbsPdD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WDAEMI3tguNMigLvfYuXmNkICVxyhMLhpVbBg6MdYCW46JNMzE0YY/SfZUyb92LQxJMF2aF+p6HFsGau5m782NOzR6q3qiQ9feiyiTjxcSFWsOE5NHW99jo= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: e891d529-ed1c-44f7-1b91-08dbf9f5b9fc X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 03:03:18.6724 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eRo4NuRH0tT15hxqFx3gafRh8J4P4yTOvnbC3yajre0euzLOhvKeuqDiQMDr10v1/BV3VBmIfY9J/iT1jXj0W9DbYGl7rHKQuBpk6O2GLi2dmLvyBG0OaSdVZny9pJUv X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYCPR01MB11269 We would like to use for_each loop for status = "reserved" nodes. Add for_each_reserved_child_of_node() for it. Signed-off-by: Kuninori Morimoto Tested-by: Yusuke Goda Reviewed-by: Geert Uytterhoeven --- drivers/of/base.c | 29 +++++++++++++++++++++++++++++ include/linux/of.h | 11 +++++++++++ 2 files changed, 40 insertions(+) diff --git a/drivers/of/base.c b/drivers/of/base.c index 25c841a3882f..b1ecfcfbb90f 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -465,6 +465,20 @@ static bool __of_device_is_available(const struct device_node *device) __of_device_is_status(device, ok); } +/** + * __of_device_is_reserved - check if a device is reserved + * + * @device: Node to check for availability, with locks already held + * + * Return: True if the status property is set to "reserved", false otherwise + */ +static bool __of_device_is_reserved(const struct device_node *device) +{ + static const char * const reserved[] = {"reserved", NULL}; + + return __of_device_is_status(device, reserved); +} + /** * of_device_is_available - check if a device is available for use * @@ -650,6 +664,21 @@ struct device_node *of_get_next_available_child(const struct device_node *node, } EXPORT_SYMBOL(of_get_next_available_child); +/** + * of_get_next_reserved_child - Find the next reserved child node + * @node: parent node + * @prev: previous child of the parent node, or NULL to get first + * + * This function is like of_get_next_child(), except that it + * automatically skips any disabled nodes (i.e. status = "disabled"). + */ +struct device_node *of_get_next_reserved_child(const struct device_node *node, + struct device_node *prev) +{ + return of_get_next_status_child(node, prev, __of_device_is_reserved); +} +EXPORT_SYMBOL(of_get_next_reserved_child); + /** * of_get_next_cpu_node - Iterate on cpu nodes * @prev: previous child of the /cpus node, or NULL to get first diff --git a/include/linux/of.h b/include/linux/of.h index 6a9ddf20e79a..331e05918f11 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -294,6 +294,8 @@ extern struct device_node *of_get_next_child(const struct device_node *node, struct device_node *prev); extern struct device_node *of_get_next_available_child( const struct device_node *node, struct device_node *prev); +extern struct device_node *of_get_next_reserved_child( + const struct device_node *node, struct device_node *prev); extern struct device_node *of_get_compatible_child(const struct device_node *parent, const char *compatible); @@ -541,6 +543,12 @@ static inline struct device_node *of_get_next_available_child( return NULL; } +static inline struct device_node *of_get_next_reserved_child( + const struct device_node *node, struct device_node *prev) +{ + return NULL; +} + static inline struct device_node *of_find_node_with_property( struct device_node *from, const char *prop_name) { @@ -1431,6 +1439,9 @@ static inline int of_property_read_s32(const struct device_node *np, #define for_each_available_child_of_node(parent, child) \ for (child = of_get_next_available_child(parent, NULL); child != NULL; \ child = of_get_next_available_child(parent, child)) +#define for_each_reserved_child_of_node(parent, child) \ + for (child = of_get_next_reserved_child(parent, NULL); child != NULL; \ + child = of_get_next_reserved_child(parent, child)) #define for_each_of_cpu_node(cpu) \ for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \