From patchwork Mon Dec 18 06:46:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13496257 X-Patchwork-Delegate: geert@linux-m68k.org Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on2110.outbound.protection.outlook.com [40.107.114.110]) (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 33E4D6FCB; Mon, 18 Dec 2023 06:46:43 +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="kk948c3y" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gv3Xn2br0LXbv5Pqs3lvHUvrAZk9CUtQ44KuZ+uwLfSW3b77TLHWtTPGgQJHHZUbAfU9R9ZEAgO0/Zog6L/NXFhwzzEFpd93su0f81NASH1WwTCbeC12VoBKmPm/qnlHR423QnJAen1yIB//ltHYi6hECj3wDErmWwh9q0zZ6pn5urParbpYsALS9hd23Y3LIc9RBL01mGfPO/JEthan50vcMSdmicjKEcr2Ac1vpqQ+u920pjMQEG2eJpFqmL2uK9P0rFTYeUy6StX9QlQF2M6+MVitAJfqoCQ+AnEAAanDCV7fCX1tocidnzm5Vw8+JGA7KFX7cKoRrVPeKVuYvg== 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=1XQHWRTVIn3IR/BVQKSU7VmzH27RAnJGrU21XEgwWMw=; b=ZrVtdrUVj+22qvDzDKJUAxYnKAQbUmZEhi0u50KCYXURGsLsInNy4w8vmTcMwQqLJMoXkGl54BEEXlZiT81PUE055UlA1/cWi/vVFdPSJkBw8O719eUKlMtW4erx6JJZZH2SkBMnWRyv1qUziZgaT96YPzqvnm8DB31xCyJCfp9R18jX3o3dTi4c1hsthpVRDzGzwU05G6DDw3RYCfAQMBxGbERkZy0oipi+X//Qm+5TzWQxg76OIYg+YsausZkkkvplaaWECkexHcCgB9gfnc8TuWNb0qjJw+GOpYZK1WDUJ/G30l/1rkrUaqwjCeNcdFiPV3XUcYrprg2Zcc3CPw== 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=1XQHWRTVIn3IR/BVQKSU7VmzH27RAnJGrU21XEgwWMw=; b=kk948c3y6l3dD4iK6g5YSbjlma29/VcMClzIYhWV8Bk5NSnSLDDJ/jw9/U7D8UnQqExocYgEsUOTzqGDyyFNwxSJ7kKJDR1cxnduTbRa2DjDPD/eXY+Vd0+z4H1pK9Vsk08GYs35FdqzZLQXA5cRqpM4uCH9VpYAQWiJN/tonHI= 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 TYWPR01MB8348.jpnprd01.prod.outlook.com (2603:1096:400:177::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.15; Mon, 18 Dec 2023 06:46:41 +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:41 +0000 Message-ID: <87msu8m2id.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v5 1/4] of: add __of_device_is_status() and makes more generic status check 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:40 +0000 X-ClientProxiedBy: TYCP286CA0031.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:29d::6) 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_|TYWPR01MB8348:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c1e0674-6980-464f-451c-08dbff95177a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6v6UMsFkgBMDGsVtz5Nif7dwhE12f8f7003ok5Qmu9znw2BKbOWMFXtAY9HTDSy5JYZm5Yn7tN66jGfMbyItx0gPd0dyeDg5lAMtSXvZad/h+dX5dXKlvHBBiJe/L+MsUuXZ87O9z0yJClfn0NqzqOL0/stUSUJFQkdu4N8MBsjWfN95ea72CTrshB/WnRHAZLGue/0dHcWPcighuz8jMgfnlRD172XWbi0qVU/gEVQXtqjEt3AfVULrn9jr0Xirm0SVkkOGHIf19Sw75SBo5yF/Fy+t+dZcjlALDhj/p9tT+LRTB4sfRPUxnko93bOgo6c5Rgr3p0VjEpH/H+5GeRcNvp4PHrKN1bntjRVHagiYXWctdt6F+/5bYihn+Uasd6SqWr99XCKUmuUim9gilFFAohm9OYLarWCHSudaFHYlz21Lgvq5JF729rYt0gs6tumygWU3M+6q9t2vZLjRl01BjtK1W8NS46ezGh7aoDunZP2+le7sPcvaHr94MkleEBkFG1W1UaeeKR/0q5Y5QIuweDOhLWvYTih5rjPro0Zy/7Ke5sqB7+O5q83rbaUbAyKpoqoOz8m8zRClLZdjW6+AduFCtaC9s061dWaya2N5eCVRMCE+3xX3Km6fsc6TcnJ8XRLhS2pBVdGDHtMZnQ== 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)(346002)(39860400002)(136003)(376002)(366004)(230922051799003)(186009)(1800799012)(64100799003)(451199024)(66556008)(110136005)(41300700001)(54906003)(316002)(66476007)(52116002)(6512007)(6506007)(66946007)(2906002)(6486002)(86362001)(8936002)(2616005)(8676002)(478600001)(107886003)(38100700002)(26005)(4326008)(7416002)(36756003)(83380400001)(38350700005)(5660300002)(41533002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: B+BwJ5hzJkNU/HBCfQ/B5KZiXj7FI27XjuXZhzDjutJRm7ymoi1B3/+z3Qnf49FG8swjpguOFMGSuDMDkJnktPu71Y2Fgu0BJo0cqZu/ODgNQYhNkWAEDw90TqDiz1I1sIa5Vs022SbQoANsJhLHGO2lUyKZN8E4OkdBGGFd6NkaARYyFmzMJTlm55uyzBIyOwUcax/Ra3VRiWj14FCeV9Jycukui+/0vuIJfxSRwjqKFqHmaI22xJ+Qi4r9JfQ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i7zJJER3eOR9W26IE5lE3mUaLxHiGmBs0ZszHxQbOD/jcTXCqW0q0piPkeOb3QnxEg006rHcR6KADcwx/5aLgS+eb0Qbpu4x5BQFpHcgk5LQ+BWJTO6spOvhkPZnVC8qNgE2i/bQvo6+SKvN/oJLmDVhuPdO5ybrha7VfPhB4X5V2eqERI9uTCwPTnk+RQsXtRrEuM3PG3hiUQQ9HVyQ54f07MaX7nrTN/TzOf5NxI5JOHPNiMZ4sAhsOrjPgFlGs0EA2S19DDaZOYIn0rQNJHyBRjVJ7c/OTQfLdzKiFl7NvLfQk= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c1e0674-6980-464f-451c-08dbff95177a 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:41.3144 (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: TYM8qzCYEIwJdk11X7FKecvKlPF57U1Dv7HjvRTs0nEmMFLEkkgV/mgPGh4HlEJ4c8DJl8SXf+0cd6Jw/vmtQI8vHzdtzpGGDugBki4zrfgroBfTvlImLjs6eJA6zXD+ X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWPR01MB8348 Linux Kernel has __of_device_is_available() / __of_device_is_fail(), these are checking if the status was "okay" / "ok" / "fail" / "fail-". Add more generic __of_device_is_status() function for these. Signed-off-by: Kuninori Morimoto Tested-by: Yusuke Goda Reviewed-by: Rob Herring Reviewed-by: Geert Uytterhoeven --- drivers/of/base.c | 57 ++++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index 8d93cb6ea9cd..3cb467a7e747 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -415,15 +415,8 @@ int of_machine_is_compatible(const char *compat) } EXPORT_SYMBOL(of_machine_is_compatible); -/** - * __of_device_is_available - check if a device is available for use - * - * @device: Node to check for availability, with locks already held - * - * Return: True if the status property is absent or set to "okay" or "ok", - * false otherwise - */ -static bool __of_device_is_available(const struct device_node *device) +static bool __of_device_is_status(const struct device_node *device, + const char * const*strings) { const char *status; int statlen; @@ -433,16 +426,45 @@ static bool __of_device_is_available(const struct device_node *device) status = __of_get_property(device, "status", &statlen); if (status == NULL) - return true; + return false; if (statlen > 0) { - if (!strcmp(status, "okay") || !strcmp(status, "ok")) - return true; + while (*strings) { + unsigned int len = strlen(*strings); + + if ((*strings)[len - 1] == '-') { + if (!strncmp(status, *strings, len)) + return true; + } else { + if (!strcmp(status, *strings)) + return true; + } + strings++; + } } return false; } +/** + * __of_device_is_available - check if a device is available for use + * + * @device: Node to check for availability, with locks already held + * + * Return: True if the status property is absent or set to "okay" or "ok", + * false otherwise + */ +static bool __of_device_is_available(const struct device_node *device) +{ + static const char * const ok[] = {"okay", "ok", NULL}; + + if (!device) + return false; + + return !__of_get_property(device, "status", NULL) || + __of_device_is_status(device, ok); +} + /** * of_device_is_available - check if a device is available for use * @@ -474,16 +496,9 @@ EXPORT_SYMBOL(of_device_is_available); */ static bool __of_device_is_fail(const struct device_node *device) { - const char *status; - - if (!device) - return false; - - status = __of_get_property(device, "status", NULL); - if (status == NULL) - return false; + static const char * const fail[] = {"fail", "fail-", NULL}; - return !strcmp(status, "fail") || !strncmp(status, "fail-", 5); + return __of_device_is_status(device, fail); } /** 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/mUMpni4xBd8hIgPIcWYrBVySSvm2v+acrebaPhwmfb+puzG+10mCG7gPWJ9B4RXjtg37K7s3aQTWaPvhkZL9p13TY/bFrF2CvhFCG49kspjzSDHCe4MTJ14sS1tW22Eu1Mz+guZxqCre2TWFq9KVf/iB/+JyGrXOKM4Rp9+UGv+KKVZH5dvobJH0dZHq9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3pKX1+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); /** From patchwork Mon Dec 18 06:47:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13496259 X-Patchwork-Delegate: geert@linux-m68k.org Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on2106.outbound.protection.outlook.com [40.107.114.106]) (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 C84B56FC9; Mon, 18 Dec 2023 06:47:04 +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="pH/g3Nfb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vh9fvJoJjaXYJQhpUY762bio+68IBifqMVMbh3OtewoeIqKocsoxy7At2HqQPimdwXfepO3XQYly3voQASf9/GsDzU/P68Tjf2v5MMn6AMq+DmyRMcFwBDVYqqDcKlJTcNPugcdWsvOhzgG1rfJRk6o+pwx57sV2CJTXhx8AOJ8nM9y+lgH+rLRnGJTDXUV4DgIiltcrIAl/lGCF2kFeaac5Dr2TstgdxNgdNVXONC0LkK2fwXs8pd8a2SEp59UXXuugy9Ud36F835EF2UZwYDE13UHKu+NvNuj4S4kiDxV77WR2c199KDm0I3fo7yNg37PJmy7/1liVJa10KTEL/g== 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=E/YbKFMch9m1xtSxAD/LiN0FMfqT7q3lL43HJogW9YatHV++jDI1C5GI2Sey4jaS7sl3QSi+03n8IaCv0jtC4ejP7EHQVjRcqVBaYyxQrcwYbt3WEtlQHxOm3jCGP3j4CWpb84NH+W1S3d/huggQLKt7V/mP+ZJR8vWdDq1xDie18ienI5IxT4+fHgVMaL7KQuLRbJH1hit6omW8qwv0aHY6/EfPE+aerfRwDxWZEaBnUPCpFp0MOXlWxsCChVgwhnDd1uXQrLefmJTpmiErO/s8xO7Fy0m3W9zMoNFhCp8XEjuBEPw2EavA1xub9UuASUyotYNEsdMvLNC+qAMK0A== 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=pH/g3Nfb6aJT8jofQQ1BzO8xXvCCby7QMp76JwAKSWF8Oa1BN3RsdzV8QIZwDGd51RB7dlOoRbjxBhWEXj7dHVPz0gLKwg+8Py3yqtSx8s66Ms8+Nauk7dMsHcn1Ptzgxc0L1glzANRMnZ7qDfuiNC8W+4lGgJ1JQET9wRyJcys= 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:47:02 +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:47:02 +0000 Message-ID: <87jzpcm2ho.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v5 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: <87o7eom2jn.wl-kuninori.morimoto.gx@renesas.com> References: <87o7eom2jn.wl-kuninori.morimoto.gx@renesas.com> Date: Mon, 18 Dec 2023 06:47:01 +0000 X-ClientProxiedBy: TY2PR06CA0042.apcprd06.prod.outlook.com (2603:1096:404:2e::30) 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: e35fa12a-04e2-4d20-65c1-08dbff952414 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9ER5vJn8FcYZd8qgR0R9KbXIq/t8btMTs2kT9kXhH8ouIgJ9mnH+pbpmMKTTPWSRU6P1M4Zgr55v52KkU2ojk2I/ewaQ6zMAIS6hVPfmFjXaFpTbCCKX3vwHYKsTtk2ZFWGBoOBU96QzzDmfBH8en0MMlwJZfvckSFjilIo2q2CPp5TKidpfZXaAJFUeJhXVo2RNBqMmBgtfZBSJhQ4Nz2WMKj25BPp8r0/csakj/InRlfWra3vHpPsw2PJxYoW6C783U+yjGOTwHX97Dvm6npsigz/qkdFH1a93zwS/RFg/LH3O+v9t8cBSRfyC1QEPLmLRF2HP0R8V8EW8mEmHXHflNo9kAGbaITv+wh2UenLl8+r37HNceUE66m4hf4GNvwgaJlLpe68YpCcsIdPBLMAm98IUnna3a96WZGfxGHOkjRK1JonxdHkAvfzbd+BaLW8NbpVkRHApYVdhuAy00jhg27CvdisPH7vnET0OSzC6JdwpMnvBpzDaFvvIAzKTHWA2IFwHrAcKlKgEUJblutGPaE6Akwuqu3DxEDkz/c49hAdHlPtJP2i+/aAUqJUcuqssktklwso/IlG+uG2x4fgwfZUg14SEGQNUYX/DcRhwwZnpMUdmxrLM3nur5c0qcM3miGbBtOmuiXk5CLSH9TKc1mRWgmB6+pvQpVDOe1E= 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);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: k5CwRckzIZH/L1kZUm29DHyBC4gJh/lqSfMloet2Lz0HRruIRc/JyFb/u6M6HxsGYI2QmPK4CreQCgCJJ8fePcY9oSOFz6hK5KQrDlLwF+4U8l4tUqC86lBKBq2m0tUippatmFOESgjtD4D6KOZtcSd1lMXzUiYplhX2h7YSb4QF2wBnZ/CrWKYE3ZKM2jcf9n4paoTXHjJq0Zk+b1EzyIbOtiCxUcNemZulKN+Q8ToWABAhWYiYQRsyVZoBk1pwTos0YZBonRXZO/KxtG7zP0n93EuvIon9AEWfdF79CmiQj4nFPdkllL9WluAyf5Esabwzod7Ko4ezkbg9MFkV360CdYAvGFOnXBXbZehoFagNUAyVPE2hp2a2x6f3UajxN/HyHrzxQQcXe9QwanJVMkm2i18tQUVNifW6wtwKJlFd8j1piM6cyexHQyk5iatNJ08awaMs8g7NfYFkX9gn1+uontR0fUhkkBVC/Dk4aNUouZxZq4vTAwZVLkXGzRDDMdYAPtLDfO9A9fK1YAqaS9ClB9Ys4a/Ks8tcAHnuwewjlacHJuUpUPBOgaXzFte8vFYOSB+ohpYj9Q/sFnCebwFTIr6zMBpjgPLPVk4pdOprk2axb8s1kfHxzZO6oUZ2IX72YrEGMb3Lza05EOdI8Ll/FpHwtiG1ii5omDjeu/GvlZSV5MqAIzqhSzRnvSTRTabZ749g/WoOFI9bdmhZKjt0V9ZDulgmko4n1fIokWBz7ovTat+5dqFEu7MmI4HsmOVUp2Ub52aeUjG4tpRckdhoqtFqOYiUFbmCTcSzCkTy29MxpN+LpMtd2N4rnOudVuofB7ZQ6JJk+pEOhVFGKwmH2BxtxmwwkUjxcPwa0k6B6F79PKLOhl2yuYS/7YyvK+19SNoDzrp0WI8I5WATBpCE3Fjn7KYLqlZcDR7wml9/N2qk/yWcAgrY1ICso23ZysFuqFXVtxfMEkhvEkjQbZWv44DY8pi6a8ayWV9PBOKOYKowmq8Px1gHtVeC6Zr57pRnhK3cyPbMkq8FUqGLwFnxrSOTBfdPDrKM7deDgS+ZQXcLG9o4zJsNybsq51HAuGq7BYkMwl+vAtTKk2EYMilqeVsWjOsbnsaG5WJFGn44aSL5D3UQCVtfmutRdhiagmmJIgyI3Ce50bgLEJaVROxQzEpzIT1I7P/H0AvOsL9sriYQ7tWZG0GIn1cFc5/BWcQGOQcL4mvY2ggWIuzVZO8bccNosz54Rrc9fX6R58B7yGodOpeHKDlRwR8DhtrBXfjuOPEU9qc0bwQH0X0d1lfkodseCPLRYguAKvoBXrNQB++22tLSosF+BCrX3xAxvv1hfRAYdZ+eKZmxd3Y/aNUNQgAUejjQWT73LW9MjJ0rzDSqjAGpCfssmD7/LeT+NsR2Ewq05C4j14kmyBpw245l3Os24jZ1dP8mk/0XouD9Txe2okPy12e7tgTa8mAyJqgftH8VX8l351b0IulMJvmUouoUGJ/2C9k+YO/5SVOO/gbVKliZ+7F0h9+lFON809NbVMBgs1bNE+btjLuSEo5P/uS8nF81JYRu4/QPhaCYaE9CInRJXIWjDmXSIpPGM5TTIjoBaTlpddnQqr/lQK5KYiuomw4Si+RQMXqBBPA= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: e35fa12a-04e2-4d20-65c1-08dbff952414 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:47:02.5171 (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: 9L3S43eI3JpHWi3elEXxuFvPyhNoNZ1BVz9ii6NbPQUud4wSkoih/gFepob2aj11i4fMcq4oOxTEGYYBDqeqD+7GzwOqtabHFYI5JjKH0mMujTEoclb1s0p1JbNpYYSN X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYAPR01MB5852 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 Reviewed-by: Rob Herring --- 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; \ From patchwork Mon Dec 18 06:47:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13496260 X-Patchwork-Delegate: geert@linux-m68k.org Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on2135.outbound.protection.outlook.com [40.107.114.135]) (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 6AAA86FCB; Mon, 18 Dec 2023 06:47:17 +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="b9Fe3Lvm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ABuNqmxWlHPb0Y7nAFhGYxzac2Xa2wsGAReMXUzLrIXvEcKSnAAqvW0jHTl5JxuGk6jLsLgRNq8BLQ2l5l7PDjWuVmv0xAtmJH1aGomosz4er571ImA7nb3XDSy8AYy+0LBIyX4+jmClYbsVL6oXKF88QsOPpYEDrKS3yLKC57pIQXy1IHQGtN2/B+AMhlFwistCUoIsRiBcJUDfYSCUBULrQ2GdHZvXbDUwAT/M628aQ/orrI0hx25dq/vCzV4dqCAo6dZuUIlayZbszkDn4cMoX6QiT7HTzQliFh1RgBrdkHU3GuhSZwqeAbutyPE8GBPWIujfQ/A+n8a/SEcz2Q== 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=IlnzplvKddfmHf9/l66OOIE8xFIgHGzMXbzFgKHljAg=; b=D+CVGFp1R+qlZylHCwfHmvEtpD+Ykl/27JpxN1jBRSea9mT58fmErOYjvzxPy45M/zAQg9zmR/XqwAEtMZm7bd0z6agOrqT//BoQsZYiHNBIIR+tGLWkMiBYjjxa5Bh3rY4QQarupFH9EnQq2X42SNtuGXuNKW02yFHE5ylCeE38Y1rKBPFccSRU9UVK3WlecqJSjQSMQQyNdLCStrYpBaAM8QAS5PMwxbjP/Aa0YdxHb99qsdut8juDFVNxQYsU4XmP6xNnF/+WAWiMKNoRPWj/idOB0X35E4mWM75d5o3MUTNa/n2zwLVbq+K0onkbVghdWuJKVVfqgEwCe8Ajow== 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=IlnzplvKddfmHf9/l66OOIE8xFIgHGzMXbzFgKHljAg=; b=b9Fe3LvmXaFiRxIfu6ocwJfQas8a1sXtzcGWk6/uuS5WMsSeqpGRxrNKOhNVs92Yzc47NKuEI+sHE9oaYXfTZKxHy6kL2pTzopw+Q/iL5JeVyjmj5BjvKisQwpAR0feFWH5khtfz38nV4EaHIB4q6/2214ceMDSSyFbYIcJVC8E= 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:47:15 +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:47:15 +0000 Message-ID: <87il4wm2ha.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v5 4/4] drivers: clk: renesas: ignore all clocks which are assigned to non-Linux system 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:47:14 +0000 X-ClientProxiedBy: TY2PR01CA0007.jpnprd01.prod.outlook.com (2603:1096:404:a::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_|TYAPR01MB5852:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ef9ea67-138f-41c2-798d-08dbff952b91 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SGL8Qwf7fhpZ3SUop3RKvGXYmju7CiIkvsuuta0Ly5LQRcYokVp4Pb6HxYOKJgtJLmzlcTry/V2BXIUKR4T7XmYDQZtGHZhpCkPHKRj+sWqHxwjvWjSHGlRjppxzCTdFn/Swcp3vfNJie17Mb9U8pBxaPnEWQsmyJZE+2vKMRfwj7ZMFxUJAiOjr274i6hpf2f+fS1t8TdYhzApg7BZ8M/TWoIZkhW0iLfDf/T3jPgBxqWCjwSq/7pfhZoQ7IsRVTlAtcUxEcYEteuhZpRlEJQIpqlKCPAqO/tYSft0GdRVE71341RlXIzOzZ/C0gZUDHeEJBd/uyjFT4ZoZ+ERoDeViJpM1RVJNzbwgmlLFPgLMY+X+4tm4S3wStnVAh21gVJ/W3jUjVgb5N7GGNzkzmJ7FgESWaHVO8+0b55nJJO2tkeT8YaODnSuy9OZjK1YkB9Gr90LhjJkx9XtLnEGjPrS2qFZGeYwhBfu51FjaJWuQ+bMKgO8rOT4jb0uzISJqtbyvEd0wJZyv9PA4+4lsrdY0x7blY2fRdxqJAjr811WuMhHaIyU/Src/FlwwIdl6Dbisd2eG7LvvO4t0S8XlZjLOJ0rGOJTMgUz1UsU3NwXpMg7DvlaGSPkBVjopoT+exYwMyo2RFqbIbxK4pPbEi/4J0/XIrfcPTMGEiM+5/pvzC3gc83haLRQFcdb6VFaZ 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)(966005)(38100700002)(107886003)(26005)(478600001)(6486002)(2616005)(86362001)(41300700001)(6506007)(21314003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Pm+TGVfPT2AHgBRvwIJWR11KZ+p36w6bAv+TG2uP7+nxRQZMMvppQBChP03G3fdKK8VLVS69KD9wNoRH849LmIlC6ORprgKyRCGsQT+nrDV5oesx/jWzCgDfbtVPg6h2bSYsqaGb2xr9uof7IiTVlwSoZE2EN3/k3wNfipFLQ5ISSATbQBO8j1BoCMdxmQygWEoriflz+NKwMLhc9wCpU4Ssme8s0+MGckgmQltCi4rs3ba48sB76DONjnRmSQpXS372PW6bVOBHRF7+HUOO6o+eNpN7i9rayq4MwDzl34cu5gllBH0iHgBGZDMcpWeFCsVXWwg+JmR/vhfy6J5o+yD706B7OVAQ38FetcmQ6vf5Zt+qYFT0gdFeJEkJpx+bByzzR9xRhgoH4Q0N+kYieSP7Sc+AXPy2avchUM1FpFnIAnmoN1LkspdiUVN/RlJ/MMctfttgxjnVcxoU5J5jLAQoDuqqWn0zofXfMKiwIcQojRiWPuYdFSEtFRFtxspGz4MqVpPmycfUvLScUGqPi1bXGstZTqjbgHKbqX+XMOSRYSckbkLE0ThHshZk4cAJLjJAm6FWXB7x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MS-Exchange-CrossTenant-Network-Message-Id: 6ef9ea67-138f-41c2-798d-08dbff952b91 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:47:15.0122 (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: W26tTD3fyxGT63XMfg39iybaDFbYCjpnnfki1h546yb5Zp1xZ4MwPuPOF8yEUPXXhAuoymzMv2JcoTlhIwsoOR/C2q+sZuApHKsO92oACVLveBSINexPGad0uOK1CqAw X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYAPR01MB5852 Some boards might use Linux and another OS at the same time. In such case, currently, during booting, Linux will stop necessary module clocks which are not used on the Linux side, but are used by another OS. To avoid such situation, renesas-cpg-mssr tries to find status = "reserved" devices (A), and adds CLK_IGNORE_UNUSED flag to its <&cgp CPG_MOD xxx> clock (B). Table 2.4: Values for status property https://github.com/devicetree-org/devicetree-specification/releases/download/v0.4/devicetree-specification-v0.4.pdf "reserved" Indicates that the device is operational, but should not be used. Typically this is used for devices that are controlled by another software component, such as platform firmware. ex) scif5: serial@e6f30000 { ... (B) clocks = <&cpg CPG_MOD 202>, <&cpg CPG_CORE R8A7795_CLK_S3D1>, <&scif_clk>; ... (A) status = "reserved"; }; Cc: Aymeric Aillet Signed-off-by: Kuninori Morimoto Tested-by: Yusuke Goda --- drivers/clk/renesas/renesas-cpg-mssr.c | 111 +++++++++++++++++++++++-- 1 file changed, 104 insertions(+), 7 deletions(-) diff --git a/drivers/clk/renesas/renesas-cpg-mssr.c b/drivers/clk/renesas/renesas-cpg-mssr.c index cb80d1bf6c7c..23e5a2b46ac1 100644 --- a/drivers/clk/renesas/renesas-cpg-mssr.c +++ b/drivers/clk/renesas/renesas-cpg-mssr.c @@ -142,6 +142,8 @@ static const u16 srstclr_for_gen4[] = { * @reset_clear_regs: Pointer to reset clearing registers array * @smstpcr_saved: [].mask: Mask of SMSTPCR[] bits under our control * [].val: Saved values of SMSTPCR[] + * @reserved_ids: Temporary used, reserved id list + * @num_reserved_ids: Temporary used, number of reserved id list * @clks: Array containing all Core and Module Clocks */ struct cpg_mssr_priv { @@ -168,6 +170,9 @@ struct cpg_mssr_priv { u32 val; } smstpcr_saved[ARRAY_SIZE(mstpsr_for_gen4)]; + unsigned int *reserved_ids; + unsigned int num_reserved_ids; + struct clk *clks[]; }; @@ -453,6 +458,19 @@ static void __init cpg_mssr_register_mod_clk(const struct mssr_mod_clk *mod, break; } + /* + * Ignore reserved device. + * see + * cpg_mssr_reserved_init() + */ + for (i = 0; i < priv->num_reserved_ids; i++) { + if (id == priv->reserved_ids[i]) { + dev_info(dev, "Ignore Linux non-assigned mod (%s)\n", mod->name); + init.flags |= CLK_IGNORE_UNUSED; + break; + } + } + clk = clk_register(NULL, &clock->hw); if (IS_ERR(clk)) goto fail; @@ -949,6 +967,78 @@ static const struct dev_pm_ops cpg_mssr_pm = { #define DEV_PM_OPS NULL #endif /* CONFIG_PM_SLEEP && CONFIG_ARM_PSCI_FW */ +static void __init cpg_mssr_reserved_exit(struct cpg_mssr_priv *priv) +{ + kfree(priv->reserved_ids); +} + +static int __init cpg_mssr_reserved_init(struct cpg_mssr_priv *priv, + const struct cpg_mssr_info *info) +{ + struct device_node *soc = of_find_node_by_path("/soc"); + struct device_node *node; + uint32_t args[MAX_PHANDLE_ARGS]; + unsigned int *ids = NULL; + unsigned int num = 0; + + /* + * Because clk_disable_unused() will disable all unused clocks, the device which is assigned + * to a non-Linux system will be disabled when Linux is booted. + * + * To avoid such situation, renesas-cpg-mssr assumes the device which has + * status = "reserved" is assigned to a non-Linux system, and adds CLK_IGNORE_UNUSED flag + * to its CPG_MOD clocks. + * see also + * cpg_mssr_register_mod_clk() + * + * scif5: serial@e6f30000 { + * ... + * => clocks = <&cpg CPG_MOD 202>, + * <&cpg CPG_CORE R8A7795_CLK_S3D1>, + * <&scif_clk>; + * ... + * status = "reserved"; + * }; + */ + for_each_reserved_child_of_node(soc, node) { + struct of_phandle_iterator it; + int rc; + + of_for_each_phandle(&it, rc, node, "clocks", "#clock-cells", -1) { + int idx; + + if (it.node != priv->np) + continue; + + if (of_phandle_iterator_args(&it, args, MAX_PHANDLE_ARGS) != 2) + continue; + + if (args[0] != CPG_MOD) + continue; + + ids = krealloc_array(ids, (num + 1), sizeof(*ids), GFP_KERNEL); + if (!ids) { + of_node_put(it.node); + return -ENOMEM; + } + + if (priv->reg_layout == CLK_REG_LAYOUT_RZ_A) + idx = MOD_CLK_PACK_10(args[1]); /* for DEF_MOD_STB() */ + else + idx = MOD_CLK_PACK(args[1]); /* for DEF_MOD() */ + + ids[num] = info->num_total_core_clks + idx; + + num++; + } + } + + priv->num_reserved_ids = num; + priv->reserved_ids = ids; + + return 0; +} + static int __init cpg_mssr_common_init(struct device *dev, struct device_node *np, const struct cpg_mssr_info *info) @@ -1003,14 +1093,20 @@ static int __init cpg_mssr_common_init(struct device *dev, for (i = 0; i < nclks; i++) priv->clks[i] = ERR_PTR(-ENOENT); - error = of_clk_add_provider(np, cpg_mssr_clk_src_twocell_get, priv); + error = cpg_mssr_reserved_init(priv, info); if (error) goto out_err; + error = of_clk_add_provider(np, cpg_mssr_clk_src_twocell_get, priv); + if (error) + goto reserve_err; + cpg_mssr_priv = priv; return 0; +reserve_err: + cpg_mssr_reserved_exit(priv); out_err: if (priv->base) iounmap(priv->base); @@ -1070,22 +1166,23 @@ static int __init cpg_mssr_probe(struct platform_device *pdev) cpg_mssr_del_clk_provider, np); if (error) - return error; + goto reserve_exit; error = cpg_mssr_add_clk_domain(dev, info->core_pm_clks, info->num_core_pm_clks); if (error) - return error; + goto reserve_exit; /* Reset Controller not supported for Standby Control SoCs */ if (priv->reg_layout == CLK_REG_LAYOUT_RZ_A) - return 0; + goto reserve_exit; error = cpg_mssr_reset_controller_register(priv); - if (error) - return error; - return 0; +reserve_exit: + cpg_mssr_reserved_exit(priv); + + return error; } static struct platform_driver cpg_mssr_driver = {