From patchwork Fri Aug 17 09:47:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Genoud X-Patchwork-Id: 1338211 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 5A457DF266 for ; Fri, 17 Aug 2012 09:50:08 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T2J9e-0008Qm-Pb; Fri, 17 Aug 2012 09:47:47 +0000 Received: from mail-wg0-f49.google.com ([74.125.82.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1T2J9b-0008Ph-DY for linux-arm-kernel@lists.infradead.org; Fri, 17 Aug 2012 09:47:44 +0000 Received: by wgbez12 with SMTP id ez12so2320639wgb.18 for ; Fri, 17 Aug 2012 02:47:41 -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:x-mailer; bh=IBiacsbNxiO+gFSUWtkuxbOExhlqK8wrVRjbk6sElF4=; b=qKDAJfbB313V9HItxILvAXr2wdGmtVxLoj6aby9rbN+To8OBzpIzzpOF2glemba2eP flluJoj2Rz4fbGfHuE0vmED6USmiF1nUHjwKORnq4rKCxytbVTGwuw5gsCR23Yv0J9on vZF760dQ5L6LTbqZigODobMkMfO70J0Nwe1sCInsUNN0t9xMkSRFTH29uMhEcDQt4cYx jjFD+7gChJBOcEVt8CAt7bybkqJTGKovjKHAzdFRuEvyU1I97Nn3rMubjy47Qd105cGY Z9IThfrv9HddHWv09o0NOriRQNpnX6ncuIXUmaxz70LGWmGLi2DDIaMtUmA9YehEz8BB OBCA== Received: by 10.216.41.195 with SMTP id h45mr2374868web.74.1345196861594; Fri, 17 Aug 2012 02:47:41 -0700 (PDT) Received: from localhost.localdomain (lyon.paratronic.fr. [213.41.177.106]) by mx.google.com with ESMTPS id el6sm8810683wib.8.2012.08.17.02.47.40 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 17 Aug 2012 02:47:41 -0700 (PDT) From: Richard Genoud To: Russell King Subject: [PATCH] BUG: clk_find() misses some clocks Date: Fri, 17 Aug 2012 11:47:23 +0200 Message-Id: <1345196843-23059-1-git-send-email-richard.genoud@gmail.com> X-Mailer: git-send-email 1.7.2.5 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (richard.genoud[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Richard Genoud , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org if a clock is declared like that: CLKDEV_CON_DEV_ID("pioA", "fffff400.gpio", &pioAB_clk) (so, dev_id AND con_id are defined) and the driver looks for a dev_id (but no specific con_id) like that: clock = clk_get(&pdev->dev, NULL); The clock won't be found: if (dev_id) best_possible += 2; /* dev_id != NULL */ if (con_id) best_possible += 1; /* con_id == NULL */ /* => so best possible == 2 */ list_for_each_entry(p, &clocks, node) { match = 0; /* * checking p->dev_id = "fffff400.gpio" and p->con_id = "pioA" * against dev_id = "fffff400.gpio" and con_id = NULL */ if (p->dev_id) { /* ok, p->dev_id exists */ /* and, we are lucky, there's a match ! \o/ */ if (!dev_id || strcmp(p->dev_id, dev_id)) continue; match += 2; } /* so we have match == 2 */ if (p->con_id) { /* p->con_id is not null */ if (!con_id || strcmp(p->con_id, con_id)) /* * too bad !! con_id is null ! * even if we have best_possible == match * our clock won't be selected */ continue; match += 1; } if (match > best_found) { cl = p; if (match != best_possible) best_found = match; else break; } } Signed-off-by: Richard Genoud --- drivers/clk/clkdev.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index d423c9b..e28b120 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -114,13 +114,13 @@ static struct clk_lookup *clk_find(const char *dev_id, const char *con_id) list_for_each_entry(p, &clocks, node) { match = 0; - if (p->dev_id) { - if (!dev_id || strcmp(p->dev_id, dev_id)) + if (p->dev_id && dev_id) { + if (strcmp(p->dev_id, dev_id)) continue; match += 2; } - if (p->con_id) { - if (!con_id || strcmp(p->con_id, con_id)) + if (p->con_id && con_id) { + if (strcmp(p->con_id, con_id)) continue; match += 1; }