From patchwork Fri Apr 1 15:49:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 8726221 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 98698C0554 for ; Fri, 1 Apr 2016 15:54:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BBF71203E5 for ; Fri, 1 Apr 2016 15:54:12 +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 3DA41203DC for ; Fri, 1 Apr 2016 15:54:11 +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 1am1Mb-0005cx-Gs; Fri, 01 Apr 2016 15:51:57 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1am1Ma-0005aj-Bw for xen-devel@lists.xen.org; Fri, 01 Apr 2016 15:51:56 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id 0E/2D-15848-B199EF65; Fri, 01 Apr 2016 15:51:55 +0000 X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-8.tower-206.messagelabs.com!1459525913!32298541!1 X-Originating-IP: [209.85.220.41] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 7755 invoked from network); 1 Apr 2016 15:51:54 -0000 Received: from mail-pa0-f41.google.com (HELO mail-pa0-f41.google.com) (209.85.220.41) by server-8.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 1 Apr 2016 15:51:54 -0000 Received: by mail-pa0-f41.google.com with SMTP id fe3so93931736pab.1 for ; Fri, 01 Apr 2016 08:51:54 -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=nWu3d7Z+tgU1lAkPI0s6CyZU8I/HU4cYHm2enmJu4n8=; b=b0LgwpHhjKEfaAizl5oukCJbpgwpVFIV0rrphVsfJTIgbk759PMcA0LCoJX0T0E+XB BPJTrZz0S4KgqN7LTeKp3qBVQEG8Wy7tTS5S5HHsj4wz7Kw/Ixwu8DLe/uzUg/qjN5wB OtPJNW/MhElYGyPwM6VwbikP6KU2bWM+Hc/Sg= 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=nWu3d7Z+tgU1lAkPI0s6CyZU8I/HU4cYHm2enmJu4n8=; b=mJel7r3/vrQUJwMv1sMx9tHNa86MV/FLfy77Ui0mjAIv+0spqa2Y0EBln8hPJWWfy4 qlnCKytE84/DUWMwB7xehwPctXabYMy7ICax8eVHbzwtjE3t1Iy4BUgddUlwV+VAW14k lRkxTjMR1WX8uMIXEd8xTPZ5eTISSS/VuqYXkBKCMY4bUS+upQFDeioQfdFM1paf5V4w PIiBSSMOf9Aaxf808dip3JbdJhzXSM7y1EsFuAqjkl+KlHMAlE7FgULQGgftNnPJHD0F WIT/6itwU/+fn5dnV0vs3aCG4NPiskw+MRQtqm2/OaauC1fU/ByGlnBRagSQJu4JItHl asHw== X-Gm-Message-State: AD7BkJLviyFlWxuda8y1kANiDPHLfUe1ZEoI9oAgFn93cW3FfgXbNn80ELBkHtS9jYJBc/AA X-Received: by 10.66.55.70 with SMTP id q6mr31375201pap.126.1459525913046; Fri, 01 Apr 2016 08:51:53 -0700 (PDT) Received: from localhost.localdomain ([167.160.116.218]) by smtp.gmail.com with ESMTPSA id yj1sm22536791pac.16.2016.04.01.08.51.44 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 01 Apr 2016 08:51:51 -0700 (PDT) From: Shannon Zhao To: linux-arm-kernel@lists.infradead.org, stefano.stabellini@citrix.com Date: Fri, 1 Apr 2016 23:49:14 +0800 Message-Id: <1459525755-36968-17-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1459525755-36968-1-git-send-email-shannon.zhao@linaro.org> References: <1459525755-36968-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, david.vrabel@citrix.com, zhaoshenglong@huawei.com, xen-devel@lists.xen.org, shannon.zhao@linaro.org Subject: [Xen-devel] [PATCH v10 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 3349d2a..5c8b2f2 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 2fbe868..2c3707e 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);