Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422731AbbFEQdN (ORCPT ); Fri, 5 Jun 2015 12:33:13 -0400 Received: from mail-bn1on0055.outbound.protection.outlook.com ([157.56.110.55]:54752 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1422686AbbFEQdF (ORCPT ); Fri, 5 Jun 2015 12:33:05 -0400 Authentication-Results: spf=fail (sender IP is 66.35.236.227) smtp.mailfrom=opensource.altera.com; vger.kernel.org; dkim=none (message not signed) header.d=none; Authentication-Results: codeaurora.org; dkim=none (message not signed) header.d=none; From: To: , CC: , , , Dinh Nguyen Subject: [PATCHv3 1/2] clk: of: helper for filling parent clock array and return num of parents Date: Fri, 5 Jun 2015 11:26:13 -0500 Message-ID: <1433521574-31052-2-git-send-email-dinguyen@opensource.altera.com> X-Mailer: git-send-email 2.2.1 In-Reply-To: <1433521574-31052-1-git-send-email-dinguyen@opensource.altera.com> References: <1433521574-31052-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: CY1PR22CA0016.namprd22.prod.outlook.com (25.162.32.154) To BN3PR03MB1367.namprd03.prod.outlook.com (25.163.34.153) X-Microsoft-Exchange-Diagnostics-untrusted: 1;BN3PR03MB1367;2:WVRATerNAHR0KzaXN8M8XiD+lIYh1L3J5v8ejChzcvVKH9//+zhP016kcinW6Ggs;2:nmBj6w415GI2WaN7YaELZ11N0jiZcZKU2x/h6zi1/TPPw+UWRXgQQfqjTnzWh/taa1EHXfStvEnMB+peu/ao+lxmmG+1MfJVxkpIIZgTR1TdkcbgAuffIpbgs5H1uR1KLEIolhLbgb0w+CapB07StA==;6:jgrL+54J6B/hWMLhQTcjpHzgRLI3l/2VDjEvWocDFGPPZ/Mw005AcnYSsRzqKCOxHsp3clLr247lZcW4igkTvE9xaRSzBuFQJroQvEyXUVdQlmZsqMq9NLBBNVm/vOHxljZ03eK8xmwjeAmVHybmcA==;3:JxusYdTFmylA31sJJq4LHF/rtdYjYC26K1ugcQqxItNYKyOsIWo1lbbukdoCIePxWYF/OwsOEIjY3ISwCuYGtvlukfLRhYsW4bT0j3kdLrbEum7++mj/c+/DLcWa5A81r1xdJlxQdX56f+/pVn3pL0aTaKRYiT01eOJtOvqeu0Z/9UQ2iG8Y2yBQhTN7doiwTJcmhachZa/faLjbyTHiVzf8+OxoIdDWFSNmUVtiroZgw0dYKGWeJBfJ6JqVTB6cW37JmrBISPP3K/ObEeBDoo/lDjfNKj+24Wq1MS15cE/zrp6oGqK0z75D1LgAsS7T X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1367;UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1429;UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB297;UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB026; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:;UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(520003)(5005006)(3002001);SRVR:BN3PR03MB1367;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1367;BCL:0;PCL:0;RULEID:(601004)(5005006)(520003)(3002001);SRVR:BY2PR03MB297;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB297; X-Forefront-PRVS: 05986C03E0 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM;SFS:(10009020)(6009001)(86152002)(229853001)(46102003)(92566002)(48376002)(47776003)(66066001)(40100003)(122386002)(33646002)(77096005)(2950100001)(87976001)(86362001)(107886002)(5001960100002)(53416004)(189998001)(50226001)(5001770100001)(76176999)(62966003)(50466002)(42186005)(19580405001)(19580395003)(50986999)(77156002)(4001430100001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR03MB1367;H:linux-builds1.altera.com;FPR:;S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oPnU0EdKzIHLzf4jt1MYhGxdimsNMwyW24kogRR2bw==;10:SwPeF/i7mIBMGWcT92HOthvPHc/oD1UToMeQ3sCl/nrKp0cP6k/K0KcMPbPGpecaP86wPgCjx3isiUf7qSjZ7Y5qAPH/oGrUjrUi5m2Yb+M=;6:71fxXAQ9qPlz09LyjPTpxQDGm7TMB0wezHQf98hM8PaIqMXqoeAgFGYwk6bUNZGgt+FAkEusFYw6ViniUxx0sRlpB6TjTbjkNMwJvopOd6BOXLokmv+8uDGdVUWAGaBcjrTP7ldKFbx1X5QDtQROAA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB1367 X-Microsoft-Exchange-Diagnostics-untrusted: 1;BN3PR03MB1429;2:BdS/6/dzM9m6L9Rv8+FNIpeC/EZ6iHkEedHwhSvY5kIPDAqgQ4b+KYzzq5Fy9qG/;2:CgQdktIN8Vuihqj3CufaA78Za/J4jEIh92s7pl5+BqodmGp8L6YGZNBo/dSPqQbz1EBKGOAK42vumnyny3QbDE8KPFLvlfXE3Xf+McnZ32g7sCOAmFUN0imxe/bCDkr0kN43iPO7Cy0QChZuO7XKFg==;9:mN3919L+sCGdmRfcpbCo8C9ySaqWjEDo+Ojbrp2kBJODLd0in7tG8zodKQa07+gNDmvHSyCuRO0hTDaxIKqOWiwEF4PpxkgFfreOwoR3LyW79Aeww6dR7XNQ/Qg2TUYHt49wutdb0BUFVFA3kxXqIA== X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: BN1AFFO11FD028.protection.gbl X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD028;1:pbDze9VZOwhHpmbosThvfjhZWd5An5elHFBHht9jgFZD+0G0LU6kt98QFgixz/bfHXRQJTm2WpRaPFujdc7E6MQQMabDO8H3Wq7/whJhREA5TPxvgrlqgewlEzFdVtOgIZL78o8HDjfDnBwJm/X16pN8T6kV94R6ePWBvfwKFF7D44NSnI6YAs/sybBRWXXfupPzJDtha3FaVXLr30gwTOhfLDaHHV5A+1KqDw8tHTNYDvKNsg+dxZq4bViRt1sMSjISACxgVd4nssn9DV+DGHpP4llfwZavL9rfznz8Srd6ereJfOcjgbNcasn6WfP4bUR6uY7C8ypPQ6lS6tAWvQ== X-Forefront-Antispam-Report: CIP:66.35.236.227;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(339900001)(199003)(189002)(2950100001)(189998001)(77096005)(66066001)(86362001)(5001770100001)(86152002)(19580395003)(5001960100002)(107886002)(87936001)(6806004)(47776003)(33646002)(105606002)(106466001)(229853001)(53416004)(76176999)(50986999)(85426001)(46102003)(92566002)(77156002)(19580405001)(62966003)(40100003)(122386002)(50226001)(50466002)(48376002)(7099028)(4001430100001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR03MB297;H:sj-itexedge03.altera.priv.altera.com;FPR:;SPF:Fail;MLV:ovrnspm;A:0;MX:1;PTR:InfoDomainNonexistent;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB297;2:m+fZrBseW6kJDBiHDcFjrMd/VkQwQJTWHGMwp4Vs9C1bapOU3Umzy9Hd8NOk2f7c;2:4UgnISchkRsH+/fcEthUvJyTYtoVOA/JWPd2weotv6heO6gL/iMRCUF9DPp5vWSr6MloutuFG8u0ZMPT9PcYvL9uQMvSfPM8SHWxKPvBH5fJOzJRWrG3a/nyAd5gGZ8ie7O2YKD4XITkdzgunZuzsWwrP3yGfyfYLgPWtOtbzX8saxlQX4jvkILRVNOA3gyiJm5id7RCjlaTMnTmvPfr51fCa6FILtDgbJzS/CtMrYo=;6:Lj/gcJcQM1BfjNbuRCnrNnJEaOQGhaLiT6oTojjV0xNWjfweYQPpd31a4w5odU0Gp/5slsFXwx47Fkp3ic5YhC0Bw/jXt8MdLlIlz25H2/peiO+QkDWDwBEnp2iqTZ454zWA2JjbpVC9BgNqQKig8Q==;3:qI+R+mRUUN38NBaNxfn6A7GkcajepEDczaxJIGIJ2pcj+fv39bauYFY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ceeMZwZfGdrRKmJxndylcR1dO2aWP1THWp/dmSm2D3hX/Rb?= =?us-ascii?Q?7uV/Epdtn0NcBgpI/vJr1GH2rLZsm12Gz/qBivCLSrWLD4pmdLGQexbgCIPw?= =?us-ascii?Q?8kfieManzB16013sNJLd6kE74IAE8vhAymhBelii2vI5LfYUYoaftITXs75j?= =?us-ascii?Q?j4JwGL/kfPCzh0bLDu+xQ870x3kmLJj7BGkjcrrWRcAdhCWEf7GyZ79u+mdz?= =?us-ascii?Q?r1Z7YH7vf7iO1Zl/1EEIhGqkTuoU7kjrp2x4t0/H80ASAs73Ch+5bn2+cr+y?= =?us-ascii?Q?2j6hJV6iNkr1AidAI5aiyKny4N/++8vJGZLDW3B//nyn/cdlU3DgBUImA6T/?= =?us-ascii?Q?ru8xZSSAoSqJgORiiQjNdlqLU2mUE7TjkXnMWNPHH1bOZO+neUFaVBjH5wpY?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB297;3:/f/3efShrfDCyjxCPNOrgjA1H0tzNn7VK29YoAoKxqBTEWSueD1wqm8nM1jj8k6dlbftxluFqbDiAje2YPfpTmva3IkM1BV+p2E7YApJLfPFcU2wyJGH5zOO046CEvi3G+uG2KYzVSbVMItqvZXiSw==;10:yIY+21mbciBLMlEyLg19tZuV1vF6k46rtf4ivnLQ0EO8m5XCxixp8xiAfAlsZAAM0EUcJaA3fvYhjrrKXvguuddwgMvBoLp40decUDR/fRo=;6:xZry8BaiXA9esYrC4VqJEcg+l6gKsd7FHQ1ydMu44H0NZLlBhq50WeeDlPL5iK0MjUBs7vZUYgyp1b4Cw19GCJpYWDukKskzd26rS5qSo1x41F3QZD96vyFMNZiA3ZrIjmhnoaK7sf4CxRjccYw4JA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2015 16:32:56.6160 (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.227];Helo=[sj-itexedge03.altera.priv.altera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB297 X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB026;2:eWy+MnQXbpVSAnkcBK1SAqYVL96Had/K+6JOlo4R4HPcuRMoWhg+t7QO0dVdBxqy;2:FC1t0UOZUgbDCU1OIOrHlqvKELUHFpoHihNcI+ronf3k8SL0pIgS1wKqGbXbJOX+9k5TkFp+wUu4huRNQ4sMFEuEyetNd/su2z8qc02dev2hi5mE+hC4/yv2fzwijaBRFnIkuJBYg8HQc7ardT3WPa2p3LQeU50b8r7rnxtCH8oRJaeOVdKUPtoV3OjFMePhOVnVdgECIOXhbTVZOaMKi/Is2WztF/qwrC+y9ZEWoME=;9:WaKeHrWOstdtLbNa+aAjO3NPlZDWPfpLtGl/yWolMaT+m3qGW5EAlG31JLV8wa/mWrRO0JbmQAcMXMGIIXfeNTvPGl8jYR2NqNI7nF3ganhomoJEfQAUW90gi/KK1bx3KwEO8APMRgf3OD+Bh/1ODg== X-OriginatorOrg: opensource.altera.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2562 Lines: 72 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 --- v3: shorten and clean up function comment, use EXPORT_SYMBOL_GPL v2: use unsigned int for size --- 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..5130622 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(): Fill @parents with names of @np's parents and return + * number of parents. + * @np: Device node pointer associated with clock provider + * @parents: pointer to char array that hold the parents' 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, unsigned int size) +{ + unsigned int i = 0; + + while (i < size && (parents[i] = of_clk_get_parent_name(np, i)) != NULL) + i++; + + return i; +} +EXPORT_SYMBOL_GPL(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..3ab66d3 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, unsigned 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/