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: 8662051 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1F46C9F36E for ; Thu, 24 Mar 2016 14:56:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 14A73203A0 for ; Thu, 24 Mar 2016 14:56:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4CC69202AE for ; Thu, 24 Mar 2016 14:56:09 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aj6eX-0004ra-5o; Thu, 24 Mar 2016 14:54:25 +0000 Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aj6ZI-0007Ux-Gz for linux-arm-kernel@lists.infradead.org; Thu, 24 Mar 2016 14:49:10 +0000 Received: by mail-pf0-x22c.google.com with SMTP id 4so59637002pfd.0 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=J/E8l10vMD3cIa8GcNf1T9BtGmDjBAZtCg3MAcdcaZv17v5/jBIvUd8iRQ/+HZirKu VnfHRoEIgi1JbkdsoKPTtAb5VYNi6ZOWBqEtLLiGpJJ2BFeypmCuUdrNa32Yqhowc3kW c7SxXRC3b80CT2qaPO3835bi17ypcWA1z+qdHDFzn8tE0shRNjOmLO7EK+V6toB1pAId cLCBRa1eLh8s+nFLKA0athAQbijcG7AOL3ez+XAZ8Ub/sdaS/B5TMo4OAKe04xb9LGpQ hB2sLcx4Y6NaEcvYoNuIRtDsR08zRpSECmDt1V6PMMKcI2TS+g1hViXD99Nlh7ezmoto yu2g== X-Gm-Message-State: AD7BkJKX4IH68jAbNMG4fUi+6euYuIbrIRydX6FMcjV2WZT+bmT6+3fs6ICaGAaFiNJG7wtn 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 Subject: [PATCH v7 16/17] FDT: Add a helper to get the subnode by given name 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160324_074901_358245_FA41C1B5 X-CRM114-Status: GOOD ( 12.14 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-efi@vger.kernel.org, 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 MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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);