From patchwork Wed Mar 15 20:05:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 9626597 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 B1C5E60522 for ; Wed, 15 Mar 2017 20:12:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F97A285D1 for ; Wed, 15 Mar 2017 20:12:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9441828650; Wed, 15 Mar 2017 20:12:43 +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 1B22528625 for ; Wed, 15 Mar 2017 20:12:43 +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 1coFBB-0008Tv-7y; Wed, 15 Mar 2017 20:05:53 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1coFBA-0008Tb-FN for xen-devel@lists.xenproject.org; Wed, 15 Mar 2017 20:05:52 +0000 Received: from [85.158.137.68] by server-2.bemta-3.messagelabs.com id 1E/D3-16699-F9E99C85; Wed, 15 Mar 2017 20:05:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrIIsWRWlGSWpSXmKPExsXiVRvkrDt/3sk Ig+u2Ft+3TGZyYPQ4/OEKSwBjFGtmXlJ+RQJrxr3zn9gKnghXPL16l62BcTN/FyMXh5DADEaJ N/ffsoE4LAIvWSRWbVjOCOJICPSzSmz5+Jy5i5ETyImRONt0kQXCrpD49OQ6G4gtJKAk8XrnZ iaIUXOYJJZv2wiWYBMwkNj/7gk7iC0CVHRv1WSwImaBM4wSnxeBOJwcwgL+Ev8PtTKC2CwCqh JT1z8Ei/MKOEm8nTSFDWKbnMTNc51gV3AKOEu8eNrCCrHZSWLagpPMExgFFjAyrGLUKE4tKks t0jU00ksqykzPKMlNzMzRNTQw1stNLS5OTE/NSUwq1kvOz93ECAwuBiDYwfiq2/kQoyQHk5Io b/mPExFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHiVQXKCRanpqRVpmTnAMIdJS3DwKInwXgZJ8 xYXJOYWZ6ZDpE4x6nJ86D/8hkmIJS8/L1VKnFcGpEgApCijNA9uBCzmLjHKSgnzMgIdJcRTkF qUm1mCKv+KUZyDUUmYNxVkCk9mXgncpldARzABHfH2A9gRJYkIKakGRl1vt6kdHby5oWUTmJ3 ZLxYcYOdc/9Nao+is0LbD8w/LCd75erf37YGyl38am3VfbQzY7rjy+yZVU0m13iTlGz0XD5du yX385k+2W2KEeCev4pMfVfr8U+T/mx96LbIq97vqEWdF36Sjm5IPJ8Xy9f7YNfWvWuGncNn1a 55N0z/mGsr4LTHNVImlOCPRUIu5qDgRALRIBii0AgAA X-Env-Sender: olekstysh@gmail.com X-Msg-Ref: server-11.tower-31.messagelabs.com!1489608350!59567445!1 X-Originating-IP: [74.125.82.67] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28954 invoked from network); 15 Mar 2017 20:05:50 -0000 Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by server-11.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 15 Mar 2017 20:05:50 -0000 Received: by mail-wm0-f67.google.com with SMTP id u132so6447736wmg.1 for ; Wed, 15 Mar 2017 13:05:50 -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=iQEUKEddlZgU+LVH+zLgXt1H7ZapUQVip6vS9iM8Yu0=; b=qkKasAo/umYmDrAa2+KhZda0B3jH/bdYfdgr3EyZavqeavXBjm/EaR4m75zyOOVnnx 4jTRmD0/zLsVv0DP/cFGh02mPgck46QfkjE89T8N53Dub/ZjexpseN4DRn6iJ2hL440U I1dM984gqYGsfWDYPojBivK3FIJdzZdOBBQf1bTseW1dIaDO5W54Y20eZx1FFbxh8KQY lnzHyi51QuknaX7jQJeX9KgfBFjJobArfc8YqXUUxkVf3qMssER3kyNGB6S0ZHT8XUYe OSSy190oY7HoLboZ+kU1rwk7dRpRPzVkPnUwpL49T42q/nKvsLnLpbb/jr8G3YK/BS9U FgrA== 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=iQEUKEddlZgU+LVH+zLgXt1H7ZapUQVip6vS9iM8Yu0=; b=M1fRgR72vOUSR5od+Hgct3uxojPU8/yDUXcBqft0dUMJxkFNaNo9sjoFyHxZg5GZ+L tSmJhyX2bwsW+zn01Tz4/YRSiEaU0QsPJsfGncotzoFENvhVso44aOjDua4UJPIbIENG API0OIvZqeMbjn94p6ysV6U/5Jqf2h8XpGHSC5rJTk5wRlsFOEP99XvWpqlbw6JpLgoa ILKCGTPh6mc4vYQrdf9mkxkurMQ14sBcfRcE6j3tXzLJCmZNC0U0azbklQ77U9yGGruH OwU2sDzpRegh5dzKQ9hUWSfVotHOQ5fV4gQoolW5vAJsDPl4pcqGKMzxhUy/YCKM6Rkr x5eA== X-Gm-Message-State: AFeK/H0CVHtfw8mrqYOGJwNUES3cs4y8dwmz3aDrZn8/Rl5kLajXp1OQfTEkZnjkUHpCnA== X-Received: by 10.28.102.86 with SMTP id a83mr6201413wmc.76.1489608350631; Wed, 15 Mar 2017 13:05:50 -0700 (PDT) Received: from otyshchenko.kyiv.epam.com (ll-74.141.223.85.sovam.net.ua. [85.223.141.74]) by smtp.gmail.com with ESMTPSA id b130sm1651516wma.17.2017.03.15.13.05.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Mar 2017 13:05:50 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Wed, 15 Mar 2017 22:05:21 +0200 Message-Id: <1489608329-7275-2-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489608329-7275-1-git-send-email-olekstysh@gmail.com> References: <1489608329-7275-1-git-send-email-olekstysh@gmail.com> Cc: sstabellini@kernel.org, vlad.babchuk@gmail.com, al1img@gmail.com, andrii.anisov@gmail.com, olekstysh@gmail.com, andr2000@gmail.com, julien.grall@arm.com, JBeulich@suse.com, joculator@gmail.com Subject: [Xen-devel] [RFC PATCH 1/9] 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 --- 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)