From patchwork Wed Jan 10 01:14:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13515583 Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01on2119.outbound.protection.outlook.com [40.107.113.119]) (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 729A21373; Wed, 10 Jan 2024 01:14:46 +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="jETWwvwz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jnanZp2/flt/tfEubJcX8UB+kqbk+2eTpUAQgEmi612QjHpxzQySo+YL7MUKNZhjXe1Ss0bMv0ZHWPEfr163eYk1WegmM/gCnr5Ofu5raTMUfgg7szx6UVJNPaNqVeevfEZ2D0wDNEl3YG2fCxcnBm6IaEhQWUzDiCfziI0q3jc0WSRrEgl2lViuP/sZlV3H4ZnIz0Qhi3jz8nRi443BvKNhmE2B6k8JeGKKR42padL3POjD7QxdfeQjkksmVMOO+0ZLi/NNDrMxl0d+TrJUqfBsFd6ZxdWN1AeQ3sPV9smzGoCIxx4FJzKVSumPS6OzvTnPGj63D58Ldcxk+x1M1A== 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=lxPPm72hfeBTx0T9x0VrOIyzf6McPLkZw7NStWHrWFniZhbK3Fb49bUVZbCFWkneIIxJIS5IIMqJAWAdAD/LJVXSNd4jifGJSoP1sLn04pQn5ec5PQs2Bf+chSY6TVPkD9rGLzkAyK9M+Y7XM2GgBrlHWWw2w0TwX5KWYTaXOu/nx2Q+yYHX7WzhjT9ilG9l6RzSZs8L5v+XzjIUloODvUskN5+af+GLQ+rCOzIuaZAwojAVKYZtayolr9zCEDIAV0ugEpeEFkr0xUSETtbUMj4BSrhhptAa3k9lC03uxokPJs4lyDk89s/4PGlmMOd2GszG0EjldtEEPUY6fbPmog== 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=jETWwvwzizK5X4RfNSRYxFmz7NsJy3dBjWxjpD7L8c1/XFfjP/ElOSeEkMnHjsMPiYWe2zKutVPM9uG1q5Ok/tgDbjE5fEtYxq4Yx3qKaMF1AkQ7vP2vG3PMXD5jaIojNVrmr9BJ952RPTbmHGznJxvMUFVXs6snW3r1oJwdPFI= 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 OS3PR01MB8442.jpnprd01.prod.outlook.com (2603:1096:604:195::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.17; Wed, 10 Jan 2024 01:14:43 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::91d:1bfa:edc4:1c5b]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::91d:1bfa:edc4:1c5b%7]) with mapi id 15.20.7181.015; Wed, 10 Jan 2024 01:14:43 +0000 Message-ID: <87bk9ugfb0.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v5 resend 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: <87edeqgfbu.wl-kuninori.morimoto.gx@renesas.com> References: <87edeqgfbu.wl-kuninori.morimoto.gx@renesas.com> Date: Wed, 10 Jan 2024 01:14:43 +0000 X-ClientProxiedBy: TY2PR0101CA0040.apcprd01.prod.exchangelabs.com (2603:1096:404:8000::26) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|OS3PR01MB8442:EE_ X-MS-Office365-Filtering-Correlation-Id: a4dc6906-47ef-40cb-03d8-08dc11798744 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FtOehzZ4Kx6XKhbP6FTAniIU9TpVXT9oNJZWiQ2Vg6OXjv9qE7oftWq5WvDIEgiXDDd/f/NJsxknKrnYkdXhQ91c+I6Gspi1tewbPJeOaTrMGKsZf8eWOA4ef4wsQkIUFJehuNxSsVmry4/IE4+zThDdNFuTwFmHL7urgvW8+iGS7odox7ScpTV0FiwZO7K4WjVw8nEf1/MXWbBPS5k92XhA7U2/6kBNYrMLXZtXdI5r6rUwPflZogWqxEKAMP+S6S7FTS2V707lLvKI3RdZta6/y1EyIrJzhoUKXKnkfL3hoVLR86R4zI+tZcH+ZmxTdJo/uoxkEGpcApaAhLftfFDc1a5b8lV3NxTmZ7kj6GDdQ7wL2/fNhssoSznYU2oJAq2G69j/TCj2ngJuaoWQNqXXtIU2rf2F6Zc/Xz1K7OgfstEinRJDHK4xWDIc64mIrJD/6p6JAEzh59KtJxdHUyY1Qnozi7SssGsLHTFRQUgqkj7uZ1d0XHBIEo/X3K7ZfDkm3YKsj48UgvQ6H3LvKKx13kLw8xBrOPd3ZVLZ7NBxffrmsPgpCCrijs3/vJxGRYJFkp618ukst0X4JoC5X4YDvHRSjlf6PoiwPXCqbr7aoWZW6KphEx9BbkJTWq8r5eK+XRTwcTSkyi/WmIARKw== 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)(396003)(346002)(366004)(376002)(136003)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(38100700002)(478600001)(6486002)(83380400001)(54906003)(8936002)(8676002)(66556008)(66476007)(4326008)(110136005)(316002)(66946007)(36756003)(52116002)(107886003)(2616005)(26005)(6512007)(86362001)(6506007)(2906002)(38350700005)(5660300002)(7416002)(41300700001)(41533002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hLgyfoyQzfCxxwaVjEZwYoq7kSH2UdskB1jCpqRT/pjkgW1jRJZcG7nWlGigMRHD87fhdYp5ZWFklLDuiqF+6cCaKruxqieK0MAlk8X3FPmR26CMl5EEoY7NZyEggd0gpShXaIH+rHA1+KhinFleXvRpi9Vh7HuYUSooE72FJnYPg1tq0zcWkm4G84BLAJ9iaPnh/TPjxmCpackwXOqDVo2sNKsHrlyq9Jl/+CszTIGwdBdUAufq8PTXtntDf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pV3Qs9qAuGqsVaI9RmAR4CU7u7P3QF5dqWJBzCpPZ/PR60TYhG2bgVGb6oE5KyBFZyWny4O7qr8prfZqUn07GHxn95ZfVTXP2bEPZzjPB7Tdj5fn4Fx9W5eeQ6sfZ6jyVNClfiwQYMaupJLRFtTPg5qCT7fLamvKmrcY66RjnbXa9QEZDWSn0R8V0vxrTBkbeLEOjlAiBJYUji5WFdC/t44gkcWQ83aQ/LW1Z+nSt68dt1UCgPfSYTvNz1DiW8exGmBDMjOqGtQQaEg3x2MTeBQJmI/93F4uQokkAlRoOWOEA5M= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4dc6906-47ef-40cb-03d8-08dc11798744 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2024 01:14:43.8915 (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: SA/LYqSBIYKj32YLBKjwoVy/0NOSTN7wQI5l+0X9Yc3iDHaJW+Oqq5e1QYGZa86eESDaqayQKqN8GRiksFPaY19bags+GMhG6lWmXgxGR0EgO313S51Fqgsn+TTUWEHM X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3PR01MB8442 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); /**