From patchwork Thu Mar 24 14:44:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 8661831 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B5113C0553 for ; Thu, 24 Mar 2016 14:51:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D9F65203B6 for ; Thu, 24 Mar 2016 14:51:02 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E37BC2017D for ; Thu, 24 Mar 2016 14:51:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aj6Z2-000406-5x; Thu, 24 Mar 2016 14:48:44 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aj6Z1-0003yo-4z for xen-devel@lists.xen.org; Thu, 24 Mar 2016 14:48:43 +0000 Received: from [193.109.254.147] by server-4.bemta-14.messagelabs.com id 5E/5C-03301-A4EF3F65; Thu, 24 Mar 2016 14:48:42 +0000 X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-9.tower-27.messagelabs.com!1458830919!33545154!1 X-Originating-IP: [209.85.192.176] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 1717 invoked from network); 24 Mar 2016 14:48:41 -0000 Received: from mail-pf0-f176.google.com (HELO mail-pf0-f176.google.com) (209.85.192.176) by server-9.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 24 Mar 2016 14:48:41 -0000 Received: by mail-pf0-f176.google.com with SMTP id n5so59265009pfn.2 for ; Thu, 24 Mar 2016 07:48:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YxPBrSqYXIY1woqvstB9gfpp3NKgTuq1QnTgroG0b4s=; b=gtT4EL9ukS3TrJIU5WJU5fe8qbQrNweTLd2xnKxTgvzCY+DAAFr4R3d683DI6l5yNx E7DSDBKahTKQVTz3gvBxV5Tktk7o3Y5lgRS6B2t8rRZpGNYppkfxTAptYA3CnDDPO5Id wGdF3OqJcdQwUNDECetj7R40lVT4oEv5VPPJ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YxPBrSqYXIY1woqvstB9gfpp3NKgTuq1QnTgroG0b4s=; b=hEtZISUhqBX/Jf0zlY9lwd3KrD2QDdSrsfwHQxGtuc9FV8zxQsPvbZsitVhRSq4PuY DXECEqMd0BSIDcbAUP+2VsJjrAfq7bYP9KBr/XEDSwzm7aWYkdUydzl0l2BQoGTaT4G3 Skm3lX2xBWM4XN4YVCxtIi912CztkcRc3lj4VkGbRNsE67s4FjaldfSdnngvmEluzrn9 s8k6kaed7FBfCF8Y79+4rAr9+EBQ0+EJybOEUeXWcVwnoI/jp5ggQ8Re8L7Ryjril+mq eyAm0wOOBRlBPmXI3ALC7zLIJEEtRjHFcwL2U3i3b84d3zfynQo8oEgfVQj0KK/nHmFM TX0g== X-Gm-Message-State: AD7BkJIr7ZPUdX/xTQWzLQEHChQFjPEOoD+2m7u/C08IG8Fgyzj+B39/dMwrROsF3WdbjNiX X-Received: by 10.98.17.132 with SMTP id 4mr13530300pfr.16.1458830919549; Thu, 24 Mar 2016 07:48:39 -0700 (PDT) Received: from localhost.localdomain ([104.238.45.135]) by smtp.gmail.com with ESMTPSA id lq10sm10780673pab.36.2016.03.24.07.48.30 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 24 Mar 2016 07:48:38 -0700 (PDT) From: Shannon Zhao To: linux-arm-kernel@lists.infradead.org, stefano.stabellini@citrix.com, david.vrabel@citrix.com Date: Thu, 24 Mar 2016 22:44:35 +0800 Message-Id: <1458830676-27075-17-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1458830676-27075-1-git-send-email-shannon.zhao@linaro.org> References: <1458830676-27075-1-git-send-email-shannon.zhao@linaro.org> Cc: devicetree@vger.kernel.org, linux-efi@vger.kernel.org, Rob Herring , catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, peter.huangpeng@huawei.com, julien.grall@arm.com, shannon.zhao@linaro.org, zhaoshenglong@huawei.com, xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH v7 16/17] FDT: Add a helper to get the subnode by given name X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sometimes it needs to check if there is a subnode of given node in FDT by given name. Introduce this helper to get the subnode if it exists. CC: Rob Herring Signed-off-by: Shannon Zhao Acked-by: Stefano Stabellini Acked-by: Rob Herring --- drivers/of/fdt.c | 13 +++++++++++++ include/linux/of_fdt.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 655f79d..09001db 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -645,6 +645,19 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node, } /** + * of_get_flat_dt_subnode_by_name - get the subnode by given name + * + * @node: the parent node + * @uname: the name of subnode + * @return offset of the subnode, or -FDT_ERR_NOTFOUND if there is none + */ + +int of_get_flat_dt_subnode_by_name(unsigned long node, const char *uname) +{ + return fdt_subnode_offset(initial_boot_params, node, uname); +} + +/** * of_get_flat_dt_root - find the root node in the flat blob */ unsigned long __init of_get_flat_dt_root(void) diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index df9ef38..fc28162 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -52,6 +52,8 @@ extern char __dtb_end[]; extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname, int depth, void *data), void *data); +extern int of_get_flat_dt_subnode_by_name(unsigned long node, + const char *uname); extern const void *of_get_flat_dt_prop(unsigned long node, const char *name, int *size); extern int of_flat_dt_is_compatible(unsigned long node, const char *name);