From patchwork Mon Dec 18 06:46:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13496258 X-Patchwork-Delegate: geert@linux-m68k.org Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on2098.outbound.protection.outlook.com [40.107.114.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 719D57461; Mon, 18 Dec 2023 06:46:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=renesas.com header.i=@renesas.com header.b="D91H3Th8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=erCizFCWpLz2aonr3JAn0jmvoReH7sLg4BrxbDsxjdqpY/+u0wZM0WbLbe696mv8kHgPdErMABd6E+Dh5S8b+cpXAUZaU9RcY2If9fgaie+1AZJPhuTpLXmkU8HpJmgw7/UxZ/BcfVTaDx7HfLZtM6tE5TVkClE6rhWGqR4N1mFp2TU0fJxWccKaOZG1i0g3Rqj/SkHjidNbyKNiPydsBjIxa5T5qTxgT83R0/c+7sa8pszfJ2kjIcdjO1YzvEiO0qxu9Qjzi5lQcOQQ+O8/wgKe1xflD+aXLbHSop2Li9hsqoiBm+T5xVCWvmaa51C+ssziIJBEfrLgVId4c8YR8w== 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=RgUkUYtygoxiqzMiBVycBlhtPag3tFrU4SqtSRyEFyI=; b=THGaBd8pR5sySjnn+pPGMI82Taf9PLRLUNIQ8bqzirp+mDIldnoktBdMVULB3x5VVDKMwBysesWv3u3/s5GFcK9siIm85xddgAhfMUvOrltpqRPevOWvwRqwJcIFzM6LXWWJ8goT9/egG7RBhVLw2oIsyU++2KOrtPJeFvcQjTPR2gyPyPxfpzGOikP0iN0SeKqDSc6uesLJYWl3onIneRZlff91zyUKdKQE32BKttdCD5JyS9wfks3MxcaE1rvdLYvYd/P102YloziA7PXpCPDRbX6pL7fEp4SGGns9VQNHNqspoITLSsT1rlQckrkowJy6nbcZ5rC1N7Nqr5jlfQ== 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=RgUkUYtygoxiqzMiBVycBlhtPag3tFrU4SqtSRyEFyI=; b=D91H3Th8KXphSuSnENkHO3IENVCJ2R1S6G5vfDfJihPMIQOKit7sEFLuVU/qa9ZPBv4pFm4HTBakNwl9fUVjAz4SsKCo2vDtI9mLYociHpvbQYVXW92zXLE7OMAwj042YjRp5G+l4A4lSkKXXSyBOSAC7wykPtvNYA/oRuRb39g= 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 TYAPR01MB5852.jpnprd01.prod.outlook.com (2603:1096:404:8053::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.16; Mon, 18 Dec 2023 06:46:52 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::eadb:ae7b:5fed:8377]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::eadb:ae7b:5fed:8377%5]) with mapi id 15.20.7113.010; Mon, 18 Dec 2023 06:46:52 +0000 Message-ID: <87le9sm2hx.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v5 2/4] of: add of_get_next_status_child() and makes more generic of_get_next 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: <87o7eom2jn.wl-kuninori.morimoto.gx@renesas.com> References: <87o7eom2jn.wl-kuninori.morimoto.gx@renesas.com> Date: Mon, 18 Dec 2023 06:46:51 +0000 X-ClientProxiedBy: TYWPR01CA0018.jpnprd01.prod.outlook.com (2603:1096:400:a9::23) 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_|TYAPR01MB5852:EE_ X-MS-Office365-Filtering-Correlation-Id: 459888ce-7567-4b14-72b9-08dbff951dd4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W/zPpI+Z1IXFEFtYytcfSMFxY46Z6UvSTyHwIG3uBMO6nNPUvRM2FpwCPkv9v+wDJf7xQdTyGoOeFhNfsxouWVhwPgkGzCLzP4QX5ImLMihxSaW9NJWQ3RqYFMeDVN8AFmrtcd0jxE98vwUgsMjS5QCmXl2+jYsQeewuuRpB3bSmVZma4yxOQUp14kdgApEGUokFR4ATXwhyn15nullngekOJPp01WFcahQJLUtH89eX84T5655/FLYd5h6mfkE+Z/PtwE9hvCSm5qZWBpzuI7+dx39wJY0BT6cJO2/iwh/F8eDm30yf64AqdsqF4WPQBqGHapTZVhACGGs4mMq07UoaZ9SKB3OQQVTbIUHovgvD2Nw2m3aSC4vYTjpU80H9ZzE1eDA1IhzyPqAkVLz04parXFM4hflFyiqm7FfLwAWhf4MBm6QTOCCUa+a+3HxebiIBbSc/1YWG7Z6Fr7wa0/WIhbZ7jNo+zKa3rgI55aCdmyDimr7akfASLy0BVxvdPaDkR2w0eThI+vGVUzVNYHg9ijz6pnPtprHTRCNRRH2Hrg2RmMTyZUWCqh78QN8T0eHmWNZoaQZqOz8rSgGfYT0cqcBvcUUCUNyZuPrbD9gdN8fG0SuYALfip8AtBefT5KlpwX/uT91c5fG2wD969P9Fjscf4WR9ABpbFypZgGa0LIPFAl7NdvutcAbC2Txu 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)(396003)(366004)(376002)(346002)(136003)(39860400002)(230922051799003)(64100799003)(1800799012)(451199024)(186009)(36756003)(38350700005)(316002)(83380400001)(110136005)(66476007)(66946007)(54906003)(66556008)(7416002)(2906002)(4326008)(8676002)(8936002)(5660300002)(52116002)(6512007)(38100700002)(107886003)(26005)(478600001)(6486002)(2616005)(86362001)(41300700001)(6506007)(41533002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: F3Un4D3GnHwjrLrtDgsUqj2nXuWAqF83KsABvuYWyXnLbNivX1PEDQHPEEwPt5AVarEsyNUaAHTo0Qjsym8Y7iSTWo+2bLXpc55u0kZrNcnMT897nzsQX4icOsJqLtPh883KR2cgSSoL2JlapByJiKIfOmqT6dPx7535EKAdGWKKA0+iO9r9Nj6ZMDv4ZVBYNynV6go2HVuVlHdo4e0cAGwkc/mUMpni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3JncKLbO/esuo/a3vx2CbriTyNVfiXiDs2WRo4v6OjYFocSy6FNGNHucBKs4SZO5HHiyQOFWGVEyX+j5HE+9ktN/MuhY091//33SFkhZkkW8TlPTVT2TZeYWFNZeXdunG7iCVz49YlWgpAo2zGtjcpjp21NvIz3lDGTxoacsUmvAcT9qIowsleF7vNMZ3pKX1+F8IwcRHJWbInc0sdQc0pwtWLLH1HIao5vuiUpZxuZuF70yCua8rydj72MwBe2SUfMNqt6EA1nBn8uX75MFm4+v+5sHbFVspWRkBgF74ZE76/2pFXCI5zHuf4EoZYNfUavRZM= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 459888ce-7567-4b14-72b9-08dbff951dd4 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2023 06:46:51.9851 (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: 9ExfKObXlAYDhcMFCNSsa9sXKrTGRmrmqIQ/1Lw2l2zTU7HgjOyzwreE7rUPfhOaSSwnDmFETjcorBkmSgcqLWcq6pSynKcYM8mCxPHZxcJgg9kcl8XqnDbMC33ngms+ X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYAPR01MB5852 Linux Kernel has of_get_next_available_child(). Add more generic of_get_next_status_child() to enable to use same logic for other status. Signed-off-by: Kuninori Morimoto Tested-by: Yusuke Goda Reviewed-by: Rob Herring Reviewed-by: Geert Uytterhoeven --- drivers/of/base.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index 3cb467a7e747..25c841a3882f 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -612,16 +612,9 @@ struct device_node *of_get_next_child(const struct device_node *node, } EXPORT_SYMBOL(of_get_next_child); -/** - * of_get_next_available_child - Find the next available 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_available_child(const struct device_node *node, - struct device_node *prev) +static struct device_node *of_get_next_status_child(const struct device_node *node, + struct device_node *prev, + bool (*checker)(const struct device_node *)) { struct device_node *next; unsigned long flags; @@ -632,7 +625,7 @@ struct device_node *of_get_next_available_child(const struct device_node *node, raw_spin_lock_irqsave(&devtree_lock, flags); next = prev ? prev->sibling : node->child; for (; next; next = next->sibling) { - if (!__of_device_is_available(next)) + if (!checker(next)) continue; if (of_node_get(next)) break; @@ -641,6 +634,20 @@ struct device_node *of_get_next_available_child(const struct device_node *node, raw_spin_unlock_irqrestore(&devtree_lock, flags); return next; } + +/** + * of_get_next_available_child - Find the next available 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_available_child(const struct device_node *node, + struct device_node *prev) +{ + return of_get_next_status_child(node, prev, __of_device_is_available); +} EXPORT_SYMBOL(of_get_next_available_child); /**