From patchwork Mon Apr 10 05:43:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 748838 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3w1fKZ6xfjz9s7L for ; Mon, 10 Apr 2017 15:45:22 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uhozURoa"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3w1fKZ5vBxzDqFL for ; Mon, 10 Apr 2017 15:45:22 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uhozURoa"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-pg0-x241.google.com (mail-pg0-x241.google.com [IPv6:2607:f8b0:400e:c05::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3w1fJ16r2CzDq8B for ; Mon, 10 Apr 2017 15:44:01 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uhozURoa"; dkim-atps=neutral Received: by mail-pg0-x241.google.com with SMTP id 79so24406596pgf.0 for ; Sun, 09 Apr 2017 22:44:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=WioS4tziRM10K/DUCAR0wsTtsIJq2pZ62e0oXFdL8ws=; b=uhozURoa9T7+TUXq9yt4L+Lf4aFoBaquzClSylkiBvJHq4/XAcpq/LM+F89KG4hyJn 9VE6eBcewVnBaqUcZ/49S6djCsZUkVj+YvCG54hfSznukOMNBRMWdt98+rSEsIJ65ELz aA2VFNZAivAbeTi33ZLp4J64RgZy9+LRecIxXspWTBnWci1VHO4TSko9D9pliIr3Uedh Cz3G19SXqQULaDE3TSMCsCts97H7qoEEJjD2pgOSwytX/fHHIK2Ml9XEp+6YQ2vLD803 /wqPC/+bBBT/ppnqO24DyGbfKzZXZrNcaMxuQBkaFlzX/3CeFqNkgW1ZG/MGpuQHd3XT py3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=WioS4tziRM10K/DUCAR0wsTtsIJq2pZ62e0oXFdL8ws=; b=NitzMBcDYlmHUyqyLNtvduaw1ph4sEcEdXUvMJ/PiEhmGHDf6YgN0QyB3qeTP5SDKj RU5Lp0GRE0+KgMV0eqGdVbq50MMLIE4Wjfl+0DpI2iystq2yD2mIoZMsfBzA+KDPSUSm n7BucDu8nmNPYc3hBhBY7XE8+vVPIYsUzTSiCugZ+tZixK7KzXkMuxvSXbOrWFZ5MDCp Z6WcZzxftr6zUhVUin21ycXaZwLXv9lUYWX1OnMC/IZ9dh1xmKPiDt5pi6UEKTt/fmbI YxjKZGjrvui9EZ6aMmHpCE7k9Dmoh3DYhFOAeIRVZFxjkGEF2PtAVL10qyyFG639gyC9 OykQ== X-Gm-Message-State: AFeK/H0L08K9a4/hJ4DHjPGPMRaVlI/vv2ajAIm6cDh5W2huq35o1taRv3fTSfJLKR/3nQ== X-Received: by 10.98.213.130 with SMTP id d124mr53207322pfg.172.1491803040123; Sun, 09 Apr 2017 22:44:00 -0700 (PDT) Received: from roar.ozlabs.ibm.com ([203.221.48.234]) by smtp.gmail.com with ESMTPSA id 2sm21842148pfo.35.2017.04.09.22.43.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Apr 2017 22:43:58 -0700 (PDT) Date: Mon, 10 Apr 2017 15:43:48 +1000 From: Nicholas Piggin To: Rob Herring Subject: Re: [PATCH 2/3] of/fdt: introduce of_scan_flat_dt_subnodes and of_get_flat_dt_phandle Message-ID: <20170410154348.051e7a34@roar.ozlabs.ibm.com> In-Reply-To: References: <20170405123706.6081-1-npiggin@gmail.com> <20170405123706.6081-3-npiggin@gmail.com> <20170406003251.533e2845@roar.ozlabs.ibm.com> <1491425881.4166.90.camel@kernel.crashing.org> <20170406103829.67d462e1@roar.ozlabs.ibm.com> Organization: IBM X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "devicetree@vger.kernel.org" , linuxppc-dev , Frank Rowand Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Thu, 6 Apr 2017 09:09:41 -0500 Rob Herring wrote: > On Wed, Apr 5, 2017 at 7:38 PM, Nicholas Piggin wrote: > > Given that it's quite a small addition to of/fdt code, hopefully > > that gives you a reasonable justification to accept it. > > > > If you prefer not to, that's okay, but I think we would have to carry > > it in arch/powerpc at least for a time, because of the schedule we're > > working to for POWER9 enablement. As a longer term item I agree with you > > and Ben, it would be worth considering unflattening earlier. > > As I mentioned, keeping it in arch/powerpc I like even less. So this is fine. Here is the patch with the change you suggested. Can I add your ack and send it via the powerpc tree with the change that uses these interfaces? Thanks, Nick Acked-by: Rob Herring --- drivers/of/fdt.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/of_fdt.h | 6 ++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index e5ce4b59e162..961ca97072a9 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -754,6 +754,36 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node, } /** + * of_scan_flat_dt_subnodes - scan sub-nodes of a node call callback on each. + * @it: callback function + * @data: context data pointer + * + * This function is used to scan sub-nodes of a node. + */ +int __init of_scan_flat_dt_subnodes(unsigned long parent, + int (*it)(unsigned long node, + const char *uname, + void *data), + void *data) +{ + const void *blob = initial_boot_params; + int node; + + fdt_for_each_subnode(node, blob, parent) { + const char *pathp; + int rc; + + pathp = fdt_get_name(blob, node, NULL); + if (*pathp == '/') + pathp = kbasename(pathp); + rc = it(node, pathp, data); + if (rc) + return rc; + } + return 0; +} + +/** * of_get_flat_dt_subnode_by_name - get the subnode by given name * * @node: the parent node @@ -812,6 +842,14 @@ int __init of_flat_dt_match(unsigned long node, const char *const *compat) return of_fdt_match(initial_boot_params, node, compat); } +/** + * of_get_flat_dt_prop - Given a node in the flat blob, return the phandle + */ +uint32_t __init of_get_flat_dt_phandle(unsigned long node) +{ + return fdt_get_phandle(initial_boot_params, node); +} + struct fdt_scan_status { const char *name; int namelen; diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index 271b3fdf0070..1dfbfd0d8040 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -54,6 +54,11 @@ 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_scan_flat_dt_subnodes(unsigned long node, + int (*it)(unsigned long node, + const char *uname, + 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, @@ -62,6 +67,7 @@ extern int of_flat_dt_is_compatible(unsigned long node, const char *name); extern int of_flat_dt_match(unsigned long node, const char *const *matches); extern unsigned long of_get_flat_dt_root(void); extern int of_get_flat_dt_size(void); +extern uint32_t of_get_flat_dt_phandle(unsigned long node); extern int early_init_dt_scan_chosen(unsigned long node, const char *uname, int depth, void *data);