From patchwork Mon Nov 3 10:12:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frediano Ziglio X-Patchwork-Id: 40002 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A373C20560 for ; Mon, 3 Nov 2014 10:18:53 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id q1sf6051819lam.8 for ; Mon, 03 Nov 2014 02:18:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=rHHe7SxjPS2iSvKEfneQYYhpDBpIKNvgbQpLzN3PeFo=; b=RDSQ87OiA1XtO1vvxvuxQj+EK9gWHeWp1QBr5Z/r7AQUj5+YhZ86osCRFDuu1eg+r4 7wnMJh5KtkWxE/bt3a/pw/ur2chK4QbOiAfKFLRIaKzOZCwwL7jNVq0LVyHMxsiV9lg4 B2pIVsywfJSWXBykti1PwiszfDOO4JukKcK0/rDnLrEhNw3DLdReuNSGEQrI6EWINRc8 4EABPSu+BdkkRT7yWysMN0hA+ova4jla28ZKr6C1gtpzzZC02Z/191VZnE+Wt7b61PI2 P+WqcXruBn/FJFTOhm9ghWzrG93J1f9+kbR4AoQOzllp7NQNUaJYsuDWoBBTmgqa7q9z PXDQ== X-Gm-Message-State: ALoCoQnd1pot0UphWUEiy53EQCHlBptQ4Kfl2qk3QfTv2HyeoTfH+uuv7sOhPFYTyks3GgSpzUNJ X-Received: by 10.112.217.102 with SMTP id ox6mr215040lbc.19.1415009932001; Mon, 03 Nov 2014 02:18:52 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.227 with SMTP id i3ls579623lae.28.gmail; Mon, 03 Nov 2014 02:18:51 -0800 (PST) X-Received: by 10.152.30.33 with SMTP id p1mr48757143lah.78.1415009931856; Mon, 03 Nov 2014 02:18:51 -0800 (PST) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id b6si31747919lae.131.2014.11.03.02.18.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Nov 2014 02:18:51 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id n15so1049145lbi.34 for ; Mon, 03 Nov 2014 02:18:51 -0800 (PST) X-Received: by 10.112.52.37 with SMTP id q5mr14026145lbo.32.1415009931762; Mon, 03 Nov 2014 02:18:51 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp212850lbz; Mon, 3 Nov 2014 02:18:50 -0800 (PST) X-Received: by 10.140.22.81 with SMTP id 75mr1639217qgm.19.1415009930001; Mon, 03 Nov 2014 02:18:50 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id q5si29013631qat.17.2014.11.03.02.18.47 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 03 Nov 2014 02:18:49 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XlEhu-0008O6-1H; Mon, 03 Nov 2014 10:17:54 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XlEdo-0008AF-9A for xen-devel@lists.xen.org; Mon, 03 Nov 2014 10:13:40 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id 16/F3-23865-35557545; Mon, 03 Nov 2014 10:13:39 +0000 X-Env-Sender: frediano.ziglio@huawei.com X-Msg-Ref: server-8.tower-31.messagelabs.com!1415009614!11249432!1 X-Originating-IP: [119.145.14.66] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NiA9PiA4NTI3\n X-StarScan-Received: X-StarScan-Version: 6.12.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 3946 invoked from network); 3 Nov 2014 10:13:38 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-8.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 3 Nov 2014 10:13:38 -0000 Received: from 172.24.2.119 (EHLO szxeml403-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id AWO17482; Mon, 03 Nov 2014 18:13:33 +0800 (CST) Received: from localhost.localdomain (10.47.73.48) by szxeml403-hub.china.huawei.com (10.82.67.35) with Microsoft SMTP Server id 14.3.158.1; Mon, 3 Nov 2014 18:13:27 +0800 From: Frediano Ziglio To: Ian Campbell , Stefano Stabellini , Tim Deegan , Julien Grall , Date: Mon, 3 Nov 2014 10:12:01 +0000 Message-ID: <1415009522-6344-10-git-send-email-frediano.ziglio@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415009522-6344-1-git-send-email-frediano.ziglio@huawei.com> References: <1415009522-6344-1-git-send-email-frediano.ziglio@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.73.48] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.5457554E.003E, ss=1, re=0.001, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: fc3fc13d539b46014e9369b4c5746efa X-Mailman-Approved-At: Mon, 03 Nov 2014 10:17:48 +0000 Cc: Zoltan Kiss , zoltan.kiss@huawei.com, xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH 09/10] xen/device_tree: Add new helper to read arrays from a DTB X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: frediano.ziglio@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: From: Zoltan Kiss Signed-off-by: Zoltan Kiss Reviewed-by: Julien Grall --- xen/common/device_tree.c | 14 ++++++++++---- xen/include/xen/device_tree.h | 11 +++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index f72b2e9..e97c28b 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -160,19 +160,25 @@ const void *dt_get_property(const struct dt_device_node *np, bool_t dt_property_read_u32(const struct dt_device_node *np, const char *name, u32 *out_value) { - u32 len; + return dt_property_read_u32_array(np, name, out_value, 1); +} + +bool_t dt_property_read_u32_array(const struct dt_device_node *np, + const char *name, u32 *out_value, u16 out_len) +{ + u32 len, i; const __be32 *val; val = dt_get_property(np, name, &len); - if ( !val || len < sizeof(*out_value) ) + if ( !val || len < sizeof(*out_value) * out_len ) return 0; - *out_value = be32_to_cpup(val); + for ( i = 0; i < out_len; i++, val++ ) + out_value[i] = be32_to_cpup(val); return 1; } - bool_t dt_property_read_u64(const struct dt_device_node *np, const char *name, u64 *out_value) { diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 08db8bc..5fcd9c4 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -346,6 +346,17 @@ const struct dt_property *dt_find_property(const struct dt_device_node *np, bool_t dt_property_read_u32(const struct dt_device_node *np, const char *name, u32 *out_value); /** + * dt_property_read_u32_array - Helper to read a u32 array property. + * @np: node to get the value + * @name: name of the property + * @out_value: pointer to return value + * @out_len: lenght of the array + * + * Return true if get the desired value. + */ +bool_t dt_property_read_u32_array(const struct dt_device_node *np, + const char *name, u32 *out_value, u16 out_len); +/** * dt_property_read_u64 - Helper to read a u64 property. * @np: node to get the value * @name: name of the property