From patchwork Wed May 21 16:09:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 30550 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f69.google.com (mail-yh0-f69.google.com [209.85.213.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id ADA3E20675 for ; Wed, 21 May 2014 16:09:54 +0000 (UTC) Received: by mail-yh0-f69.google.com with SMTP id i57sf7923862yha.8 for ; Wed, 21 May 2014 09:09:54 -0700 (PDT) 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:subject:to:cc :in-reply-to:references:date:message-id:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=aLTi/pvC8YEPyY+PD/fjtv0bs0jWBPNTSayurZkDSco=; b=fZHMUwbXGRiKCC7hCvhOzPiM0Aa6hy8XaoDEIZ/BYe++fsdrFFlznRX/wZS/wNNiaT 5dmG78BB8SkF37JCXv2rdSZqXc0saCONjEGyqPHKdKKiuEjjocyFbNLCoCU4EZrlpgwq 6t2wZtNgqxXRJlxuP2tWgIyV5IX/i+Y7D9InDBLCVJBb4mvOmm8mw3bHY0PILXkYGyhC nCcd6sG7VYUysbBbut5YMoX8IS7c8abth7FecHDFi4D9V1ZhUprj+PEBrGIJjFv1wS1p V63tETvqdwQtORazLeAptbcAvx6fLK+LiHnLOBkV8Sbek9NkGlqlx7oowm5r8UOKDN10 iqFw== X-Gm-Message-State: ALoCoQlu7F4g3kePBkxB7/5FfdQveDi4tm2K6X4i/5QWQHQQIFojM++h1kOBc0U4GgaLqYc0TDrR X-Received: by 10.224.120.67 with SMTP id c3mr8210240qar.4.1400688594500; Wed, 21 May 2014 09:09:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.34.46 with SMTP id k43ls833451qgk.58.gmail; Wed, 21 May 2014 09:09:54 -0700 (PDT) X-Received: by 10.58.243.39 with SMTP id wv7mr1296949vec.51.1400688594388; Wed, 21 May 2014 09:09:54 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id xe4si1452012vdc.71.2014.05.21.09.09.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 May 2014 09:09:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id hu19so2789539vcb.20 for ; Wed, 21 May 2014 09:09:54 -0700 (PDT) X-Received: by 10.221.7.71 with SMTP id on7mr10716820vcb.18.1400688592250; Wed, 21 May 2014 09:09:52 -0700 (PDT) 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.221.72 with SMTP id ib8csp126177vcb; Wed, 21 May 2014 09:09:51 -0700 (PDT) X-Received: by 10.66.241.66 with SMTP id wg2mr59563602pac.132.1400688591122; Wed, 21 May 2014 09:09:51 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ez2si6840603pbd.174.2014.05.21.09.09.50; Wed, 21 May 2014 09:09:50 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752824AbaEUQJn (ORCPT + 27 others); Wed, 21 May 2014 12:09:43 -0400 Received: from mail-pd0-f182.google.com ([209.85.192.182]:50346 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752690AbaEUQJk (ORCPT ); Wed, 21 May 2014 12:09:40 -0400 Received: by mail-pd0-f182.google.com with SMTP id r10so1535814pdi.27 for ; Wed, 21 May 2014 09:09:40 -0700 (PDT) X-Received: by 10.68.242.135 with SMTP id wq7mr60129708pbc.147.1400688580484; Wed, 21 May 2014 09:09:40 -0700 (PDT) Received: from trevor.secretlab.ca ([61.215.197.74]) by mx.google.com with ESMTPSA id xr9sm106975769pab.5.2014.05.21.09.09.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 May 2014 09:09:39 -0700 (PDT) Received: by trevor.secretlab.ca (Postfix, from userid 1000) id DD7F9C4198A; Thu, 22 May 2014 01:09:31 +0900 (JST) From: Grant Likely Subject: Re: [PATCH 2/3] of: Make of_find_node_by_path() handle /aliases To: frowand.list@gmail.com Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, David Daney , Pantelis Antoniou In-Reply-To: <537C15B1.3020006@gmail.com> References: <1399993115-21552-1-git-send-email-grant.likely@linaro.org> <1399993115-21552-3-git-send-email-grant.likely@linaro.org> <537C15B1.3020006@gmail.com> Date: Thu, 22 May 2014 01:09:31 +0900 Message-Id: <20140521160931.DD7F9C4198A@trevor.secretlab.ca> 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=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) 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: , On Tue, 20 May 2014 19:55:45 -0700, Frank Rowand wrote: > On 5/13/2014 7:58 AM, Grant Likely wrote: > > > Make of_find_node_by_path() handle aliases as prefixes. To make this > > > work the name search is refactored to search by path component instead > > > of by full string. This should be a more efficient search, and it makes > > > it possible to start a search at a subnode of a tree. > > > > > > Signed-off-by: David Daney > > > Signed-off-by: Pantelis Antoniou > > > [grant.likely: Rework to not require allocating at runtime] > > > Acked-by: Rob Herring > > > Signed-off-by: Grant Likely > > > --- > > > drivers/of/base.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++---- > > > 1 file changed, 56 insertions(+), 4 deletions(-) > > > > Was this patch created against a tree that has modifications to device tree > > locking? > I get a hang due to deadlock when I apply it. Patch to verify the > cause is below. Ummm... I may have forgotten to enable CONFIG_LOCKDEP when testing. Try the following fix, and can you please pass me that brown paper bag. g. commit 35e9c5ae6c3d0b5eb91579f397d8e1ecb95ee711 Author: Grant Likely Date: Thu May 22 01:04:17 2014 +0900 dt: Create unlocked version of for_each_child_of_node() When iterating over nodes, sometimes it needs to be done when the DT lock is already held. This patch makes an unlocked version of the for_each_child_of_node() macro. Signed-off-by: Grant Likely --- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/drivers/of/base.c b/drivers/of/base.c index 8900d378c07e..c05a143b6a70 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -695,6 +695,22 @@ struct device_node *of_get_next_parent(struct device_node *node) } EXPORT_SYMBOL(of_get_next_parent); +#define __for_each_child_of_node(parent, child) \ + for (child = __of_get_next_child(parent, NULL); child != NULL; \ + child = __of_get_next_child(parent, child)) +static struct device_node *__of_get_next_child(const struct device_node *node, + struct device_node *prev) +{ + struct device_node *next; + + next = prev ? prev->sibling : node->child; + for (; next; next = next->sibling) + if (of_node_get(next)) + break; + of_node_put(prev); + return next; +} + /** * of_get_next_child - Iterate a node childs * @node: parent node @@ -710,11 +726,7 @@ struct device_node *of_get_next_child(const struct device_node *node, unsigned long flags; raw_spin_lock_irqsave(&devtree_lock, flags); - next = prev ? prev->sibling : node->child; - for (; next; next = next->sibling) - if (of_node_get(next)) - break; - of_node_put(prev); + next = __of_get_next_child(node, prev); raw_spin_unlock_irqrestore(&devtree_lock, flags); return next; } @@ -780,7 +792,7 @@ static struct device_node *__of_find_node_by_path(struct device_node *parent, if (!len) return parent; - for_each_child_of_node(parent, child) { + __for_each_child_of_node(parent, child) { const char *name = strrchr(child->full_name, '/'); if (WARN(!name, "malformed device_node %s\n", child->full_name)) continue;