From patchwork Sun Sep 29 00:37:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 2959631 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 878D89F244 for ; Sun, 29 Sep 2013 00:40:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C253620237 for ; Sun, 29 Sep 2013 00:40:44 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D818C20221 for ; Sun, 29 Sep 2013 00:40:43 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VQ53I-00088A-Lt; Sun, 29 Sep 2013 00:40:01 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VQ533-0005O0-FY; Sun, 29 Sep 2013 00:39:45 +0000 Received: from mail-ea0-x231.google.com ([2a00:1450:4013:c01::231]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VQ52g-0005Lv-F3 for linux-arm-kernel@lists.infradead.org; Sun, 29 Sep 2013 00:39:23 +0000 Received: by mail-ea0-f177.google.com with SMTP id f15so1897549eak.22 for ; Sat, 28 Sep 2013 17:39:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SOPOaZT9kg1XiMWQLL5DVRSR/zu4aA5r4yUJYZIVzXQ=; b=pVNivVP9zu3FnwBSGSaRThySANPcU8BgzZi7IS9A7YuKq549NgqkSJRHHyHVo1J2JT po2O6RQ12RXL0IdfDxx7WnT9osH/E9LcCyeXo+IvlhLQF4wIPfXbNXQsAcELpmyWxLPb 8U8gCTVXopCrw4b6ZBxbGqrzoW+AS2TcTyVTbZbBymXCsOG5lzRAlJkk+WOzt48jfiQD OR1hdpXf/RAyjfbtw3TcV3r/uLETfNQ6liDqSSK56DAH4FTJY+NtWrfbIaHlSswT6MuV Pw1VM06GCb//qOJF2XgCR5bUfsjs1sJIz5sJkvjpuLnM+ROHQwvhIPeIQkkx3lJq5gcw D3Uw== X-Received: by 10.14.9.72 with SMTP id 48mr23457835ees.42.1380415140669; Sat, 28 Sep 2013 17:39:00 -0700 (PDT) Received: from flatron.tomeq (87-207-52-162.dynamic.chello.pl. [87.207.52.162]) by mx.google.com with ESMTPSA id v8sm33364506eeo.12.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 28 Sep 2013 17:39:00 -0700 (PDT) From: Tomasz Figa To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/3] clk: Correct lookup logic in clk_fetch_parent_index() Date: Sun, 29 Sep 2013 02:37:16 +0200 Message-Id: <1380415036-15997-3-git-send-email-tomasz.figa@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1380415036-15997-1-git-send-email-tomasz.figa@gmail.com> References: <1380415036-15997-1-git-send-email-tomasz.figa@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130928_203922_657769_0D40E9DB X-CRM114-Status: GOOD ( 12.04 ) X-Spam-Score: -2.0 (--) Cc: Sylwester Nawrocki , Mike Turquette , linux-kernel@vger.kernel.org, Tomasz Figa X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This function is supposed to iterate over all parents of given child clock to find the index of given parent clock in its parent list, using parent cache if possible and falling back to string compare otherwise. However currently the logic falls back to string compare in every iteration in which clock cache entry does not match given parent, due to wrong check conditions. This patch corrects the logic to continue the loop if parent cache entry is present and does not match requested parent clock. In addition, redundant checks for parent cache array presence are removed, because it is always allocated in the beginning of the function. Signed-off-by: Tomasz Figa --- drivers/clk/clk.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 63f9ac1..32e2fed 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1097,11 +1097,14 @@ static int clk_fetch_parent_index(struct clk *clk, struct clk *parent) * them now to avoid future calls to __clk_lookup. */ for (i = 0; i < clk->num_parents; i++) { - if (clk->parents && clk->parents[i] == parent) + if (clk->parents[i] == parent) return i; - else if (!strcmp(clk->parent_names[i], parent->name)) { - if (clk->parents) - clk->parents[i] = __clk_lookup(parent->name); + + if (clk->parents[i]) + continue; + + if (!strcmp(clk->parent_names[i], parent->name)) { + clk->parents[i] = __clk_lookup(parent->name); return i; } }