From patchwork Wed Aug 28 14:47:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 19589 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f72.google.com (mail-vb0-f72.google.com [209.85.212.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4193225E58 for ; Wed, 28 Aug 2013 14:48:50 +0000 (UTC) Received: by mail-vb0-f72.google.com with SMTP id f12sf6775486vbg.3 for ; Wed, 28 Aug 2013 07:48:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=6sy2foAQunlNuz23QQU9GO7LiPyPy7PixgPzcENGl3k=; b=ev/seNGw0KSgFhGT0pWkg1pmpxBWxkFBiBsA7io5Ec66LZBp3Fs7+bxhxlyNgWBCGm 3u5qymrqYTZcUtYbc7DV3wG66RTXVeB6pAPN1q3VuXDDxZ/pB5qLFOO+K7T5sO6iUb4a Eh9Z5YQTW9EaaUQAHm8bEPJyifmv5omN3yZqY4CXPcWbpXcqlT5EjerrPyypJRB5xMxk +6SsCKAx6Z5vUV+3eiiZl9hbqvVsxgjc2AtoaCiCe1P0PKubyRuR+u8lrhKQ0jeetv+M 9I/Z9ycjKvouvKPDAtVznRc9y1CJIjZ3zi4K/3yalN41z2baGjJ7U0XhaoCAtjA8euRm t2XA== X-Received: by 10.236.63.165 with SMTP id a25mr10023573yhd.43.1377701329889; Wed, 28 Aug 2013 07:48:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.26.6 with SMTP id h6ls364479qeg.99.gmail; Wed, 28 Aug 2013 07:48:49 -0700 (PDT) X-Received: by 10.220.42.140 with SMTP id s12mr617855vce.33.1377701329763; Wed, 28 Aug 2013 07:48:49 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id dp3si6601844vcb.96.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 28 Aug 2013 07:48:49 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id ia10so4057134vcb.6 for ; Wed, 28 Aug 2013 07:48:49 -0700 (PDT) X-Gm-Message-State: ALoCoQnSBtZ2jKKXFeUOiM6fSFHQnCSqIyp+wxvuKmW6sdgWmC08gelI0VZPD4a1TLZJkOFf4+bv X-Received: by 10.221.55.4 with SMTP id vw4mr311131vcb.37.1377701329684; Wed, 28 Aug 2013 07:48:49 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp359983vcz; Wed, 28 Aug 2013 07:48:49 -0700 (PDT) X-Received: by 10.194.201.131 with SMTP id ka3mr20233788wjc.22.1377701328450; Wed, 28 Aug 2013 07:48:48 -0700 (PDT) Received: from mail-wg0-f49.google.com (mail-wg0-f49.google.com [74.125.82.49]) by mx.google.com with ESMTPS id n6si1840646wiw.4.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 28 Aug 2013 07:48:48 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.49 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.82.49; Received: by mail-wg0-f49.google.com with SMTP id a12so3243579wgh.4 for ; Wed, 28 Aug 2013 07:48:47 -0700 (PDT) X-Received: by 10.194.250.69 with SMTP id za5mr2652381wjc.80.1377701327892; Wed, 28 Aug 2013 07:48:47 -0700 (PDT) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id a8sm5590498wie.6.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 28 Aug 2013 07:48:47 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Cc: stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, patches@linaro.org, andre.przywara@linaro.org, Julien Grall Subject: [PATCH V1 27/29] xen/dts: device_get_reg: cells are 32 bits big endian value Date: Wed, 28 Aug 2013 15:47:41 +0100 Message-Id: <1377701263-3319-28-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1377701263-3319-1-git-send-email-julien.grall@linaro.org> References: <1377701263-3319-1-git-send-email-julien.grall@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Device tree cells are 32-bit big endian value. Use __be32 to avoid confusion later. Also replace get_val call by dt_next_cell. Signed-off-by: Julien Grall Acked-by: Ian Campbell --- xen/common/device_tree.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index b120585..4bc1ce4 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -154,25 +154,11 @@ static bool_t __init device_tree_node_compatible(const void *fdt, int node, return 0; } -static void __init get_val(const u32 **cell, u32 cells, u64 *val) -{ - *val = 0; - - if ( cells > 2 ) - early_panic("dtb value contains > 2 cells\n"); - - while ( cells-- ) - { - *val <<= 32; - *val |= fdt32_to_cpu(*(*cell)++); - } -} - -static void __init device_tree_get_reg(const u32 **cell, u32 address_cells, +static void __init device_tree_get_reg(const __be32 **cell, u32 address_cells, u32 size_cells, u64 *start, u64 *size) { - get_val(cell, address_cells, start); - get_val(cell, size_cells, size); + *start = dt_next_cell(address_cells, cell); + *size = dt_next_cell(size_cells, cell); } void dt_get_range(const __be32 **cell, const struct dt_device_node *np, @@ -327,7 +313,7 @@ static void __init process_memory_node(const void *fdt, int node, const struct fdt_property *prop; int i; int banks; - const u32 *cell; + const __be32 *cell; paddr_t start, size; u32 reg_cells = address_cells + size_cells; @@ -345,7 +331,7 @@ static void __init process_memory_node(const void *fdt, int node, return; } - cell = (const u32 *)prop->data; + cell = (const __be32 *)prop->data; banks = fdt32_to_cpu(prop->len) / (reg_cells * sizeof (u32)); for ( i = 0; i < banks && early_info.mem.nr_banks < NR_MEM_BANKS; i++ ) @@ -396,7 +382,7 @@ static void __init process_multiboot_node(const void *fdt, int node, u32 address_cells, u32 size_cells) { const struct fdt_property *prop; - const u32 *cell; + const __be32 *cell; int nr; struct dt_mb_module *mod; int len; @@ -418,7 +404,7 @@ static void __init process_multiboot_node(const void *fdt, int node, early_panic("fdt: node `%s': `reg` property length is too short\n", name); - cell = (const u32 *)prop->data; + cell = (const __be32 *)prop->data; device_tree_get_reg(&cell, address_cells, size_cells, &mod->start, &mod->size);