From patchwork Mon Nov 3 16:46:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frediano Ziglio X-Patchwork-Id: 40047 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 23F8521894 for ; Mon, 3 Nov 2014 16:49:50 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id ex7sf2984625wid.8 for ; Mon, 03 Nov 2014 08:49:49 -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=wVGqF91MrVlqRur7AClo9irvT1YrIo7p8/I8/hksxKA=; b=Ma7AW+OJru5xKQDe7D4v4a9FJo8u5sCOz9qIMab/Prk7EWIb3LNG7Iu/HWFya4WbuM xn9EQmkGJoJlcowcDnDv/Sg6r8XVyaj/NnJ0/5BVQXY/2PuNNeUXhMK14QmEClzY3qDf ex9wn4sSKQpzzIwMawjE4EdXStE0Qr3ThSBbory5I34PzvN/EHw9TsiSA6sGXxR6yRV/ HYyRnQ3RB7FzYhnPcKJ3UWXpMPHQQ6fa+wFXQfTSY+z/mzzRGveoL5w9FmNDSL4XfD43 14cdMSUhirVYmNNK2vr7sl/vlP1xg976bgnaKY6bq4ywqF4pFUWvLvuZMIDBJszz805c Ia0Q== X-Gm-Message-State: ALoCoQnFgK9jL82GflA9wBekEtGFrc/olcgkuBiEKuOZPCcV6bbyUatjZHfWctsQuz6+rGL2b3oD X-Received: by 10.112.163.229 with SMTP id yl5mr20329lbb.23.1415033389210; Mon, 03 Nov 2014 08:49:49 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.5.43 with SMTP id cj11ls757450lad.85.gmail; Mon, 03 Nov 2014 08:49:49 -0800 (PST) X-Received: by 10.112.139.165 with SMTP id qz5mr14227231lbb.96.1415033389071; Mon, 03 Nov 2014 08:49:49 -0800 (PST) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id jc4si13184571lbc.137.2014.11.03.08.49.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Nov 2014 08:49:49 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id gq15so9711868lab.21 for ; Mon, 03 Nov 2014 08:49:48 -0800 (PST) X-Received: by 10.112.218.101 with SMTP id pf5mr16078740lbc.46.1415033388924; Mon, 03 Nov 2014 08:49:48 -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.141.34 with SMTP id rl2csp19968lbb; Mon, 3 Nov 2014 08:49:48 -0800 (PST) X-Received: by 10.221.29.134 with SMTP id ry6mr37585746vcb.26.1415033387638; Mon, 03 Nov 2014 08:49:47 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id th7si10287695vcb.32.2014.11.03.08.49.41 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 03 Nov 2014 08:49:47 -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 1XlKms-0000Px-M4; Mon, 03 Nov 2014 16:47:26 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XlKmr-0000Pf-K7 for xen-devel@lists.xen.org; Mon, 03 Nov 2014 16:47:25 +0000 Received: from [193.109.254.147] by server-2.bemta-14.messagelabs.com id 30/64-02984-C91B7545; Mon, 03 Nov 2014 16:47:24 +0000 X-Env-Sender: frediano.ziglio@huawei.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1415033239!12282247!1 X-Originating-IP: [119.145.14.64] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NCA9PiA4MDE5MQ==\n X-StarScan-Received: X-StarScan-Version: 6.12.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 11151 invoked from network); 3 Nov 2014 16:47:23 -0000 Received: from szxga01-in.huawei.com (HELO szxga01-in.huawei.com) (119.145.14.64) by server-4.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 3 Nov 2014 16:47:23 -0000 Received: from 172.24.2.119 (EHLO szxeml424-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CDW69175; Tue, 04 Nov 2014 00:47:17 +0800 (CST) Received: from localhost.localdomain (10.47.77.41) by szxeml424-hub.china.huawei.com (10.82.67.163) with Microsoft SMTP Server id 14.3.158.1; Tue, 4 Nov 2014 00:47:10 +0800 From: Frediano Ziglio To: Ian Campbell , Stefano Stabellini , Tim Deegan , Julien Grall , Date: Mon, 3 Nov 2014 16:46:30 +0000 Message-ID: <1415033196-30529-2-git-send-email-frediano.ziglio@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415033196-30529-1-git-send-email-frediano.ziglio@huawei.com> References: <1415033196-30529-1-git-send-email-frediano.ziglio@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.77.41] X-CFilter-Loop: Reflected Cc: Zoltan Kiss , zoltan.kiss@huawei.com, xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH v2 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.215.48 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