From patchwork Tue Nov 21 02:05:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13462413 X-Patchwork-Delegate: geert@linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=renesas.com header.i=@renesas.com header.b="UOrmnmEO" Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on2134.outbound.protection.outlook.com [40.107.114.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7856F85; Mon, 20 Nov 2023 18:05:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IpsOc9MoxDj25IDnBDKaDnGq0NkEgTaDxw41zj6abUMoZ1JNp2SJCYYkUKHrAJ8UwXMuAaL+CszyI/cGgiH2n/hv5EU9XhFqi7Px5Wry6JhwGV4p0T38UOyvTGHnVVPdeiq4XJnm6adQt7+S7cGkA6WRyWU3KQ3iohz3fyQRTeZbLq3/VtSCyyHyrvZWd/8tEzU0kEJrPsFOHQuqZNpIfx4BdxRzTFafseuhiH8/hhMFG442InZYhycD0N05HFcN0yW7O8/mLTdrxrwO3wEgHIjf24zy33kIzM/1YoYsuPKqj2wqSafD7akEyBl7tN+7ZY7HcMi5HZKK1R/EJtix0Q== 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=pJ9np3T+wOYwhmN8Vc0TSzIL7szs5pjdyC+crr80IMA=; b=GYd87EpwiIfnm48HwqocMrxW5CMSv03AI+u2lJFHUbbLRTrct4cgceu4qleVF7RkJuoXeFqW8V5Zrd98q4BJL54vBhspQQ84YSYfC8I+pJerPnwtsnVisQfvCasIdzDODRGAQ2SGyLB9/jf5o7zd4aY4qDnScBG3pQs9ckkDqNNilaB/ybKMhLfk4nfYK1U/FXVArjpLnSD9I8Xsnvo1AXX2XfR3AuXNzx5r579Si7e1a8+r6gfW1jCgTg7Bu7ntMphV7SWJsEQVbCyj0XIauyWUvtfVzjiE/G/8/luYf1DWFmTWUfhIiOiBBNFVfgfCoOkXV7Wn6WgdAZ1XtCyOWg== 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=pJ9np3T+wOYwhmN8Vc0TSzIL7szs5pjdyC+crr80IMA=; b=UOrmnmEOvUO2yoPJlfKYjzJOzxwioSkC4DtPMbtvawSvxpR5JdymfyYAuEvIwf95EGrCQpEm9MOFjrVGV3ERr6crZ3KgAKUttedo/KKAa87V0GfQPOdBlNO/huH3UhlmYfLIVD0Rt+RQ89eSEtjkCsm8gE/7/PiABWqJtz31G4M= 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 OSZPR01MB8610.jpnprd01.prod.outlook.com (2603:1096:604:18d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.28; Tue, 21 Nov 2023 02:05:30 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::16b3:a84d:faa6:4846]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::16b3:a84d:faa6:4846%6]) with mapi id 15.20.7002.028; Tue, 21 Nov 2023 02:05:30 +0000 Message-ID: <87cyw3c13p.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v2 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: <87fs0zc14m.wl-kuninori.morimoto.gx@renesas.com> References: <87fs0zc14m.wl-kuninori.morimoto.gx@renesas.com> Date: Tue, 21 Nov 2023 02:05:30 +0000 X-ClientProxiedBy: TYCP286CA0221.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3c5::7) 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_|OSZPR01MB8610:EE_ X-MS-Office365-Filtering-Correlation-Id: caceef08-ad15-44a8-8ecc-08dbea3656ac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ObcR/TxCYhRbDgNJWiIVSuKpk7mJqWNs82/rAu/gVtKR6ic8tn6dixgXGS8afM/u6iEijalTk+FPoymT2//cnpkekLoN+mgGZILZXPAUXloo6L1VnwpUN3FYg1IH8JQ+PYUwi1iBpLoYFi+kyh6/5iv875mYmsY1UeXqmHyxw7WNtM4jErwGp2V8NdniJVldpu2p4f0jb4jjf5eLZVh+/zoNMC6oOya86CgoTMZN5keONae4W8SPidMdi0757IU2p8QL0lKh4ddiG2oldOy3ybxtHtNoUXIdBtasucJtPKpRhFoXivR+qe6OzXJyRHsfCGgwIiNtVvpxsfa2lgbFQPHP4tgAywpe1TEkeYllwkHVYx2YtpTJOun+F5jDfKG3fW4YOjAa43WojvhudJs/w5YMjYYrWctkjglt1CmOxaG1u6NYLhhGZ7PtdZu6YK62AmP1y/ikTAZXBHYQCbHfDamSQoj5EYpbuvQmz1l22OWUWatznqdTlupZ9MuWxXUMMjB8AHZBWM3tLxPBpddRgAwsN9uFbLyhmjWWm2MmN5SYAvNeD4mZpSSUcyjmzfjLGvvzdg7I/6d2Onx/nLH1gGWZXmrQPLdry3T0E9KdnkUK4I6YVcEzwOqZ4g1z3OOe1heFsfeLmFMy+uyrAXPo0Q== 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)(136003)(346002)(366004)(376002)(396003)(39860400002)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(2906002)(4326008)(8676002)(8936002)(86362001)(7416002)(5660300002)(38350700005)(41300700001)(36756003)(26005)(83380400001)(52116002)(6512007)(6506007)(2616005)(107886003)(38100700002)(316002)(66476007)(54906003)(66556008)(66946007)(478600001)(110136005)(6486002)(41533002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Yb6UwgCjmB1/nTe+X8wxtE/IZ2gxcx+Y/mGOyafg1Sk4YyaIXrn+tgJVOSiT58sQR5XGuxJ9k6tFS/cNCozrW82/daI3GStFw5Yg5ehIzCGYijLDKe4l2asX1leYqlsKvw/VYxrlP9iaBBVRXDzwspFrKzdPX1JXK6JEsUCsJ8GceRWiUXXNG8FOyCqgTxeM7egBt9YemQ4FPMa6fZP+XySzrRBhD+4bA5oUG3I+H+C1SSn2FuYOAIdNyW4BmpRNVNQd+GXK2ZiqqnLnJhTNcNcnp20NBjWpOqxWwHgJJ757o/hAzUdvIp6wbvaF4vZdqmBPNhYvYRyhw+M7756OHunDfwRZX3hjms5KPEpbJpQLCNc3TT8Ld0eqDE629Sb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c/e9PzZf2HBYsFh30dcA06WGEZCog5iYA81u9nkpprmhlXo+sOTczRTmKRuBo0tE9n6HVMwy+l+6ri0TDEiasteMYBVStNbTHdJJvYvSuWBNdoK44dWyVwIvJYbWF5OdvyUJTxsmdF7Xyb5+Q/A4kNFvpmOY34dzUb5iEyaQuyMGaT2f+EYU= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: caceef08-ad15-44a8-8ecc-08dbea3656ac X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 02:05:30.7390 (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: ODwub1ftPtt+pEQZmXiOEAuu7eOoyG5LZAvy8cvsICrbhAPe1jUO+qbIYJuKMGJmnl8ih2AIEPS1AkHAwJbYM95Mzw2VMSAUF8mOrrpxGesM0TDN/Kj9YDBue2NX3N8e X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSZPR01MB8610 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 --- 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..d0f7e7c890f1 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); /**