From patchwork Tue Sep 28 18:18:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rahul Singh X-Patchwork-Id: 12523457 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F5E4C433F5 for ; Tue, 28 Sep 2021 18:21:34 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E001A60ED4 for ; Tue, 28 Sep 2021 18:21:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E001A60ED4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.198245.351630 (Exim 4.92) (envelope-from ) id 1mVHjK-0001kk-4z; Tue, 28 Sep 2021 18:21:26 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 198245.351630; Tue, 28 Sep 2021 18:21:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVHjK-0001kZ-0p; Tue, 28 Sep 2021 18:21:26 +0000 Received: by outflank-mailman (input) for mailman id 198245; Tue, 28 Sep 2021 18:21:25 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVHjJ-0001kM-3o for xen-devel@lists.xenproject.org; Tue, 28 Sep 2021 18:21:25 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id e351fd90-2088-11ec-bcc4-12813bfff9fa; Tue, 28 Sep 2021 18:21:24 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 249EB6D; Tue, 28 Sep 2021 11:21:24 -0700 (PDT) Received: from e109506.cambridge.arm.com (e109506.cambridge.arm.com [10.1.199.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3F6233F793; Tue, 28 Sep 2021 11:21:23 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: e351fd90-2088-11ec-bcc4-12813bfff9fa From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, rahul.singh@arm.com, Andre.Przywara@arm.com, Stefano Stabellini , Julien Grall Subject: [PATCH v3 07/17] xen/device-tree: Add dt_property_read_u32_array helper Date: Tue, 28 Sep 2021 19:18:16 +0100 Message-Id: <89788e202bc91e2bc7f9c3c33eb91ab7478381ee.1632847120.git.rahul.singh@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Based Linux commit a67e9472da423ec47a3586920b526ebaedf25fc3 Import the Linux helper of_property_read_u32_array. This function find and read an array of 32 bit integers from a property. Signed-off-by: Rahul Singh Reviewed-by: Stefano Stabellini Reviewed-by: Bertrand Marquis --- Change in v3: - Modify commit message to include upstream Linux commit-id not stable Linux commit-id Change in v2: Patch introduced in v2 --- xen/include/xen/device_tree.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 1693fb8e8c..3ffe3eb3d2 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -392,6 +392,36 @@ int dt_property_read_variable_u32_array(const struct dt_device_node *np, const char *propname, u32 *out_values, size_t sz_min, size_t sz_max); +/** + * dt_property_read_u32_array - Find and read an array of 32 bit integers + * from a property. + * + * @np: device node from which the property value is to be read. + * @propname: name of the property to be searched. + * @out_values: pointer to return value, modified only if return value is 0. + * @sz: number of array elements to read + * + * Search for a property in a device node and read 32-bit value(s) from + * it. + * + * Return: 0 on success, -EINVAL if the property does not exist, + * -ENODATA if property does not have a value, and -EOVERFLOW if the + * property data isn't large enough. + * + * The out_values is modified only if a valid u32 value can be decoded. + */ +static inline int dt_property_read_u32_array(const struct dt_device_node *np, + const char *propname, + u32 *out_values, size_t sz) +{ + int ret = dt_property_read_variable_u32_array(np, propname, out_values, + sz, 0); + if ( ret >= 0 ) + return 0; + else + return ret; +} + /** * dt_property_read_bool - Check if a property exists * @np: node to get the value