From patchwork Wed May 10 14:03:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 9719907 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 189DB6035D for ; Wed, 10 May 2017 14:06:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AB4F28602 for ; Wed, 10 May 2017 14:06:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3E7528609; Wed, 10 May 2017 14:06:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 9E52928602 for ; Wed, 10 May 2017 14:06:02 +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 1d8SDI-00076I-DN; Wed, 10 May 2017 14:03:36 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8SDH-00075u-JA for xen-devel@lists.xenproject.org; Wed, 10 May 2017 14:03:35 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id 02/3E-02183-6BD13195; Wed, 10 May 2017 14:03:34 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsVyMbThkO42WeF Ig9O3+C2+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozO90dZCs6KVHx7sp2xgbFNoIuRi0NIYAaj xO7vvSwgDovASxaJRa03mUAcCYF+VokNB7YwdjFyAjlxEtdmd7FA2NUSV363MoHYQgJKEq93b maCGDWLSeLJxovsIAk2AQOJ/e+egNkiQEX3Vk0Ga2AWKJfombmMrYuRg0NYIEBixmcxkDCLgK rE2gfvwMK8As4SLa8CIFbJSdw818kMYnMKuEjseH2HBWKts8T/j99ZJzAKLGBkWMWoUZxaVJZ apGtkqJdUlJmeUZKbmJmja2hgqpebWlycmJ6ak5hUrJecn7uJERhY9QwMjDsY7072O8QoycGk JMqru0soUogvKT+lMiOxOCO+qDQntfgQowwHh5IE7wUZ4UghwaLU9NSKtMwcYIjDpCU4eJREe I9KAKV5iwsSc4sz0yFSpxiNOV5cfv+eiePJyh/vmYRY8vLzUqXEebtAJgmAlGaU5sENgsXeJU ZZKWFeRgYGBiGegtSi3MwSVPlXjOIcjErCvJEgU3gy80rg9r0COoUJ6JRABgGQU0oSEVJSDYw 79hW+/5YqcPbnXPVX2/fsW+IWGcwtGmz7J+5W0Qn1W08WbIyINl2ZqtXbxNKXkL43xFz2gtL3 PqEZmwL+P6yY/yzres5Sm0i7CSxGqorzuo9veaAadkYwxoLlVub/6K6GqYxrpL4dEv+p9UX2O bPn/sjsolvMZxQv8B/hTOVekpA+c49aq7oSS3FGoqEWc1FxIgDsNz1VuAIAAA== X-Env-Sender: olekstysh@gmail.com X-Msg-Ref: server-8.tower-206.messagelabs.com!1494425014!97175557!1 X-Originating-IP: [209.85.128.194] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 49637 invoked from network); 10 May 2017 14:03:34 -0000 Received: from mail-wr0-f194.google.com (HELO mail-wr0-f194.google.com) (209.85.128.194) by server-8.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 10 May 2017 14:03:34 -0000 Received: by mail-wr0-f194.google.com with SMTP id g12so8717027wrg.2 for ; Wed, 10 May 2017 07:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8REJ3B6Ba9W1HaXTJJQcIcZiXZW4Jzc0ihSEANxaZlM=; b=CMivG5BVUeo/mVBCoNnXrFARMGTd8CPoIUgH4PONrGaA2LbAy7qx+jcsnJJxEYdS0X OseiAlob5d3wHqnxqG+Onz91Czv6dKt2EpTY30q+JNXCA2Wt6BI328+PsJ0KQ6NPXQof T5ZQs34Qn5jo8PMF1uZ87h5Jsx6Hph6xyMAA78PMUcWsM+qdNK0VjqC4u7eyZEhGmpfY lG0Ax4DOPbs7vZQ5mxa/eRXqvTAGn8+Nc4thsZvGskLwO7G1a/Ckl/XTs3Pmo3NeBKMD HjjWfGWr6ETBIbU7/lHtQoNrFciSlO+1qOZeQlhJmGLmE6u41auKnu8IvWmZFSFe2jv6 Zqsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8REJ3B6Ba9W1HaXTJJQcIcZiXZW4Jzc0ihSEANxaZlM=; b=QpsDETAqkRmGZQWNZVJt/HZyOeImvuZVwKlhgYZ86hdlBTJdsBLdDwRSrohxwcBB+o U6sZ9T2/KiX8Q7ych0MSfBiw6GigPY7oTitZI41txuk9ghyoEEXIdaUuRNs5HS2JAGaB rHycLJx5t17cduZU27lmCVxWKDYt+oV92rWKUbT33Goj9bCwievlRBylN7jO0sgsRpr1 nDs++kslgLJp8fEaFjwrUO14K6uWXy7dXal2rvRDDzg2zg+/RpE3+iszJCRpPajYjCaC dfz/xfZgRsFSwd8dWXVn7uuAJPUaws+T6MGPKiXdEkCXxQfwyRhswbFNjcAij/D7sTVQ thAQ== X-Gm-Message-State: AODbwcDeYhWpEEasjZj7nW3hsIzz9vYw4XoErc/ISwc/KReFTl5X87UK HZZNW1yCGBhlgA== X-Received: by 10.223.141.171 with SMTP id o40mr3807836wrb.110.1494425013860; Wed, 10 May 2017 07:03:33 -0700 (PDT) Received: from otyshchenko.kyiv.epam.com (ll-54.209.223.85.sovam.net.ua. [85.223.209.54]) by smtp.gmail.com with ESMTPSA id c34sm3378304wrc.7.2017.05.10.07.03.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 May 2017 07:03:33 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Wed, 10 May 2017 17:03:05 +0300 Message-Id: <1494424994-26232-2-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494424994-26232-1-git-send-email-olekstysh@gmail.com> References: <1494424994-26232-1-git-send-email-olekstysh@gmail.com> Cc: wei.liu2@citrix.com, julien.grall@arm.com, sstabellini@kernel.org, ian.jackson@eu.citrix.com, jbeulich@suse.com Subject: [Xen-devel] [PATCH v1 01/10] xen/device-tree: Add dt_count_phandle_with_args helper 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-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Tyshchenko Port Linux helper of_count_phandle_with_args for counting number of phandles in a property. Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Julien Grall --- Changes in v1: - Add Julien's reviewed-by --- xen/common/device_tree.c | 7 +++++++ xen/include/xen/device_tree.h | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 7b009ea..60b0095 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -1663,6 +1663,13 @@ int dt_parse_phandle_with_args(const struct dt_device_node *np, index, out_args); } +int dt_count_phandle_with_args(const struct dt_device_node *np, + const char *list_name, + const char *cells_name) +{ + return __dt_parse_phandle_with_args(np, list_name, cells_name, 0, -1, NULL); +} + /** * unflatten_dt_node - Alloc and populate a device_node from the flat tree * @fdt: The parent device tree blob diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 0aecbe0..738f1b6 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -764,6 +764,25 @@ int dt_parse_phandle_with_args(const struct dt_device_node *np, const char *cells_name, int index, struct dt_phandle_args *out_args); +/** + * dt_count_phandle_with_args() - Find the number of phandles references in a property + * @np: pointer to a device tree node containing a list + * @list_name: property name that contains a list + * @cells_name: property name that specifies phandles' arguments count + * + * Returns the number of phandle + argument tuples within a property. It + * is a typical pattern to encode a list of phandle and variable + * arguments into a single property. The number of arguments is encoded + * by a property in the phandle-target node. For example, a gpios + * property would contain a list of GPIO specifies consisting of a + * phandle and 1 or more arguments. The number of arguments are + * determined by the #gpio-cells property in the node pointed to by the + * phandle. + */ +int dt_count_phandle_with_args(const struct dt_device_node *np, + const char *list_name, + const char *cells_name); + #ifdef CONFIG_DEVICE_TREE_DEBUG #define dt_dprintk(fmt, args...) \ printk(XENLOG_DEBUG fmt, ## args)