From patchwork Tue Jun 25 17:51:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pengfei Li X-Patchwork-Id: 13710436 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0F7E6C2BD09 for ; Tue, 25 Jun 2024 01:50:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HyB8OvVTfRDbfqjh7YCnCbwhZc3Z75NK3flFYNlKZRI=; b=QOnAjJOjKFhMN4vidGkldYcYos mqyyJQnevByXDazqzVj6hnplndoBcwjIc3BVbpnCup99w5h4M0XxrotUVSUmIizTxkc3H25LVXoXV QtREJzR1ZK6LT2Fsc+edhDCNJ2vbLthzGt9VO6Z1epR9CFIgUEzTmkgWm9zQ5ZwzfDpw50tirPEBG +15peI5SkgKS8LsFXRIyC3bCnqxN5y1gV44yDfzDwg+WFZ+nyGGKPOTCzQMD5xRPDlYYdwVLSrPHa w4bS+mB/YIKDLV61fdnn9htuxXP6Li97GlduqVdfDdbqYc0QoGgdX27oPBkR/9SjSk/NVHi4cbnCM Ztw26+aw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLvK4-00000001GAl-2VMq; Tue, 25 Jun 2024 01:50:16 +0000 Received: from mail-vi1eur05on20601.outbound.protection.outlook.com ([2a01:111:f403:2613::601] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLvJx-00000001G7o-1nhX for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 01:50:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WoJvvvXg1uNaW37qK4Pn84QE8agrtjNBoTkYxp3Iis1pg7+r5DbCXthgizCa9rCyV6QTaB6f+HZGeDiCjWBgxYuXBvmiLJk2GJHqYa83Lt2nCUYKvzwbk0RGExMOYyYdRfCkp3iK8/bcYMFQJMhaaoEOC9f+f2CPngwlfoGUq2G/XfndbPul9BWjixN71xe2Oz8agl7sVCfeSWhEo2x50F1pX1qed+o5oulsFPF1VuJTjVw6iwDud9PuJWJ/z+UomUe0QmO4j1nEt1BRhYpCDZbGPRYB5jss1Nn5ldLY9TsOe9rF+aKqQKA2j32ZGoYuaDk3ycVnodulObuT9WAIuw== 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=HyB8OvVTfRDbfqjh7YCnCbwhZc3Z75NK3flFYNlKZRI=; b=HMgGtVni3Mo5CFuWO0gjd99jTwFTQJiPBZboJZ8dGeo4xpWfGbhUjOBjzmYaHM6uCb7M3kXUiUvtzk2dczLDeXgyVEoKmXkas4uMTqAkFOHlsDwnf84qrQ3XkxB7LQawCs+FdCQVJr3DP/vyE0+LgoaPsG0ss1s0Xv4y0yGUVGskwcnk+r74QIGydzphxFQrhuvuroM+vNo/1Zi6GCMaXDKBRYiIKacPjqC+XSYKuxTvKVAz0qZa8jkHdGiK21d/l6F3Uj8Gr+OVvpSNr4nRmfQovMwpsVKgVYxN08D0HcF2/8XxxswweGtlRBkOBuIBw+Wycvok6k2OW2iIhl8Edg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HyB8OvVTfRDbfqjh7YCnCbwhZc3Z75NK3flFYNlKZRI=; b=gofaumJxMbXFncwN0tU4tCDlsjAroT8Dqi4E+CXQuxxsjOaOvJhVzGm3XO9EC6KAJs7b6wO26kDCXCQGvYNPMchiRkTleqt5wXypTLorMelCSPt7PZmEn+UT5U/6VmefY1q7gCF4+32QoRuKPkyn0KvrJ3NUZakdnyOiWnD+KwI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB8PR04MB7065.eurprd04.prod.outlook.com (2603:10a6:10:127::9) by DU2PR04MB8965.eurprd04.prod.outlook.com (2603:10a6:10:2e0::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.30; Tue, 25 Jun 2024 01:50:08 +0000 Received: from DB8PR04MB7065.eurprd04.prod.outlook.com ([fe80::8af7:8659:9d42:bd84]) by DB8PR04MB7065.eurprd04.prod.outlook.com ([fe80::8af7:8659:9d42:bd84%4]) with mapi id 15.20.7698.025; Tue, 25 Jun 2024 01:50:08 +0000 From: Pengfei Li To: krzk+dt@kernel.org, robh@kernel.org, abelvesa@kernel.org, mturquette@baylibre.com, sboyd@kernel.org, conor+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, ping.bai@nxp.com, ye.li@nxp.com, peng.fan@nxp.com, aisheng.dong@nxp.com, frank.li@nxp.com Cc: kernel@pengutronix.de, festevam@gmail.com, linux-clk@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] clk: imx93: Drop macro IMX93_CLK_END Date: Tue, 25 Jun 2024 10:51:46 -0700 Message-Id: <20240625175147.94985-2-pengfei.li_1@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240625175147.94985-1-pengfei.li_1@nxp.com> References: <20240625175147.94985-1-pengfei.li_1@nxp.com> X-ClientProxiedBy: AM9P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:21c::22) To DB8PR04MB7065.eurprd04.prod.outlook.com (2603:10a6:10:127::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB8PR04MB7065:EE_|DU2PR04MB8965:EE_ X-MS-Office365-Filtering-Correlation-Id: 1adeaefc-bfd8-410f-8fe0-08dc94b92412 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|376011|7416011|52116011|366013|1800799021|921017|38350700011; X-Microsoft-Antispam-Message-Info: M1WHTeNDZAKN3xFYggXJEr9HoHOk2mQA8XpL+FZAy3ozRk7iBH19txBQxsNCkiYxIqazGXhhBNvxcKBXvYi0TLzaTelB8/hFHCqX26fAE9Tvan7YoYVQckalAhl6DeG5VJhEr2PTH/kXtT56Rx9wG44UeMuBUuH6Gw1Wa6T9QJmAC2j/0D2s+lDCtzLhjByCU4b69WO3ZfgTRB3rK05G00y/5PR1xS5Q2vEnUxf7Bn8k73vdCprgfiF7JZyyKBd6dzWYQBCSvCTfdCF31CGE0L+WW+qdro6q2IQj4vr8kC677tTbyKocOvHk+wZ2AS7xM0RgaSWJZneV7pYz7yEze2OUX4Y5Mbt3vNeROnuJX5Fb9BvXSmY/5Vp3YhKCclwRyBQEHixFFcw5LKI2WpkH37bLOGmsu1G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.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(376011)(7416011)(52116011)(366013)(1800799021)(921017)(38350700011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DfZXvjiN+W9DVdDBi+2dlVt4L+Ld/jdJKFG7f4xMFuomXYcKoTFZpYW/0rmjP+iOzR2hfONjmLQ1bbLt/zFgM1gvA7lkYbIYYDOcnIH/m2L9IuhK+arrwbIvdipF0mO/ns+5giwGIYzymrxklaBwRakHSfKkIPj6ara7Nn58JnGue9cla7Cle8O4qcYrIIMz2WEo01M/3xS1i4a/wvzB2V7QxNVPoBHOdV8PFP5wfWyswWLUaR00C3mD4MbCPyPRKU/Pe9VUoh9W8RwFjWG2k1r4qqMG78E3hjc6t12eiPGv1cJfRYV71jqnqLjGK/I0p+EHrThMmK2OKWI6BHeyspHM//qIEtv6viZmQvMlhfOEoghInigkxGD6AiDBvIjf0xg02rQeX5Dc5JTgsQnl2/XfsOZPI/7N0AUCaRk9K3uTJzGzkjDlG0VYgzAmv8PBTFjvq+XIxepjgIFMmtslah8hUu3RjYGlITFDj6lvhnSAtpQKJ/QTH9YeE4aAnyf0UTS7k3STlwGHUAF/wEhBAnNNwJ2o4RDyPmt6vDVspMggwdW+pfG6CEEjx4FM20Hb4I/8wA7VIyNdbPEx5O5boFItKrHQQNTvRnibZADVlzqS6t3mSEp5XctXnO95t5WouR19ggdmJH2uH/Jvwodqjvsh5JpE0I4EYF+rOsimhY8W8dPwowds6hIBRVKIGwOtyN2PdOgpw5OspFlz+nu8N0ltETOIJ7Zj3d0uOpq+HX9UOc1/cuJOxKpa/31eC57S0HfnMxkJyXOVdIW7Jqoxf/5tAy6IlJICxURE0ham0GS4e81/Kmp6RCT5P+QLOsu/XO2v78NPDUtH0zqMUWMAPpAUqXs8w6+RHZyj6avpBAxlstDHLgEHpodwWTynqtNT3y5QiWRqL0P6XzSPsCBHzim3TNLRgSUsVRqWD1j3QD9Vprl1G7pujD1QqaEWY7uOSZiLgScSHfNtB91W/MjEcCRhtc99bJiyA+iF7ew4f4pvl87DLD1ojdHFbqEiMA1Wh83kXOFmqLdKJaiJSAeR3kG9ZVrDuPbFTTDTpalbMhujuL7GWPb/TuCtlfnDwQutc8NASSIyIpFaVSCT7OvzDPL1/0k2zVDED6wY6plfXruo2bRRH8FFRYTnCSkgAVT29pYfII/t3nFsZ341UGKYZV6e+Ud+40S+PeXCMLfDrp4bKv4ibF5P6Te4RHmxLCQ4VhtKZt6DJhs9FUhtvCC6poTIqfT5zo6F+bq77B8ou4P/qvRx8sdM2UBY9G0Kg+G/XXY9F0rx2oNZDr13tSB6SD8mNeI85Ig5tNd5X6G58xafHEvVlGCywaU3r2oi9ZQq2Nif5BYvJ3fQDElGCUDGP9h9+i5PTm+Su58tM4DSC0rU2+OY6uwaqcd1zSieusJX+KjAbUlGhvGjS1Qxy90/PLH5uRcLRkdgt2Rq2HLpJ4/2VYjwvx0sZ7g09JdbRL3phsk9EN2Vobpd5ldYANQ+IEoE0awzr7x8LFOLAiotisQ8SK7v1gxPHDoaty+Htz3lHMEypFR8a6JfsYBTXxHCrATsxlh4Xr/S0/QAJF+XKhj5Flj7lFRBrQ1SZaevxWmW X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1adeaefc-bfd8-410f-8fe0-08dc94b92412 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB7065.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2024 01:50:07.9697 (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: 9svq1uYBDFLJric7p2ig4j8scoSt0XYs7fdbowTj5dSy+0Wq9HHx1wDU6tV8c9qv0zTECRkaSdUipPpUCdvuEw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8965 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240624_185009_495865_78D739E2 X-CRM114-Status: GOOD ( 17.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org IMX93_CLK_END was previously defined in imx93-clock.h to indicate the number of clocks, but it is not part of the ABI, so it should be dropped. Now, the driver gets the number of clks by querying the maximum index in the clk array. Due to the discontinuity in the definition of clk index, with some gaps present, the total count cannot be obtained by summing the array size. Signed-off-by: Pengfei Li Reviewed-by: Peng Fan --- drivers/clk/imx/clk-imx93.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/clk/imx/clk-imx93.c b/drivers/clk/imx/clk-imx93.c index c6a9bc8ecc1f..68c929512e16 100644 --- a/drivers/clk/imx/clk-imx93.c +++ b/drivers/clk/imx/clk-imx93.c @@ -257,6 +257,20 @@ static const struct imx93_clk_ccgr { static struct clk_hw_onecell_data *clk_hw_data; static struct clk_hw **clks; +static int imx_clks_get_num(void) +{ + u32 val = 0; + int i; + + for (i = 0; i < ARRAY_SIZE(root_array); i++) + val = max_t(u32, val, root_array[i].clk); + + for (i = 0; i < ARRAY_SIZE(ccgr_array); i++) + val = max_t(u32, val, ccgr_array[i].clk); + + return val + 1; +} + static int imx93_clocks_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -264,14 +278,17 @@ static int imx93_clocks_probe(struct platform_device *pdev) const struct imx93_clk_root *root; const struct imx93_clk_ccgr *ccgr; void __iomem *base, *anatop_base; + int clks_num; int i, ret; + clks_num = imx_clks_get_num(); + clk_hw_data = devm_kzalloc(dev, struct_size(clk_hw_data, hws, - IMX93_CLK_END), GFP_KERNEL); + clks_num), GFP_KERNEL); if (!clk_hw_data) return -ENOMEM; - clk_hw_data->num = IMX93_CLK_END; + clk_hw_data->num = clks_num; clks = clk_hw_data->hws; clks[IMX93_CLK_DUMMY] = imx_clk_hw_fixed("dummy", 0); @@ -335,7 +352,7 @@ static int imx93_clocks_probe(struct platform_device *pdev) clks[IMX93_CLK_ARM_PLL]->clk, clks[IMX93_CLK_A55_GATE]->clk); - imx_check_clk_hws(clks, IMX93_CLK_END); + imx_check_clk_hws(clks, clks_num); ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_hw_data); if (ret < 0) { @@ -348,7 +365,7 @@ static int imx93_clocks_probe(struct platform_device *pdev) return 0; unregister_hws: - imx_unregister_hw_clocks(clks, IMX93_CLK_END); + imx_unregister_hw_clocks(clks, clks_num); return ret; }