From patchwork Tue Jul 25 17:26:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 9862557 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 C33816038F for ; Tue, 25 Jul 2017 17:30:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5DF8286DB for ; Tue, 25 Jul 2017 17:30:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6F40285C4; Tue, 25 Jul 2017 17:30:06 +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 F23C1286E1 for ; Tue, 25 Jul 2017 17:30:04 +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 1da3c0-0008Qx-7b; Tue, 25 Jul 2017 17:27:12 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1da3bz-0008Qj-Gp for xen-devel@lists.xenproject.org; Tue, 25 Jul 2017 17:27:11 +0000 Received: from [85.158.139.211] by server-16.bemta-5.messagelabs.com id C5/87-01712-E6F77795; Tue, 25 Jul 2017 17:27:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNIsWRWlGSWpSXmKPExsVyMfS6k25efXm kwYpWZovvWyYzOTB6HP5whSWAMYo1My8pvyKBNePx8fVsBS9EKpZ/ecvSwDhZoIuRi0NIYDqj xN5/t1i7GDk5WAReskh07IoCSUgI9LNKfOzqZgNJSAjESWxb38oCYVdKvNs4mR3EFhJQkni9c zMTxKTZTBK3dn8Aa2ATMJDY/+4JWJEIUNG9VZOZQGxmAQuJ5uOzwAYJCwRIfPtyG2qzqsTqhU fBbF4BZ4kpi/ZCLZaTuHmukxnE5hRwkdj6aRsLxGJnifXHDjBPYBRYwMiwilG9OLWoLLVI11Q vqSgzPaMkNzEzR9fQwFQvN7W4ODE9NScxqVgvOT93EyMwsBiAYAfjl37nQ4ySHExKorzfdMsj hfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwGtYB5QSLUtNTK9Iyc4AhDpOW4OBREuF9VQuU5i0uS MwtzkyHSJ1itOS4cmXdFyaOKQe2A8lXE/5/YxJiycvPS5US5/UBmScA0pBRmgc3DhaHlxhlpY R5GYEOFOIpSC3KzSxBlX/FKM7BqCTMqw4yhSczrwRu6yugg5iADpozoxTkoJJEhJRUA6OV6dM sJdeFt70cT2cseL5OZNP/R5xeRwwma088GvI/8vUtX7WakuRnc0v8H5Y3L+ucqOox6ZN64+qn f90FK/zf6HGYst63WrE0TlJcJt7P5HbgPTmdUG+mxs695z0eOP6U2XH1SZT18+MsOsmzKmJye Aq28idmi/fU2V8+/8z02r6Lpzunr1NiKc5INNRiLipOBACOhMsPvgIAAA== X-Env-Sender: olekstysh@gmail.com X-Msg-Ref: server-15.tower-206.messagelabs.com!1501003629!90455993!1 X-Originating-IP: [209.85.215.66] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 20772 invoked from network); 25 Jul 2017 17:27:10 -0000 Received: from mail-lf0-f66.google.com (HELO mail-lf0-f66.google.com) (209.85.215.66) by server-15.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 25 Jul 2017 17:27:10 -0000 Received: by mail-lf0-f66.google.com with SMTP id y15so5623491lfd.5 for ; Tue, 25 Jul 2017 10:27:09 -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=2KxiGWY45muZYUJGOi1ABWYiII1S2F+wiHDur3uA1Ug=; b=HUGdjR1Qc5dRoSpVQ58nOUONYVysk7K6AJgk8LPHOuFIkdwR42yf11N+Rf9sPg8ycq Eg7Ytu+oC3E577lG5R2ua1NsUcyJiGmqYUMCkvYqPes0FLU6e3asIZMJe1SzXTxj68Mw 7klxRCoKxqFu0noxsdMHXB21kOFZ7hhqbVm4MnMUnwTGj+WxxtmJINF9RGs/vDv+ePTC 3rdi6yUSMXOxHtyLUrG1TpRBcOUmRyEQo5MC4FDXE+c7OX0vF1/pVZXihHu0rH0+e+1c OrGV1Y6gHc1BCRlxVQi8zct+mu5tYEr5Hqgyn5nsjReDujfL2pQnSqdBJ1Q0q5a1crde HYKQ== 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=2KxiGWY45muZYUJGOi1ABWYiII1S2F+wiHDur3uA1Ug=; b=mxqomQdKJan6Mi3+ZkBU+fCNNNhVAaLK1nFzdRPifwsuX2qiBBf6xH+qmXbj6CEJVq IQyD4Ua5F3tmCgwmA9gidg9lH3HxXAFnmLiyxKibmnMi0ZWnkPXyyOHD8C43lhzDGwwg ZkSvD6YQ4UQNDRYL3pjgNXXz0WebRNKQEPzVSOZhBP6NMHUQpRfcedaSsxIy6mC404jO DQ1n2OchN0hTet8irhQpVe2h4x3StokwyDce3XbhMmtAADTYqG60CEHjbE3LpKlNohUD 6wRjf2mQs94G85Y47olX6RxGKSQLyu9Gu0dn8V5dhe4wjOM6RVX57Q4tLLvSMOwj7w0x QCCw== X-Gm-Message-State: AIVw112RloexHtvYd8DXg+3MjITDtTgu1VLYfDJklUG12+HZwLoZhZo/ TYNiQaCaL+QfPyov X-Received: by 10.25.213.83 with SMTP id m80mr6782695lfg.177.1501003629033; Tue, 25 Jul 2017 10:27:09 -0700 (PDT) Received: from otyshchenko.kyiv.epam.com (ll-59.209.223.85.sovam.net.ua. [85.223.209.59]) by smtp.gmail.com with ESMTPSA id v145sm411748lfa.21.2017.07.25.10.27.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 10:27:08 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Tue, 25 Jul 2017 20:26:43 +0300 Message-Id: <1501003615-15274-2-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501003615-15274-1-git-send-email-olekstysh@gmail.com> References: <1501003615-15274-1-git-send-email-olekstysh@gmail.com> Cc: Oleksandr Tyshchenko Subject: [Xen-devel] [PATCH v2 01/13] 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 Changes in v2: - --- 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)