From patchwork Thu Nov 6 10:12:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frediano Ziglio X-Patchwork-Id: 40269 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7EBD624237 for ; Thu, 6 Nov 2014 10:15:05 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id gq15sf1554797lab.6 for ; Thu, 06 Nov 2014 02:15:04 -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=C1br7lZlN4eNULR1C2zf5KBXNSyogMOtsr1xWl6FyBpHP7WjrjeVRS+rBB47539hIH h3Q0SCC1Lbe2ck10DTcDIjMsfpSfuzvZ+O3qix4us4gtWX5i1O5YkFvDZEWApGgEtQUk UdqDHLoaiKyVZk0wTMKTb7WaBmVKElloM2blanSmiulEYvtQHxODiPs35REjGk0D+RuS 936XAJNfVw+0CfutTUqjhdi785/xJi+0TB2g/ezqO7ib7OVEUjPj6Q4bi0dIsqWvV6Cy YpeupWgiC01HnNEIWHqD8RrIeamOHkEumfIhSWxR895HKzEn6UJ7TGQjwbNFSZAhABB1 4F3A== X-Gm-Message-State: ALoCoQmiMvRiezTMkQIL7u10HBF1oy/8a/i375Qw76usnIUDme/n/gwTV0ckZ2P3Wzo75LpkvsY0 X-Received: by 10.194.61.243 with SMTP id t19mr343761wjr.5.1415268903526; Thu, 06 Nov 2014 02:15:03 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.200 with SMTP id x8ls56608lae.76.gmail; Thu, 06 Nov 2014 02:15:03 -0800 (PST) X-Received: by 10.112.137.39 with SMTP id qf7mr3939276lbb.47.1415268903339; Thu, 06 Nov 2014 02:15:03 -0800 (PST) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id wl2si10786988lbb.95.2014.11.06.02.15.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Nov 2014 02:15:03 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by mail-lb0-f170.google.com with SMTP id z12so626352lbi.15 for ; Thu, 06 Nov 2014 02:15:02 -0800 (PST) X-Received: by 10.112.52.37 with SMTP id q5mr4085199lbo.32.1415268902297; Thu, 06 Nov 2014 02:15:02 -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 ew9csp21723lbc; Thu, 6 Nov 2014 02:15:01 -0800 (PST) X-Received: by 10.52.116.36 with SMTP id jt4mr225500vdb.44.1415268899886; Thu, 06 Nov 2014 02:14:59 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id t5si4713187vci.18.2014.11.06.02.14.59 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 06 Nov 2014 02:14:59 -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 1XmK47-0008JN-Pp; Thu, 06 Nov 2014 10:13:19 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XmK46-0008It-0T for xen-devel@lists.xen.org; Thu, 06 Nov 2014 10:13:18 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id 61/7A-14727-DB94B545; Thu, 06 Nov 2014 10:13:17 +0000 X-Env-Sender: frediano.ziglio@huawei.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1415268792!10807855!1 X-Originating-IP: [119.145.14.65] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NSA9PiA3NzQ2Mw==\n X-StarScan-Received: X-StarScan-Version: 6.12.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21150 invoked from network); 6 Nov 2014 10:13:16 -0000 Received: from szxga02-in.huawei.com (HELO szxga02-in.huawei.com) (119.145.14.65) by server-5.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 6 Nov 2014 10:13:16 -0000 Received: from 172.24.2.119 (EHLO szxeml460-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CBY66950; Thu, 06 Nov 2014 18:13:07 +0800 (CST) Received: from localhost.localdomain (10.47.67.20) by szxeml460-hub.china.huawei.com (10.82.67.203) with Microsoft SMTP Server id 14.3.158.1; Thu, 6 Nov 2014 18:12:56 +0800 From: Frediano Ziglio To: Ian Campbell , Stefano Stabellini , Tim Deegan , Julien Grall , Date: Thu, 6 Nov 2014 10:12:05 +0000 Message-ID: <1415268731-6519-2-git-send-email-frediano.ziglio@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415268731-6519-1-git-send-email-frediano.ziglio@huawei.com> References: <1415268731-6519-1-git-send-email-frediano.ziglio@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.67.20] X-CFilter-Loop: Reflected Cc: Zoltan Kiss , zoltan.kiss@huawei.com, xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH v3 1/7] 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.170 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