From patchwork Tue Feb 18 22:31:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 24917 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f200.google.com (mail-ig0-f200.google.com [209.85.213.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CF382202B2 for ; Tue, 18 Feb 2014 22:31:46 +0000 (UTC) Received: by mail-ig0-f200.google.com with SMTP id k19sf21049249igc.3 for ; Tue, 18 Feb 2014 14:31:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=Cwjp2Wu5UIxAbc+0/kZ8fD1CWd1bUp4dNCik5r7AupQ=; b=h8xasRBgIltORIMWB3O4yKqJRGQL72w3mk33TwN/oelSRuvjwSHdamTSYNIcsmIHci 6tA1MWgg2IQH50R16a1SKV81Gt7uoli5wK7DvGXxFfi4Vb3aNMXZYjEgJkF/QJTW6yHs gZ33Uu8F2YKOQ8C4Rjp+iXzU0WKthrFW4UnQdzZkojx720ysCaiOgKF4WszRqCKC2CG7 qNfCQXvQt1ABitjxWqnUo9XpkQBKyF6CQRhoEQdN6+DpbTk5obPrP1im9Z4Z6e+cPA8M PfRxtjmZuSz3eYPB4trCWNtJ8lSnKqZBthU4Jjq/RFTRPmY3xCLnF47psfOhHH+qxEpj aDGA== X-Gm-Message-State: ALoCoQkjuhfSaAXryI9t575XiwFTin0vzArTipJZH7F5gvProc6oTmL2jAAszgRSwFveujM1Unyb X-Received: by 10.183.3.36 with SMTP id bt4mr13730079obd.29.1392762706045; Tue, 18 Feb 2014 14:31:46 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.29.134 with SMTP id b6ls1467228qgb.91.gmail; Tue, 18 Feb 2014 14:31:45 -0800 (PST) X-Received: by 10.221.34.211 with SMTP id st19mr23070254vcb.5.1392762705905; Tue, 18 Feb 2014 14:31:45 -0800 (PST) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id eo4si5944913vdb.108.2014.02.18.14.31.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 14:31:45 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id oy12so13867321veb.23 for ; Tue, 18 Feb 2014 14:31:45 -0800 (PST) X-Received: by 10.220.175.198 with SMTP id bb6mr10963232vcb.31.1392762705810; Tue, 18 Feb 2014 14:31:45 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp251585vcz; Tue, 18 Feb 2014 14:31:44 -0800 (PST) X-Received: by 10.68.125.164 with SMTP id mr4mr35623512pbb.27.1392762699434; Tue, 18 Feb 2014 14:31:39 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oq9si19651498pac.238.2014.02.18.14.31.38; Tue, 18 Feb 2014 14:31:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752697AbaBRWbc (ORCPT + 27 others); Tue, 18 Feb 2014 17:31:32 -0500 Received: from mail-wi0-f181.google.com ([209.85.212.181]:39012 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751774AbaBRWb3 (ORCPT ); Tue, 18 Feb 2014 17:31:29 -0500 Received: by mail-wi0-f181.google.com with SMTP id hi5so4034485wib.2 for ; Tue, 18 Feb 2014 14:31:28 -0800 (PST) X-Received: by 10.180.188.229 with SMTP id gd5mr19976266wic.54.1392762688728; Tue, 18 Feb 2014 14:31:28 -0800 (PST) Received: from trevor.secretlab.ca (host109-153-23-84.range109-153.btcentralplus.com. [109.153.23.84]) by mx.google.com with ESMTPSA id xt1sm48794538wjb.17.2014.02.18.14.31.26 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 14:31:27 -0800 (PST) Received: by trevor.secretlab.ca (Postfix, from userid 1000) id 97520C40935; Tue, 18 Feb 2014 22:31:24 +0000 (GMT) From: Grant Likely To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Kevin Hao , Rob Herring , Sebastian Hesselbarth , Grant Likely Subject: [PATCH 1/4] Revert "of: search the best compatible match first in __of_match_node()" Date: Tue, 18 Feb 2014 22:31:17 +0000 Message-Id: <1392762680-1498-2-git-send-email-grant.likely@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1392762680-1498-1-git-send-email-grant.likely@linaro.org> References: <1392762680-1498-1-git-send-email-grant.likely@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: grant.likely@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Kevin Hao This reverts commit 06b29e76a74b2373e6f8b5a7938b3630b9ae98b2. As pointed out by Grant Likely, we should also take the type and name into account when searching the best compatible match. That means the match with compatible, type and name should be better than the match just with the same compatible string. So revert this and we will implement another method to find the best match entry. Signed-off-by: Kevin Hao Signed-off-by: Grant Likely --- drivers/of/base.c | 43 +------------------------------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index 10b51106c854..ba195fbce4c6 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -730,49 +730,13 @@ out: } EXPORT_SYMBOL(of_find_node_with_property); -static const struct of_device_id * -of_match_compatible(const struct of_device_id *matches, - const struct device_node *node) -{ - const char *cp; - int cplen, l; - const struct of_device_id *m; - - cp = __of_get_property(node, "compatible", &cplen); - while (cp && (cplen > 0)) { - m = matches; - while (m->name[0] || m->type[0] || m->compatible[0]) { - /* Only match for the entries without type and name */ - if (m->name[0] || m->type[0] || - of_compat_cmp(m->compatible, cp, - strlen(m->compatible))) - m++; - else - return m; - } - - /* Get node's next compatible string */ - l = strlen(cp) + 1; - cp += l; - cplen -= l; - } - - return NULL; -} - static const struct of_device_id *__of_match_node(const struct of_device_id *matches, const struct device_node *node) { - const struct of_device_id *m; - if (!matches) return NULL; - m = of_match_compatible(matches, node); - if (m) - return m; - while (matches->name[0] || matches->type[0] || matches->compatible[0]) { int match = 1; if (matches->name[0]) @@ -796,12 +760,7 @@ const struct of_device_id *__of_match_node(const struct of_device_id *matches, * @matches: array of of device match structures to search in * @node: the of device structure to match against * - * Low level utility function used by device matching. We have two ways - * of matching: - * - Try to find the best compatible match by comparing each compatible - * string of device node with all the given matches respectively. - * - If the above method failed, then try to match the compatible by using - * __of_device_is_compatible() besides the match in type and name. + * Low level utility function used by device matching. */ const struct of_device_id *of_match_node(const struct of_device_id *matches, const struct device_node *node)