From patchwork Sun Aug 4 12:32:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13752618 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2043.outbound.protection.outlook.com [40.107.22.43]) (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 B4CD936139; Sun, 4 Aug 2024 12:24:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722774248; cv=fail; b=KZ3FjATSfDl38yL8Ys54SjGK+u3QnggxX9c2w6M5ze0yI2wklrADvCqCqCepL2zbOtQt3LfQm+zXNQ/zEXhUIAq0sFmqE+4GzK9Z+TanKIyfO/ZgmUprxSTxOWXVaOLgzA4ULQ6XLUIYZoyo3wCoX+bqQwm9lgiPYV54uIjj0CQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722774248; c=relaxed/simple; bh=jJHtN5cdjpw48j/RwDXB2cYoH8FaDj/mkqJp7Fm5m44=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=ouFRKgzUWAFiGqUQd4BmDQButuTc5S1qFKF6z3GxwhMfj2rCtfhMAENAqqC+d1H7hjoXBd9vsB0GXc77DSdi4R27eNhz75Vrz12qdOnTh7CTCU+rd25idmP9O0+txGj6MCiTiZgoh6vWeN/vYKDDB+uCtM6lIFJY5K8uhPcfhJc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=VjyrvMEL; arc=fail smtp.client-ip=40.107.22.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="VjyrvMEL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TPOrdhHlK2PQSZtoznZ++fU3a6XCavKAMtWeZnWCPJATMGkl1empKo6byOcP9IucmcKRUcT3YDfDMo5nMYiumOqvSv9hJrGEHH+hIV39/sMNN7wlVYRxxEISQydu3eFpYOk5+6K4c90RVciq27zTy8z1hnMd8ljhlNesy3cD2K2yYt2Ei2EqDUkve4EHInfgElhE1dlEmju8DWXKaKYRA17aRkh3IlJcEIuhqmhPturNp53kN6E1LMJPB6eUmB8Io9aRn4aYzYEZJQOK7KVVQge0+2z3jacsjzNgdGttZkee+a1/ZwzaUgLCVeWW9fMCD5r16Hph0sZgfRIaTW9TVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Inysam4Nwgvdh+lgZZMJHWWZI7brIH8XEIf9gyI9WyY=; b=Nnb9B5JW7rxc4+gExaiHYq/Y4AQsbx8+yFhGguyjt5gSytjgToy4cz0u+26oddl4kj85m9boGs6v89mJPXjFTyL9V7PKl6c04XN7Fx9FrjQ3xuMGEkzayuwGxijabb2qZZdRuRatR0yMuK0el6JVlJldElMCyMGBpQ8Tpvu1pKEsG5IgmHIQBmWon2bFX0xKzWe8g8hZJCEhbkLsKMQDMpF1Cx/qaA0KKO/ljHL5mBTRTZ5lbcD9PTNfu9TGLnAWTdWryClzHQHtKa12Y8FrBqGxHySaMGKebOTpZQoF1/i0qmPLngEOW+Ut1wHOUnoYV9Z015qFFfQr5mTC5zMxIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Inysam4Nwgvdh+lgZZMJHWWZI7brIH8XEIf9gyI9WyY=; b=VjyrvMELoZTn2VRN0S6d8il/f1y1mU4CRbNFyt3kyR/LsNuG+oXHLzbpP2GAslsIJblLgD9hFu3XgsxTTQzjqAPgx7a8AsnAffPMLgV/c/q8mVw2qb/3/3MEdwVxdDOIfr2l1jyrsG5z4vOlT+PtgXXQLs5/FulPNDv7n0OrqtonLcH3DcFKtC7WnAjWnKJx/1jxh7mUdzaFGTa+Xk8ddVhh5HPlpMt4DslpssBjI+A6L38TbedCMZiXf5us57X0YIZVZbUcTz5HfYDhEWmpaPm4bmnJ4gghC3tjxhlaMMqMSVWyEltwHGVuIiC3RI4y3s6TARNECgtDOjAWK5IRvg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by DBAPR04MB7413.eurprd04.prod.outlook.com (2603:10a6:10:1a6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.25; Sun, 4 Aug 2024 12:24:02 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%4]) with mapi id 15.20.7784.020; Sun, 4 Aug 2024 12:24:02 +0000 From: "Peng Fan (OSS)" Date: Sun, 04 Aug 2024 20:32:55 +0800 Subject: [PATCH v4 1/2] of: property: add of_property_for_each_u64 Message-Id: <20240804-clk-u64-v4-1-8e55569f39a4@nxp.com> References: <20240804-clk-u64-v4-0-8e55569f39a4@nxp.com> In-Reply-To: <20240804-clk-u64-v4-0-8e55569f39a4@nxp.com> To: Rob Herring , Saravana Kannan , Michael Turquette , Stephen Boyd , Luca Ceresoli Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Peng Fan X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722774785; l=2787; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=/uWDVm5pCySyF5BAPfXac+GeAhNij296nWQXpAULzPw=; b=AaLZMkjvJbIRJu9kcvya9BVP2zvCnZC09Wm/5CF4hx7T1aPMA+kl8/CW65aM7EzzUppKlibbq jntreCoxCFPBI1nOQwRZkyUfA6xt8eEfOrjoyRCZLbYHKu0XsnMrS2G X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI2PR01CA0047.apcprd01.prod.exchangelabs.com (2603:1096:4:193::10) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|DBAPR04MB7413:EE_ X-MS-Office365-Filtering-Correlation-Id: fc070f14-d584-4333-8066-08dcb480534f X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA: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PhWgNu0w0csNHwREFfqtD?= =?utf-8?q?hxV5yz0IEoZ4XEIn15DIjQte1beMatt7IT0pYQ7kkalWP2LN0CEfxy19fJ0ZFDLOX?= =?utf-8?q?ivIvuEBeekeHayHf1X++eevTCw9uhZqIYUAKIXI9Sa+Gfxm3XDs9jPTd1f/E2BQwj?= =?utf-8?q?ngUD5I3PbvuS6ffAMwoFqHB4aGTY9zjX1ctWF+bppcBVGxivmiQoQ9EIOcyccUEmu?= =?utf-8?q?PQsW/q2qikWxEO/fLmhDeBeYQHwVuatYD1+utQo75WeX9n4N2okK38MqYTnOvh5uX?= =?utf-8?q?p98o00Ztit7jdRvZWEVV98o9j4NwypJwi88u6e9k9X1cSIWVl8y69iI3Txl51f+Xd?= =?utf-8?q?RmQFYHx+KVwTQJQMphpzdlIEdFxSscTujOn/m6i1K7jTHC599MhUi5MJ8LxD21aRn?= =?utf-8?q?lF7HxXweohe6nJL/zws5FBkqqBWdv89wPM2ibZTnR0OQGa1RIgvJVdLA6f3Ce3rZ8?= =?utf-8?q?/PsTHuOjc9esRff9woS31NfXbcCVyl4Q7MWN+DORyF9Zb96r+zCSIL55KpIAdhUst?= =?utf-8?q?B1Lwzvh/noFDmA5KMM+AOYKzDLIy8Xi0OQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(52116014)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?vHT3ynttJkM+/K5KRYFdgx+YUR+O?= =?utf-8?q?EL3Jx24aYI2amg6ji85p4Iu6yqAbt+J78scpe3DLplFZ092eamHSMJFYTJts6Rsbq?= =?utf-8?q?wkt6j5utNar0hW6xkXCAlzAKykAx2EXc8BZG9/IkLwTbZo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/cR2W8sMQg?= =?utf-8?q?RMfg6LlR+C29+8yonKAiPIb7QhqAbuh6tG8AepnmZKX3r51npbP2gSNx2LtHMYYjU?= =?utf-8?q?PSHCuB5ZVzcaGuCjLp0hW6gGB4+x9Y5dIYsRJijSVwdPae/3+U809htN0F6lPQ/2S?= =?utf-8?q?sOvQlXObAdjH4oumVmrju5emYb0nSznLqfs2zGoePF+QVjGCM8Bz9ERXucz3UzYkw?= =?utf-8?q?h5rcWhA3YkV3pFdTNcql+0IeN/JTnMn1II5msWuXftWxhdea1P7VENd4WcgrwJmxL?= =?utf-8?q?i1UfxjcV3JuPFoh5DrFR576dhbB0//0BuYrcxZrrmAv43VC+uDXe+/LhqqOvl/Z/2?= =?utf-8?q?xzno2dIUQKN83jINkyZbybnGzXmK2BuHuC15X706MtDnTGCEOw/ORD/GlBxOJfaFA?= =?utf-8?q?3SUcmguSfwk5akqcwBkzHhRqAurjd51ygkhhXphRfNqkZpFSkWgHvFdpXY7PrCBpN?= =?utf-8?q?k0alBR0PsUIzcyfMriystiR14NIqFuU/ivs7I/nK3vz1s9tNlVOE8eAQKgAShUSzp?= =?utf-8?q?TSaiwYETUAfe?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc070f14-d584-4333-8066-08dcb480534f X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2024 12:24:02.7176 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NiyutEYalAxiuJXFzv5NI/56CaMPF+3W+veMbWPwzdY7AOOeboSOLELo1mQqlFrTW1FRWSnAA087ngdZbLyWtg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7413 From: Peng Fan Preparing for assigned-clock-rates-u64 support, add function of_property_for_each_u64 to iterate each u64 value Reviewed-by: Luca Ceresoli Signed-off-by: Peng Fan Reviewed-by: Rob Herring (Arm) --- drivers/of/property.c | 23 +++++++++++++++++++++++ include/linux/of.h | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/drivers/of/property.c b/drivers/of/property.c index 164d77cb9445..f70fd8deb9cd 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -548,6 +548,29 @@ const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur, } EXPORT_SYMBOL_GPL(of_prop_next_u32); +const __be64 *of_prop_next_u64(struct property *prop, const __be64 *cur, + u64 *pu) +{ + const void *curv = cur; + + if (!prop) + return NULL; + + if (!cur) { + curv = prop->value; + goto out_val; + } + + curv += sizeof(*cur); + if (curv >= prop->value + prop->length) + return NULL; + +out_val: + *pu = be64_to_cpup(curv); + return curv; +} +EXPORT_SYMBOL_GPL(of_prop_next_u64); + const char *of_prop_next_string(struct property *prop, const char *cur) { const void *curv = cur; diff --git a/include/linux/of.h b/include/linux/of.h index 85b60ac9eec5..de481a4bdad0 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -437,6 +437,16 @@ extern int of_detach_node(struct device_node *); */ const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur, u32 *pu); + +/* + * u64 u; + * + * of_property_for_each_u64(np, "propname", u) + * printk("U64 value: %llx\n", u); + */ +const __be64 *of_prop_next_u64(struct property *prop, const __be64 *cur, + u64 *pu); + /* * struct property *prop; * const char *s; @@ -832,6 +842,12 @@ static inline const __be32 *of_prop_next_u32(struct property *prop, return NULL; } +static inline const __be64 *of_prop_next_u64(struct property *prop, + const __be64 *cur, u64 *pu) +{ + return NULL; +} + static inline const char *of_prop_next_string(struct property *prop, const char *cur) { @@ -1436,6 +1452,13 @@ static inline int of_property_read_s32(const struct device_node *np, _it.item; \ _it.item = of_prop_next_u32(_it.prop, _it.item, &u)) +#define of_property_for_each_u64(np, propname, u) \ + for (struct {struct property *prop; const __be64 *item; } _it = \ + {of_find_property(np, propname, NULL), \ + of_prop_next_u64(_it.prop, NULL, &u)}; \ + _it.item; \ + _it.item = of_prop_next_u64(_it.prop, _it.item, &u)) + #define of_property_for_each_string(np, propname, prop, s) \ for (prop = of_find_property(np, propname, NULL), \ s = of_prop_next_string(prop, NULL); \