From patchwork Wed Feb 12 05:28:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hao X-Patchwork-Id: 319516 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id B68922C0396 for ; Wed, 12 Feb 2014 16:28:59 +1100 (EST) Received: from mail-pd0-x230.google.com (mail-pd0-x230.google.com [IPv6:2607:f8b0:400e:c02::230]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 921522C00BC for ; Wed, 12 Feb 2014 16:28:33 +1100 (EST) Received: by mail-pd0-f176.google.com with SMTP id w10so8503556pde.21 for ; Tue, 11 Feb 2014 21:28:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=b0WIhVy6FJYaXrcJhAWvrpOmKqKQosfspe3/W4CAM3E=; b=WFtu6cRVTba1k5eMNfNznIlEnq0n1Inlt8NVaHOYGBdkIKEEMhxo0jFjmiIp8jeXBF dydT0aJqwxTEKfLf0JO68Lw2jA/irdPhxPZk+LXUDYqfq4P3hRRGabsdg0CWAZwXmdMc V1GkQeb5xbQrw9FPyv5BUzGw+tvEg+aGtGvFy5H4j/DIfOY2i87BDn2IAYQbZg04CtS6 c0NT9lrk9MYsN76c4/e+kN91MYwVo/J922qdDsgcgI2kyaay4W6KsZ+qIlvXhZ2EUM0l 7wNksHOuKkKvmrA9Ewfzexrk0qY3pNmXgiC8ONZA7ydPgL02ymgWvsCpXuKtOD7DEJBK fdJg== X-Received: by 10.66.119.136 with SMTP id ku8mr37155184pab.121.1392182909656; Tue, 11 Feb 2014 21:28:29 -0800 (PST) Received: from pek-khao-d1.corp.ad.wrs.com ([1.202.252.122]) by mx.google.com with ESMTPSA id id1sm59182588pbc.11.2014.02.11.21.28.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Feb 2014 21:28:28 -0800 (PST) Date: Wed, 12 Feb 2014 13:28:16 +0800 From: Kevin Hao To: Stephen N Chivers Subject: Re: Linux-3.14-rc2: Order of serial node compatibles in DTS files. Message-ID: <20140212052816.GA15434@pek-khao-d1.corp.ad.wrs.com> References: <20140210110342.GA15806@visitor2.iram.es> <20140211072606.GA26514@visitor2.iram.es> <63AEBD99-AA87-4FD7-BBDA-0CE419959F14@kernel.crashing.org> <52FAA97F.4060600@gmail.com> <1392162080.6733.404.camel@snotra.buserror.net> <52FAB65C.4090201@gmail.com> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Chris Proctor , Arnd Bergmann , devicetree , Scott Wood , linuxppc-dev@lists.ozlabs.org, Sebastian Hesselbarth X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Wed, Feb 12, 2014 at 10:21:58AM +1000, Stephen N Chivers wrote: > But, the Interrupt Controller (MPIC) > goes AWOL and it is down hill from there. > > The MPIC is specified in the DTS as: > > mpic: pic@40000 { > interrupt-controller; > #address-cells = <0>; > #interrupt-cells = <2>; > reg = <0x40000 0x40000>; > compatible = "chrp,open-pic"; > device_type = "open-pic"; > big-endian; > }; > > The board support file has the standard mechanism for allocating > the PIC: > > struct mpic *mpic; > > mpic = mpic_alloc(NULL, 0, 0, 0, 256, " OpenPIC "); > BUG_ON(mpic == NULL); > > mpic_init(mpic); > > I checked for damage in applying the patch and it has applied > correctly. How about the following fix? Thanks, Kevin > > Stephen Chivers, > CSC Australia Pty. Ltd. > > _______________________________________________ > Linuxppc-dev mailing list > Linuxppc-dev@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/linuxppc-dev diff --git a/drivers/of/base.c b/drivers/of/base.c index ff85450d5683..ca91984d3c4b 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -730,32 +730,40 @@ out: } EXPORT_SYMBOL(of_find_node_with_property); +static int of_match_type_name(const struct device_node *node, + const struct of_device_id *m) +{ + int match = 1; + + if (m->name[0]) + match &= node->name && !strcmp(m->name, node->name); + + if (m->type[0]) + match &= node->type && !strcmp(m->type, node->type); + + return match; +} + static const struct of_device_id *__of_match_node(const struct of_device_id *matches, const struct device_node *node) { const char *cp; int cplen, l; + const struct of_device_id *m; + int match; if (!matches) return NULL; cp = __of_get_property(node, "compatible", &cplen); do { - const struct of_device_id *m = matches; + m = matches; /* Check against matches with current compatible string */ - while (m->name[0] || m->type[0] || m->compatible[0]) { - int match = 1; - if (m->name[0]) - match &= node->name - && !strcmp(m->name, node->name); - if (m->type[0]) - match &= node->type - && !strcmp(m->type, node->type); - if (m->compatible[0]) - match &= cp - && !of_compat_cmp(m->compatible, cp, + while (m->compatible[0]) { + match = of_match_type_name(node, m); + match &= cp && !of_compat_cmp(m->compatible, cp, strlen(m->compatible)); if (match) return m; @@ -770,6 +778,15 @@ const struct of_device_id *__of_match_node(const struct of_device_id *matches, } } while (cp && (cplen > 0)); + /* Check against matches without compatible string */ + m = matches; + while (!m->compatible[0] && (m->name[0] || m->type[0])) { + match = of_match_type_name(node, m); + if (match) + return m; + m++; + } + return NULL; }