From patchwork Wed Feb 19 14:14:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 24961 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f69.google.com (mail-qa0-f69.google.com [209.85.216.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 681BC2054E for ; Wed, 19 Feb 2014 14:16:48 +0000 (UTC) Received: by mail-qa0-f69.google.com with SMTP id w8sf601657qac.8 for ; Wed, 19 Feb 2014 06:16:48 -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=PC8Aijdr3Dq5ZRYRj6221MdoFmhwRBfIXE5cDT4a/LGR2pGR2+JIj3TDXuo6d5j01+ D7cpPwMAC68YQytTnLQBvFRgqnBW0gbwRvNZh23M1Zgz2ewJ2qDFAcgIxiJ3y3bykHZl XrJK4zEJu3D0oEVhXjs5uwZed+vYHZYDdQt42RwImyBxCD6/mWRZNYU6tzI9DQTZJ3rA RFG7WzqySzhy3jnPPzqdvB+c2ZQkP21iqCn09IM4HhMeYk3MkkhdvhQ/oJ3giAIqaE5x kKac1q+8MsuNwYsuM2hMQYwFqCLRuwLfT/SnnZx+LRN+P3eSEvsNW7NX5RNuJPSqgyiV AV5w== X-Gm-Message-State: ALoCoQlEi7X2xs2tOMjjNilYMZQNgoDbQCIhCWCf86Ghgif3DpaVBHU7roVV28VkZgXA3seMhmKr X-Received: by 10.224.20.133 with SMTP id f5mr15292465qab.8.1392819408235; Wed, 19 Feb 2014 06:16:48 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.231 with SMTP id q94ls115159qga.45.gmail; Wed, 19 Feb 2014 06:16:48 -0800 (PST) X-Received: by 10.52.232.168 with SMTP id tp8mr11245752vdc.38.1392819408089; Wed, 19 Feb 2014 06:16:48 -0800 (PST) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id si7si115794vdc.102.2014.02.19.06.16.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Feb 2014 06:16:48 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.171 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.171; Received: by mail-ve0-f171.google.com with SMTP id pa12so421859veb.30 for ; Wed, 19 Feb 2014 06:16:48 -0800 (PST) X-Received: by 10.220.106.84 with SMTP id w20mr25568996vco.18.1392819407968; Wed, 19 Feb 2014 06:16:47 -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 u4csp300737vcz; Wed, 19 Feb 2014 06:16:47 -0800 (PST) X-Received: by 10.68.172.37 with SMTP id az5mr2504966pbc.139.1392819407054; Wed, 19 Feb 2014 06:16:47 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fb4si395628pbb.82.2014.02.19.06.16.46; Wed, 19 Feb 2014 06:16:46 -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 S1753803AbaBSOQi (ORCPT + 27 others); Wed, 19 Feb 2014 09:16:38 -0500 Received: from mail-we0-f182.google.com ([74.125.82.182]:49010 "EHLO mail-we0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753910AbaBSOPC (ORCPT ); Wed, 19 Feb 2014 09:15:02 -0500 Received: by mail-we0-f182.google.com with SMTP id u57so378117wes.13 for ; Wed, 19 Feb 2014 06:15:01 -0800 (PST) X-Received: by 10.180.182.199 with SMTP id eg7mr1712316wic.13.1392819301050; Wed, 19 Feb 2014 06:15:01 -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 f3sm2106059wiv.2.2014.02.19.06.14.59 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Feb 2014 06:15:00 -0800 (PST) Received: by trevor.secretlab.ca (Postfix, from userid 1000) id 0DA69C40B2B; Wed, 19 Feb 2014 14:14:54 +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 v4 1/4] Revert "of: search the best compatible match first in __of_match_node()" Date: Wed, 19 Feb 2014 14:14:47 +0000 Message-Id: <1392819290-1044-2-git-send-email-grant.likely@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1392819290-1044-1-git-send-email-grant.likely@linaro.org> References: <1392819290-1044-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.171 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)