From patchwork Wed Nov 5 09:41:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frediano Ziglio X-Patchwork-Id: 40176 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 845C2240A6 for ; Wed, 5 Nov 2014 09:45:56 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id c41sf619008eek.8 for ; Wed, 05 Nov 2014 01:45:55 -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=Nf11SMMf1Riy3eaAMJEHaIDW2MHgLwbb+VDLCUblq9s=; b=BWTkMYj+19m4v6Su4s2blWHEwAdbvjwWzfg6tN11ecldClTpXTdHxFDOfNK5ut1sul f1tUa4j2ucTVoujp7cD9guO0g9qZB3IDQ5QRuKqXStiA9xumBRjmZMTWZsx7EUKbdtIQ 30hTTNNL9vR3YyxfWzcBCMDdr7MJx7fl12RVLMzqrXRe5neLV3oU0HqdezouHrxJjrwY QPFf7IVChcUwlEHLAdcB1jQRTjhImb++iBF9pFWR5MSZQW2hk2+BBN3jcwXxEs3js+Xl dAL1SmTqEEKQjz/9Cvf+8s4baooI+RwL/K0syp00GssBpva0LWmi0cSpsG3NHjQCG/9B 8xmw== X-Gm-Message-State: ALoCoQmiI4PHuDfc2GLwjDLQY0Su4Hke/npB/bVrCL2ltQoVO6VDqJdf03Fnj307B7M+KQd3kTQW X-Received: by 10.152.3.168 with SMTP id d8mr9629130lad.0.1415180755036; Wed, 05 Nov 2014 01:45:55 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.161.234 with SMTP id xv10ls433511lab.99.gmail; Wed, 05 Nov 2014 01:45:54 -0800 (PST) X-Received: by 10.112.173.100 with SMTP id bj4mr66792403lbc.78.1415180754895; Wed, 05 Nov 2014 01:45:54 -0800 (PST) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id ap3si5277778lbc.33.2014.11.05.01.45.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Nov 2014 01:45:54 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id b6so321607lbj.16 for ; Wed, 05 Nov 2014 01:45:54 -0800 (PST) X-Received: by 10.152.5.38 with SMTP id p6mr65526505lap.44.1415180754782; Wed, 05 Nov 2014 01:45:54 -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.184.201 with SMTP id ew9csp256524lbc; Wed, 5 Nov 2014 01:45:53 -0800 (PST) X-Received: by 10.140.42.51 with SMTP id b48mr8517929qga.102.1415180753238; Wed, 05 Nov 2014 01:45:53 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id w8si5487141qag.4.2014.11.05.01.45.52 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 05 Nov 2014 01:45:53 -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 1Xlx8W-0008Eq-V4; Wed, 05 Nov 2014 09:44:20 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xlx8V-0008ER-On for xen-devel@lists.xen.org; Wed, 05 Nov 2014 09:44:19 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id FD/70-01660-371F9545; Wed, 05 Nov 2014 09:44:19 +0000 X-Env-Sender: frediano.ziglio@huawei.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1415180534!11304085!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 30724 invoked from network); 5 Nov 2014 09:44:17 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-12.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 5 Nov 2014 09:44:17 -0000 Received: from 172.24.2.119 (EHLO szxeml450-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id AWQ73659; Wed, 05 Nov 2014 17:42:12 +0800 (CST) Received: from localhost.localdomain (10.47.71.64) by szxeml450-hub.china.huawei.com (10.82.67.193) with Microsoft SMTP Server id 14.3.158.1; Wed, 5 Nov 2014 17:42:04 +0800 From: Frediano Ziglio To: Ian Campbell , Stefano Stabellini , Tim Deegan , Julien Grall , Date: Wed, 5 Nov 2014 09:41:08 +0000 Message-ID: <1415180475-8339-2-git-send-email-frediano.ziglio@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415180475-8339-1-git-send-email-frediano.ziglio@huawei.com> References: <1415180475-8339-1-git-send-email-frediano.ziglio@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.71.64] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.5459F0F5.00BD, 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: e5101f1ef27fd5f5d7e8bae19f2010bf Cc: Zoltan Kiss , zoltan.kiss@huawei.com, xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH v3 1/8] 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.171 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 | 13 ++++++++++--- xen/include/xen/device_tree.h | 11 +++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index f72b2e9..1a886c0 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -160,14 +160,21 @@ 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; } diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 08db8bc..629bfb2 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: length 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