Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932210AbbFAVwo (ORCPT ); Mon, 1 Jun 2015 17:52:44 -0400 Received: from mail-by2on0086.outbound.protection.outlook.com ([207.46.100.86]:8421 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932151AbbFAVwZ (ORCPT ); Mon, 1 Jun 2015 17:52:25 -0400 Authentication-Results: spf=fail (sender IP is 66.35.236.236) smtp.mailfrom=opensource.altera.com; codeaurora.org; dkim=none (message not signed) header.d=none; Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=dinguyen@opensource.altera.com; From: To: , CC: , , , Dinh Nguyen Subject: [RFC/PATCHv1 1/2] clk: of: helper for filling parent clock array and return num of parents Date: Mon, 1 Jun 2015 16:46:25 -0500 Message-ID: <1433195186-14867-2-git-send-email-dinguyen@opensource.altera.com> X-Mailer: git-send-email 2.2.1 In-Reply-To: <1433195186-14867-1-git-send-email-dinguyen@opensource.altera.com> References: <1433195186-14867-1-git-send-email-dinguyen@opensource.altera.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [64.129.157.38] X-ClientProxiedBy: BY1PR0501CA0006.namprd05.prod.outlook.com (25.162.139.16) To CY1PR03MB1373.namprd03.prod.outlook.com (25.163.16.27) X-Microsoft-Exchange-Diagnostics-untrusted: 1;CY1PR03MB1373;2:vJU0bGObGMbmyBUkHdIkfCQYC3ObuqnSLpVFPF37sZqpES0fOeUNH0mOydiBUS4Y;2:SRSyGviaei5OVwiE6RgX3+L7t/1lxyOAz6tvGUo6s+0KNn0gb08TY1MaGJQVFyG3kbq/JSgRpm1TvBCKcBOFC1bjycrVhYjh/nMdNUlmabABfKV/8XDubqPjat6tr0p0js1Fb9699xiKIGxdlRmhPQ==;6:LmN9A3BJXzjYxYyNmihEfhC9h96NIn+XaHRGZD3JxoJUMlHWqobOllaOHlWYnsC3B6YkJLhzgdt+Ugg0/SiEw4IRzwP5Iv5Bo+v0Yl3cyt9p3bsD0bbf8m+5OkK1xjAhit0aqkwG9yJr4iV+B5Lreg==;3:initVRlGMTjsZ5OE6uRD9MFzhRPzyTLDsttmeSvew0GTT8+ilPrtsZfyJ8YOxfkrLwQOk9trxYqI6U3SwraLx+ZjFGWfs+OZqmkrB9THQUOwsLJin5znRVHe/dxzU8nsyBIqcoDdPr15UJC/oI2YI0N2quRN4+P2/XNiXj/wyNKErTSOfY8v/ME709u0SaSDsLRnXdPDoGxUyTqgLZ406b6O5Yy3heYg2xdubBvBozPdlnJ0CdLkDDmSC/DxUat0YxahgihkV1ZatMi1GFcvxL++0yn9hWYCrS3L/bVAoc0dZilV26kA9+Qk1ne9Dsc6 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB1373;UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB128; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:;UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(520003)(3002001);SRVR:CY1PR03MB1373;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB1373;BCL:0;PCL:0;RULEID:(601004)(520003)(5005006)(3002001);SRVR:BY2PR03MB128;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB128; X-Forefront-PRVS: 05947791E4 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM;SFS:(10009020)(6009001)(189002)(199003)(86152002)(19580405001)(105586002)(106356001)(86362001)(68736005)(47776003)(92566002)(48376002)(77096005)(64706001)(62966003)(5001830100001)(5001860100001)(2950100001)(107886002)(50226001)(5001960100002)(77156002)(189998001)(53416004)(46102003)(97736004)(50466002)(50986999)(5001770100001)(122386002)(81156007)(40100003)(229853001)(76176999)(66066001)(4001540100001)(19580395003)(42186005)(87976001)(101416001)(33646002)(69596002)(4001430100001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR03MB1373;H:linux-builds1.altera.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:0;LANG:en; X-Microsoft-Exchange-Diagnostics-untrusted: =?us-ascii?Q?1;CY1PR03MB1373;9:W73qJnXy6LZDxzUz6F/sBMX6vuUgBPeiDs/TIIgatI?= =?us-ascii?Q?fgxG+DiI9LV02K0cgVzJmv9BNBL2MLs4HAH3aQdWdqU+l10/bAQmy6xpy42E?= =?us-ascii?Q?W4SRtvlQ/nSQMJ9A6855zrrbRtJugFZ0QBW2di0+uLi5LYnQfKD4RkG7KJds?= =?us-ascii?Q?URQ3Q7TKhPNYva7WEoQSPN4fOJlIE1TRTT1wuAxE0EFAZgG7szO3PtUbrP3T?= =?us-ascii?Q?k2p/VBtlbpp/+Uj7LKH5w3Fq1btp17Arm3ayZt13EBZ8tDJaAk8Qun2Wz5E1?= =?us-ascii?Q?sTlaqRD9hNiNTf3EeCadCenwVszQpSijTDMKr8m7n4+tLn2FZk2SueJdT6q0?= =?us-ascii?Q?DWxnRbweJqHSUtkJd5cR2FjPtJE5YgVR4boH19HUFR3c9SPw9dnO6y+Kl58G?= =?us-ascii?Q?C7KnkuHYSFZUt67P6xrGMcTydt7D7RLzktgzTsnj7Fq2CFPT01bV+/R43phn?= =?us-ascii?Q?kDsyBmEQdW+t8TBUMVALz9SHBBpLREIYBuYwOTRRbjLUD8EmDULKqrcgEtUi?= =?us-ascii?Q?O0/78Y3vWu4VTzQ4NKOXVj18vzk/bCNer4m/veoD5O98zyIY7+jowMluznNw?= =?us-ascii?Q?SJS5PLXPVoKYfWU3noiu5h9OCSuwYy2vLsJ47Q28yW6BDcBBQGDFc72YbJI4?= =?us-ascii?Q?PPtUNwcqKDmvBrXoIQmwp06SU6N/2oDLPfpCga/2S2D1MNXhiUIJfPZNFfbW?= =?us-ascii?Q?49GkuCCqv4PXBqeEC53+tdpJOo3M/0lWS76l5PmQV2WPPctpJbIl0w9wopcC?= =?us-ascii?Q?AVe68U2D2cPKJRklujqH8wrX5KUS9f+14CapGi3h7RZl1dX5efPVtgi+02/m?= =?us-ascii?Q?hn2Xjs2UpcbzOz6DHtZLg9nx+Y4XwGTvWcc6ApxyziC3yM+NOf+x+jw0cN8D?= =?us-ascii?Q?kvtv0Far4j+HnKt94agAAUuA0nDjbgmchp4XsNyNI0xrS82fKuSwcWyL7GGY?= =?us-ascii?Q?FyGObnCnhL+IDpti4lmGpjB4CRtvb0/b71QenVHTGkMKJ2sroKOI9coRco6u?= =?us-ascii?Q?wtWTr+j/zBIBoixQ8+Abkx4FUPDMCQ4ctZhs4GlyxjUxxaLSWfqH2UHx6BGC?= =?us-ascii?Q?c8UuusDx58IPUSxkW7GlSdnTfqXADHV//KDA8bmWGEUEB6NoOUyxNLEQTYcr?= =?us-ascii?Q?jAGcaAAnQsAyQIXsUjAgVpvt9TGkF3?= X-Microsoft-Exchange-Diagnostics-untrusted: 1;CY1PR03MB1373;3:FdrLlleoVpwn6BlW3DAk2gVIjcdnx8zJ6+2CfNxYyt9xtuQmNqOx8RJsxzupsoIxh1j6fSkXCk6gQPFWFHVv8MDvIyiGXxMs9ywG5ILhOcc7cWzBLWEnWEWsHnm0s9Uk619v8IgxHQkNWN4XUyXjkQ==;10:q50YYzTkoeAL/p7UabAwbAVgiAQRythgIgZIVwKPq4nVJ+mwQOPZ1VlOWT/AhavcUliJqaEU9HqPTDXQ8t6c/Bo4Jo6RpKLgKbpEPSVcTRU=;6:mEGKEKRJbU9V4aH82ALsjxxYt8B9eTc80XuZeKCnzSTFGayRAAORjcN3G33J38evwrlOOL46KyjZ1UUEHgVU5/DcIC/CwZ3yj5OVuHybRa7GLpjuEoqR+ozKf5q5/qRVy/0fWb36fxRGzjYWQurEOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR03MB1373 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: BY2FFO11FD029.protection.gbl X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD029;1:KtwV0v40iPTc6kS48YI3srEWVmfXUp1UOzrfC6hpF5vJzlftMvBxlz+oPuCS+LyKfSrpbMfIwAgcRafsrgdbLuJtVY6yHWLRP8W8T7DRBa6s4gi3UPUHQMNcRmv+7zJq2/MZltbcjP4bTaAyBfv5eor0usANY2myOiZw5bfYD5VH+spu+JvOLEVeviH/QsJNFwuNZQ8J7GGKL7uNWt/I4mT5CbPEJ2Dsv2Hy4SMfrDAbsBg4Ed65AVBCEYCRSWgWPptGJI+x0Et7x6ujm2WNeXgDR8sz1eC0/q0hZMidZGs= X-Forefront-Antispam-Report: CIP:66.35.236.236;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(339900001)(189002)(199003)(16796002)(86362001)(77156002)(62966003)(122386002)(40100003)(86152002)(50986999)(76176999)(19580405001)(19580395003)(85426001)(47776003)(66066001)(64706001)(48376002)(50466002)(6806004)(87936001)(229853001)(105606002)(33646002)(46102003)(106466001)(4001540100001)(81156007)(97736004)(5001830100001)(5001770100001)(6070500001)(92566002)(2950100001)(5001960100002)(107886002)(5001920100001)(189998001)(68736005)(5001860100001)(77096005)(53416004)(50226001)(7099028)(4001430100001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR03MB128;H:sj-itexedge04.altera.priv.altera.com;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:0;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB128;2:hapdYmHpablenowyyGl1fY0rvgZr7j1lf5EzJFtuJftAy89aJgCvnNsGOxjGnYyJ;2:jCKZrnYvYR8Wtx39Jt10bAWylWZ/Ugipyni8D98BK0Q3RaO5Umz4m6DtxopHu49RCPTtaWOpbVADjet//oNsR3vJfczMyeyIcRzDsJFcTTaibpFTz8zBPjpU3RBWMgY/eh9/vLTAkht2mOMBPy5G5+VRmBKbXl+yR9Yv5prjjinJLsULPPj94GrQ3NkCuz4SaGvqG4CvZfGtnLSMHv/uzCx3FBluLjhR02gZx7ZIe2g=;6:ECq3ZkMdUXOL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aMFi6fJpoe8xzDzFhE5oKkfiFZkurQkJMfeys9rEB2q89LY+G552AfxrcEI8qtJF7eIIL6xd3V/6wb+EevW0qhAh6R0uZ7pUVho0UsaC/am9s89QKdQ==;10:87Xmv1mGtFeYpN5L9KKLPt+zaWag8qbbgs8HotH8DSxLN90J5hzWY7F+NU/0Xfn5F3ohTGRKlry2QHZIsn1Ue4FQKhiYaRd/OoH/p/n3mPU=;6:Z/VGIZRHUkEyLByOKsiKNg3O4hbV/32Iihe2k0qAVU0zY8RWBxLA1eB09dPi7I3KCOENHIzwb9jVnhz+LoUhkGrUVOklFMBK3FDvyNaD8USYe0KZ1qyVeCFGbvbjEgrBeqvsp0HC5oAaryhrpfDZaA== X-OriginatorOrg: opensource.altera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2015 21:52:20.8590 (UTC) X-MS-Exchange-CrossTenant-Id: fbd72e03-d4a5-4110-adce-614d51f2077a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fbd72e03-d4a5-4110-adce-614d51f2077a;Ip=[66.35.236.236];Helo=[sj-itexedge04.altera.priv.altera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB128 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2464 Lines: 69 From: Dinh Nguyen Sprinkled all through the platform clock drivers are code like this to fill the clock parent array: for (i = 0; i < num_parents; ++i) parent_names[i] = of_clk_get_parent_name(np, i); The of_clk_parent_fill() will do the same as the code above, and while at it, return the number of parents as well since the logic of the function is to the walk the clock node to look for the parent. Signed-off-by: Dinh Nguyen --- drivers/clk/clk.c | 20 ++++++++++++++++++++ include/linux/clk-provider.h | 1 + 2 files changed, 21 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 459ce9d..b75616f 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3060,6 +3060,26 @@ const char *of_clk_get_parent_name(struct device_node *np, int index) } EXPORT_SYMBOL_GPL(of_clk_get_parent_name); +/* + * of_clk_parent_fill(): Helper clock function that will fill the parent + * clock's array and return the number of parents it found. + * @np: Device node pointer associated with clock provider + * @parents: pointer to char array that hold the parent's name + * @size: size of the parents array + * + * Returns number of parents for the clock node. + */ +int of_clk_parent_fill(struct device_node *np, const char **parents, int size) +{ + int i = 0; + + while (i < size && (parents[i] = of_clk_get_parent_name(np, i)) != NULL) + i++; + + return i; +} +EXPORT_SYMBOL(of_clk_parent_fill); + struct clock_provider { of_clk_init_cb_t clk_init_cb; struct device_node *np; diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index df69531..36e56c4 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -624,6 +624,7 @@ struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec, void *data); struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data); int of_clk_get_parent_count(struct device_node *np); +int of_clk_parent_fill(struct device_node *np, const char **parents, int size); const char *of_clk_get_parent_name(struct device_node *np, int index); void of_clk_init(const struct of_device_id *matches); -- 2.2.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/