From patchwork Mon Jul 29 02:30:52 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: 13744190 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2087.outbound.protection.outlook.com [40.107.21.87]) (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 452A6770F1; Mon, 29 Jul 2024 02:22:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722219724; cv=fail; b=C7qTMDRIsrke8WWnA4i/IwWfTooyFyuRMAFmzZ0xPMqcgAo6l+KsShgZkCe4KRDtiEVMPnqWVKntq9wA1o2wBaA/DeqddKohGEWL0AbMnSRkhfugNg6FUgAd5ZHkPaNMAzSin9ewsSmCU45vItAhLywiaCeG7RUAUFALKTAX7e0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722219724; c=relaxed/simple; bh=ECAcC70VNkmHhGoOuWrQrqiUNXqEeLqwVMObpF/upJ8=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=eeoD5kqU8rhcpWFfVdA4E9JvNXoxvK9XJfcEsRPXk+059nnBVYxGnQyP0btp9a7Dw+dtkg8M0T6gnPZzNxALkh768pduUC5Q+ormS6Pjr89c+XE1BPc3nRPt4FEKju9uOg5B+IhorqKy2GAJxmDNGxkuOwIvSf1w3ZzAIGF+Mzc= 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=rWl50BHY; arc=fail smtp.client-ip=40.107.21.87 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="rWl50BHY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aHsO2OzhVcTMZCgbSka1ItDfVrYITXki0qdFZIZTCj8ZObgN0gdp0py9sHMT/ZfV5QiFva7xDEIf5Z7gkKfHWasWlQdnUhyy4e+XeBbRZby90Vt0Tmi13XoN7p3Hxfa9i+grbdJ4oecvT3zjcrLj9Tb5bScwYAjl8m2iaF3RaMAjEeAZCj6cU6FJkLoKDGs2b5lehzidN6pQhwYZDYK4P4VebAikaIYFPiRkubglH5wSlA80ay6LDzLkJKnBmWfzUMJ66yZIMUCT7ZmzHLC33KAF0TZellYZlKxF2tigg4ZL7+mskig5WO9o/+y1hG5hPo3LiJm3e/26pjbPRsz1mQ== 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=UZckXn/OMalNyPvz/0j6CIflrCeicJiMPhPygtPLPC4=; b=cGmO46IwmrsH9JRjt1w1dIHSoJGJv0wAsVeqzD7//o4CfxFUFCFcO47IYTTpqoyAqrKOpzrV2xx/OdwoM+q/MlziAo5OXdgK7yjyvLteYmdX/MOaUx4AeTYOFdY+81StgPar4xSFsOG8IvIUPtfIIGKaRZSIGYhlLh1PGvrVpKfKRMmt2ltWc8e+2eodkIMmCnrlAyutny6ZCmqvKA2HpunBnNNfLRNuuyjQr48WUEiXJozgFLZjD5pp7wM2xZea5Bw3EzLIWsUjGVkj+IckuS8CPZcovU0AG8FGWmn+l53tHi0P/XWaGDht0SKLBaeoVUUkovjCbQnHPgOaDatg+g== 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=UZckXn/OMalNyPvz/0j6CIflrCeicJiMPhPygtPLPC4=; b=rWl50BHY+6r71TevAx5LRQRa37ZklND9CFVM3TDgLF9jfxTxtDPOhVszTl8PY5qFYKeIVMP77a3K0kKh0LvinQVf9v5g5VJ+RFWF+FIpsS5CIisNsWW570+R/SVlRbpcHkZB/jFIyn3yTMemIO6P9+uUbJB/PIVK0Nk4PDOW47+2ZdZekKwex1DXVsHSUgWOZsizn7LYSceRPtBTSUXmnGuUxvFFOpaZMMXQQ6lx6YTOEOAZqfK9vHSBxeYlQzT9CvQXf8jYkL5gI39bFkcTTa2e33DGr/tM8pBj7GOoPR1p9OS7E9OyEKXK0rmSGqizR2nYeSHgb6Oo3ZKecLWBCQ== 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 DBAPR04MB7368.eurprd04.prod.outlook.com (2603:10a6:10:1ad::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7807.27; Mon, 29 Jul 2024 02:21:59 +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; Mon, 29 Jul 2024 02:21:59 +0000 From: "Peng Fan (OSS)" Date: Mon, 29 Jul 2024 10:30:52 +0800 Subject: [PATCH v2 1/2] of: property: add of_property_for_each_u64 Message-Id: <20240729-clk-u64-v2-1-ffa62ee437e6@nxp.com> References: <20240729-clk-u64-v2-0-ffa62ee437e6@nxp.com> In-Reply-To: <20240729-clk-u64-v2-0-ffa62ee437e6@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.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722220263; l=2731; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=8CQ/HRjnMclVYkf+T04PTSQpcqAJ1N+X/qi6aupHpMY=; b=ER6Oi5XWGKIOZIG6FLrcTDSS9XH+HxBXFXXv9M/Iv6UoWQt7arfyc+Nt2lywzQLAsG8o++gLm 3BFzlhuzaJRC6OTqc+dJIqU1VcIKj/ggwDbuFDVinLEe0feHd8UrxwO X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR02CA0001.apcprd02.prod.outlook.com (2603:1096:3:17::13) 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_|DBAPR04MB7368:EE_ X-MS-Office365-Filtering-Correlation-Id: 48e40a8d-86a4-457c-98bc-08dcaf7539ae X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?+Eo0MYtX9asNOh1l1vzNLZuFruwRL+3?= =?utf-8?q?paNAuQ+TU4aZDzziQaMKgo2F2+jSnEz88HQv6T5fZjCqItejt7r2uEVFB//ME1E/p?= =?utf-8?q?ggRoj5D+VNBWCIJ8T1t6z0zCl0mu1SX5rEVxUnQhwA4b95Un74Cnsluu8T1WZ4B6l?= =?utf-8?q?tSXt9bpX1y3XkkDhlzoFe3dBnPYf/m4OJed+VLLF+eVQBZDg/nLkoSWHUjCk8DOdu?= =?utf-8?q?Ly5nYDznunJXEgmF+ESVuGGmFKq1hN4yQSwn+VgDYQTlayirOsXq5mXrwFVJxjV3F?= =?utf-8?q?cbw62fq6Rm8C46fyDKf77ye9HPfA7BSRKEXK0EDo23hCYnHd6qQtFN/RI9yMhfnnH?= =?utf-8?q?L6wiVdJFiX9W6d5fN61eZ/YinQFG/2lRrWJfjktb1RKP2oUBmtHIdCAoUcd1h4djC?= =?utf-8?q?Kq8AXYXHp9wu/ojB08r6Nu9zTEgwIk4B72fsuLseEf/N2h/4S+MK86uPZS2dEnvUM?= =?utf-8?q?KtsBq/LI9bFmxoLNea9b87bqIMBQVM1vEWRi1n9cVnErr8aaOvz/lbVcTipfQUgDH?= =?utf-8?q?8xJeDdK2EZUT48j8uWtwxQP+2hKxYFf0YR6ijqR6mZriROE+98415HcT2kpfVM8Yy?= =?utf-8?q?iifNpCHsA/KMQUT71SK67PbeEqKqlqiWOovT40b/kQvKBW6xNR2BEdCXKjz+KQM3o?= =?utf-8?q?d9W8qkOaBYyA+EHsBD+MV5WI8Sul3kT17gE56lbASG5lw+TmcoVN4WYDwYJvNztef?= =?utf-8?q?G1xG0zvLs0Wl9BvGxJMkn7wQEsA4O94jeqZxmPUhSP8LxU6UvE2wOp97sfXoyWxsg?= =?utf-8?q?QdLgAMiWxvlxsNd459RwBGiXezKvas/s1yIzD7RZto4RQ7xLFa7bp33Sw8P7oqTVb?= =?utf-8?q?u9dYYPXFH3BLsXBL8ehNELss8lv4Tbsq3juWPve5WwjvJ90yo09CKroQngc30k0Vj?= =?utf-8?q?F95xNOXsVChL3mlImkKYyDVjVXDOKfdMKSmHRFjftv9HyafRjjkneGkc/MushCjAS?= =?utf-8?q?IC60cHqSJ1CYSL1cm6yQquPAUsNPZCRpHnBm54I+r+mnhAlitX1s79b8hG+iPIMST?= =?utf-8?q?R4YhY0mnfAtl+d6eLOFougghjzTHonk12RHWz1WxurfQfo59bKJ9BmBCYxOy/K8vm?= =?utf-8?q?7uvw4DHVo7wVysLpPjwyHBwluduQ6fOivGQCN14cDXdntt3NIL93LZQlRweKmDsWp?= =?utf-8?q?rZ8ENkTAOoVvpU2zILXpPsHAMZlXcQycZDn+9qhnuxfM2j3v3nGfUS6LzsFELObPZ?= =?utf-8?q?s6WeOrJ4W1YpfUYVVOLcw/p6UhLD/xzJveM8VQjPPodMSgsg+Ui+5i6aZrVkfuay1?= =?utf-8?q?stu/cnPyLu+Itz+m7g90ebb91VCrRbFCp6wl1531zm1aODisc++Mq6CvXOYSEFd9J?= =?utf-8?q?Ua8GVjnX7s4ZofpgdWymzfHEOAAnCjHRgQ=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)(1800799024)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?VZtVr6NEeQH72IrVZto4C6SHnEsA?= =?utf-8?q?Lrzumlbe3nleaJwCbKmJpAiwpt+1ZLmEHME3ff65R2V2e/ukMeF9bIpP1KUjOxbO5?= =?utf-8?q?8/Vsn6IDwa9LoqcFcn8Y79nhbamKIQpPS/eNs1r3fTunMX/0bYMXUuixh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7L6M?= =?utf-8?q?j03aF5reZkIwQao2Cs8Wf2er2FflEG64pQ6Ne5Bp0vcOPVPaQEkioceCSXM6G/ZXk?= =?utf-8?q?nnGwzChk3X6ks0b4LVWaY/HCeWcIOFKfL3OuszcgFogVHZpwep4XsSKL8WrWEmTsG?= =?utf-8?q?jgZOUR9Onyp3HgiSPY1kLJJ03m4XCkgkXvhNhmbCWDui9VHdyTPMCF50Tb5UFAI62?= =?utf-8?q?bfU2y4J2pALcxI+utU0nKz4APH1+/rUaaTIp1uUrZQ1jNBrTIFtgaAciSn82FqbCu?= =?utf-8?q?/iEl0uunQ4A0h+xO6iPSNBFAsF1lpabcgDmQ1IDKZeKEi4d8lHEN95usdQgSosSop?= =?utf-8?q?eriLuh5kroAa1YR/intV1hhh7R7fVgkuTWlDVUf2jK7Cafyzu6enh/nPt49uz13J/?= =?utf-8?q?f0jW5dhcc3TDQxenzUtLtwd85nr47e6E+sWuDqZkHholH60MSh6gFGQgNUvKAxXnA?= =?utf-8?q?shi17UpdAqiKaMzpiCcHminH9h3fwOeUbJVO2DyZFgXfz1UM0lbN20zB3MW0eTNOH?= =?utf-8?q?clqzPHw3GoG4?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48e40a8d-86a4-457c-98bc-08dcaf7539ae X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jul 2024 02:21:59.4427 (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: AA/RYE1wY95DCDX1Ue1XbsaK/m0GJz7dsto8ll9bRNsfbH7EaI6SXDcGr6OQZ3wT+N6GVNbFgXl3h/lf/QgQqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7368 From: Peng Fan Preparing for assigned-clock-rates-u64 support, add function of_property_for_each_u64 to iterate each u64 value Signed-off-by: Peng Fan Reviewed-by: Luca Ceresoli --- 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); \