From patchwork Mon Dec 28 10:10:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 561266 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B2FFB140C14 for ; Mon, 28 Dec 2015 21:12:31 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aDUm7-0005na-Cg; Mon, 28 Dec 2015 10:11:35 +0000 Received: from conuserg012.nifty.com ([202.248.44.38] helo=conuserg012-v.nifty.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aDUlG-00053l-L5 for linux-mtd@lists.infradead.org; Mon, 28 Dec 2015 10:10:44 +0000 Received: from beagle.diag.org (p14090-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.90]) (authenticated) by conuserg012-v.nifty.com with ESMTP id tBSA9vFF010273; Mon, 28 Dec 2015 19:10:11 +0900 X-Nifty-SrcIP: [153.142.97.90] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Subject: [PATCH v2 15/16] clk: simplify clk_fetch_parent_index() function Date: Mon, 28 Dec 2015 19:10:28 +0900 Message-Id: <1451297429-21689-16-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1451297429-21689-1-git-send-email-yamada.masahiro@socionext.com> References: <1451297429-21689-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151228_021043_217671_65C3A05C X-CRM114-Status: GOOD ( 10.56 ) X-Spam-Score: 0.9 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- 2.1 RCVD_IN_MSPIKE_L3 RBL: Low reputation (-3) [202.248.44.38 listed in bl.mailspike.net] 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 RCVD_IN_MSPIKE_BL Mailspike blacklisted X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , Michael Turquette , Stephen Boyd , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The clk_core_get_parent_by_index can be used as a helper function to simplify the implementation of clk_fetch_parent_index(). Signed-off-by: Masahiro Yamada --- Changes in v2: None drivers/clk/clk.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 151cbe8..5b9aec0 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1069,23 +1069,9 @@ static int clk_fetch_parent_index(struct clk_core *core, if (!parent) return -EINVAL; - /* - * find index of new parent clock using cached parent ptrs, - * or if not yet cached, use string name comparison and cache - * them now to avoid future calls to clk_core_lookup. - */ - for (i = 0; i < core->num_parents; i++) { - if (core->parents[i] == parent) - return i; - - if (core->parents[i]) - continue; - - if (!strcmp(core->parent_names[i], parent->name)) { - core->parents[i] = clk_core_lookup(parent->name); + for (i = 0; i < core->num_parents; i++) + if (clk_core_get_parent_by_index(core, i) == parent) return i; - } - } return -EINVAL; }