From patchwork Tue Jul 30 08:57:54 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: 13747071 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010061.outbound.protection.outlook.com [52.101.69.61]) (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 1960A194AD6; Tue, 30 Jul 2024 08:49:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722329354; cv=fail; b=Otv8aiv7ejaR1sQclPWZ/uXeFnxm6Gfn0ywnNyxtxTXzRg7zEvmsQcmmPe90PZUu0wbUV+lybCcudR0M8Jbqn+iTSFlVyzhoe0Jq2sCVQy/6+Xo0MqonWEk5E43loy1uceMeHjzIIj2IzrypqesBB/oDcmMt4BnJk8j08RTWGUo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722329354; c=relaxed/simple; bh=jJHtN5cdjpw48j/RwDXB2cYoH8FaDj/mkqJp7Fm5m44=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=i4zCHH68hVzDxzkUlsQT5Xg0GtYtcvyu7eZpv6KbSukuzM0lEBYHUPhYvU87Uayfsqv/BuzXIYLqWIFBmjUeLkiN/IwxDRnlUhqHNrZg5cxCPoWGsi0X8d7gHo6dF40ZyGfvQhXEQ048br4KanpAw7a9E3bgytrNWL6zT1NOOiY= 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=SSRrAqvo; arc=fail smtp.client-ip=52.101.69.61 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="SSRrAqvo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uLdaqUcfLt7fEpX/TUAQ6CMAnSrDfSdC8W/3SSLChgKVvcja/ourLnZqcXCrs9pC0XKgxt9xVJbjVsN3y+l+JD634J2B51vhsHNqCVIFbeWoeIMb27KktNU+3o7bIGk6PEp/2d4LpOs3m5opuh5O94j3E2M7E9mNxF5AQhlRJFJz9AtlKO5t0xLknAsScVuq9TWFZL+6cx8nB+yw2p/uDrnCdOlDB+9WhkdFNM0hK1lvVBg30/hJZVyz6FiqZl+H1wmzFwJuHPhL1v7g6GvQjgMx7KjhCFy9VSLv+DxnQJkOQNIQa9sZVVyHqS8XMhLANnWfgpYaYQl4Kqr4RN7zhw== 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=aCbMP+Kpy0b8AZOm4vvY+WV4eoopEamz1xVTULY2PfAbhgALKnoEKMYlb5g4Css8ZKg8Rk+UXP7MbTBlOSqgMpuckunAAQAkbQ1KR4RfNz/wACTwWh7FkQ0ogm3uFNkEgl2ySfWhCo0xNSk/EZnZNQc48pA8h+4+NnTg3O0ywUn9dbgZygWL0UBa+HuvPr+Bz9fBP4tHa2K9pQj9Q+jQ8sAkfa7FcDYDnSAHkiLRhrQn128siYC8s5jAXXzVm6C1uI151ItsfYfhzoQCD+hkii1X/YuPGtw1H2dWDAOl8NmhJhDH16IQrHbylsZDBTJmNAxWK4p7xQRaAvLC3GdJ8w== 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=SSRrAqvoFZC2nSNwfrhqSBpHSlOkonmEYJ9jHoTomCKRTKfWJkCwfsThE5UsV/ysXI8j00Iz5FKZlgFp1/vE/tUct/+AOl7Q8SDm1d5D8mth7aeK/S1PocuICTkdgqSk4unm6IXRcXwxNbYapqsuKrygZmfTyiVYPc+AR5EOxZc+4c4e1E+aq7iT8EsPZJ3BzVNt3bTc7Rs1KIFJ8rS6VCdvw26phLRvVPdDHXAjerwWXXoO98cUjrD3bxQQL1Zhujal9NTf7HLz51aRcrWA/LQCJbCNFo6GmNWTj/JKu5KhNaTBWFIkizB73v9UTkCbep9p0lYDBl6P/Uwnsj+uLw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DB9PR04MB8461.eurprd04.prod.outlook.com (2603:10a6:10:2cf::20) by PAXPR04MB9021.eurprd04.prod.outlook.com (2603:10a6:102:217::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.20; Tue, 30 Jul 2024 08:49:09 +0000 Received: from DB9PR04MB8461.eurprd04.prod.outlook.com ([fe80::b1b9:faa9:901b:c197]) by DB9PR04MB8461.eurprd04.prod.outlook.com ([fe80::b1b9:faa9:901b:c197%5]) with mapi id 15.20.7762.020; Tue, 30 Jul 2024 08:49:06 +0000 From: "Peng Fan (OSS)" Date: Tue, 30 Jul 2024 16:57:54 +0800 Subject: [PATCH v3 1/2] of: property: add of_property_for_each_u64 Message-Id: <20240730-clk-u64-v3-1-4d2b19edaa6e@nxp.com> References: <20240730-clk-u64-v3-0-4d2b19edaa6e@nxp.com> In-Reply-To: <20240730-clk-u64-v3-0-4d2b19edaa6e@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=1722329887; l=2787; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=/uWDVm5pCySyF5BAPfXac+GeAhNij296nWQXpAULzPw=; b=bK6nhnpFwq1vkB5JFUMKPuRmRoHYNXYUwqkzCQhqc3Ym8Qk5nbVxHISzmn6Sw2hP6MzcBqTaj fH9xnAKmkbIDSfthoAecvQbGh/y3sAjHWcDdAy5IvSgbfc1RC2Pdr6e X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI2PR02CA0038.apcprd02.prod.outlook.com (2603:1096:4:196::22) To DB9PR04MB8461.eurprd04.prod.outlook.com (2603:10a6:10:2cf::20) 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: DB9PR04MB8461:EE_|PAXPR04MB9021:EE_ X-MS-Office365-Filtering-Correlation-Id: 15e68d66-e99b-42e0-9c2a-08dcb0747882 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|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?g9+W0J8u1eb9K5BqqCN2YdWklI/Ncto?= =?utf-8?q?EFa/cATsl+UBpo8B/2Kltw9LrA6urcBpHyolx3K36PsIdco1XrWJrxxAKlUIPotF2?= =?utf-8?q?90BmZJKo6fI9eOIkoEAHGDS4qDhjxZB86aJlat7a0AWiiLVdl5f2uwtf2rzkuZE55?= =?utf-8?q?8FQoX+QLiA3BZAqLhaGDKEcMHYqDf8ydziJuHUYQ8gwHisUGXCo/T66MjhuMKcxpV?= =?utf-8?q?TCp9XPbKSDtW/km4gWvK9t8EbK8l0TMayoYFxgQI9snaeaiZSdlCaLFvK/2XYMnup?= =?utf-8?q?RKBvZH5Z0dSFvQUY50IWsmHvh2Bn3yMhtnpx7AvUZNUjG+3lO88DrDOXOfQJz3WmS?= =?utf-8?q?ma2o7SN3QnjR8xbMQ43VnWK/qiHiofGAaXzzi1DFP5vZfGC6xqwLPH07xyOinBz8q?= =?utf-8?q?Tu64iIuNq1brCGaz57x1jC3KuzER+9Fy34hhKY5+lksMTRLR1RTzhjMvSJmWo2JUK?= =?utf-8?q?4upuGl9T0A28p7OA+zVjVbVcdrumOAJuixTjjubDYpJrPqS0prdHM3EVfONxJFwra?= =?utf-8?q?pVlR1k/gfJrU/DqkBXHKFJsWhvZPGWbYKB9QV6DUhYehO0b19EECqkB7mESxYAmIt?= =?utf-8?q?bn+iij9bjICnwvnVqoR7Is/rw4G+sZrIL0p1725UezA/sBRIp+tXZGZyG+xldNnuc?= =?utf-8?q?TknOI7/VvAoLZtWwTaRMorF6zUe6/ZwsRH5EBfIKkmxG/deP/qNJZ3IrhpwZSbSPn?= =?utf-8?q?VYH4G+/NQqp3xMW1B5BZLAdmhM7FYBRpC9updtvnv3cqqsucN1Eehq4GouYGEUn8R?= =?utf-8?q?yJkWmcyCANtOkky3cPCvsNmmAtlP8ezEQL72vzjQB0DonWD1cA1ZarfPPJcCYIxtu?= =?utf-8?q?XxwEWd5atXig0VXQiYfYqw7G5ikyp1FdsAgomJq5PLvxXXaoSFVkhPBEU+GQuOfSG?= =?utf-8?q?z2vSte7fzNv6CYXfdwSgtXGMEmm656uKKDSaqb6syTu/Pxd1Hsl8+0kMDBmLiOuw2?= =?utf-8?q?E23/Qem7MfP6WKZKiaRCNFnVW5tL9itGpJgyGLmwQQkC84Vn7IvpnXfEaDXzJvDja?= =?utf-8?q?N+XS63rTRmVfWH/7+5sI14IW7OrO5RaPU9fBqwBZqhxDarfmmgmbJvxq9Y3RsVoKW?= =?utf-8?q?SqwmgnsMHPxPZpsiDeooVHFD5CKLDbY06N8WMGZ6m62nd94WMVJ6jjclUAIrQF7mD?= =?utf-8?q?wFsQCNm89m+KVK5g+LPcOpUNh9/ZJgVafh4JojzXxIjIf3CqYEUlGyQ7gVwf41xE9?= =?utf-8?q?8tvPsy2XMyobHQfPKv+uEN2D0zhlYGzOfpnGlYqIVTMo8YFQfQbmIlmmOnGAVb9+p?= =?utf-8?q?3FfiQTdP0bpIJElOARrvTHEpKTMeBwWOE5+7V/nwrpse37ochxhhsZu5bgbPPkFGu?= =?utf-8?q?v0daOtxfXK1ECZA+aXgAJc+T1kiDsby2RQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB8461.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?FfUyqprUjygLWogRT91NDZMFawA3?= =?utf-8?q?t17QCIPTeyw1KAsyVmZLDRWj/nvJZKEpLB/ngdLjHWs2fairy7BsaCvLsNSY8qWK7?= =?utf-8?q?FkDJyv4Oidbf2AD+f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VlQNJo98hCSQGHFYymwWIuTYnPaRFK1jjL?= =?utf-8?q?71ZSjb+/jKnDWgMIX2Ii2CjEhRTjsM1cQ1qiHH7sO6TlBy9TdJHCpP8fdLOZQCmlO?= =?utf-8?q?OadNSlR00yM46W/VwXA6lJqeGgVjjy9OVbWrYYG0u2/ML7gbiP4NvQE4W4mG9+ldd?= =?utf-8?q?lgbVpK1sBi+LRU+xx6UJPE3e5gFemt97RpsGyM/YmzjrqoWD91/3XnfxABzgJzbdH?= =?utf-8?q?LlKJj0pDV+cv6ITgE2LwU+thc/ZvVOS/0Iwv4WliyqScGyJp5kMDLIK1zZKZga+3l?= =?utf-8?q?5WPuDFB0pafmEDlWuJZU1YJ15h453DiyH0LLgeHmFIZomWspHEvAis+nXvm0SEVuL?= =?utf-8?q?K5w9e2akoNMiub5XolFjhXuINre1/hublzuNUg0WtXEYRh6VKb5sAfJzvf5kjcwM/?= =?utf-8?q?EexK0/EorZp2doDdE+4/4dsbSQJh6cv3POeUy54IILI80gMduxNEm75SEle7a9U6d?= =?utf-8?q?cERoL/DLRTibQkZdaN8iWtybDGiyBvEMuycikwI26Vuk2roJtIyt2u2/633zs6XsL?= =?utf-8?q?SUkVU50foHt6?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15e68d66-e99b-42e0-9c2a-08dcb0747882 X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB8461.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2024 08:49:06.7345 (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: R4UdnlKsFilhFOYoQksr0/d95xFWB7Rjf/SQa/z9R4cGysdNNKwoaqvflv6CTaaf9ZToNRf6+ll5EDg6j8fb3A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9021 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 --- 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); \