From patchwork Fri Feb 8 23:17:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 2119071 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 9B19DDFE75 for ; Fri, 8 Feb 2013 23:26:11 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U3xIS-0006Ah-UE; Fri, 08 Feb 2013 23:23:56 +0000 Received: from ducie-dc1.codethink.co.uk ([37.128.190.40]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1U3xCr-0001Ca-Es for linux-arm-kernel@lists.infradead.org; Fri, 08 Feb 2013 23:18:19 +0000 Received: by ducie-dc1.codethink.co.uk (Postfix, from userid 1002) id 2B23D46C60E; Fri, 8 Feb 2013 23:18:04 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on ducie-dc1.codethink.co.uk X-Spam-Level: X-Spam-Status: No, score=-2.9 required=6.0 tests=ALL_TRUSTED,BAYES_00 autolearn=unavailable version=3.3.2 Received: from rainbowdash.ducie.codethink.co.uk (rainbowdash.dyn.ducie.codethink.co.uk [192.168.24.216]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTPS id 9F63746C641; Fri, 8 Feb 2013 23:18:00 +0000 (GMT) Received: from ben by rainbowdash.ducie.codethink.co.uk with local (Exim 4.80) (envelope-from ) id 1U3xCj-0006Xs-JT; Fri, 08 Feb 2013 23:18:01 +0000 From: Ben Dooks To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 11/17] ARM: fixup atags to be endian agnostic Date: Fri, 8 Feb 2013 23:17:41 +0000 Message-Id: <1360365467-25056-12-git-send-email-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1360365467-25056-1-git-send-email-ben.dooks@codethink.co.uk> References: <1360365467-25056-1-git-send-email-ben.dooks@codethink.co.uk> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130208_181810_089302_A79E08F3 X-CRM114-Status: GOOD ( 17.92 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Ben Dooks X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Use the atag32_to_cpu() function to allow the main atag handling code to be agnostic of any endian configuration. Signed-of-by: Ben Dooks --- arch/arm/kernel/atags_parse.c | 51 +++++++++++++++++++++-------------------- arch/arm/kernel/atags_proc.c | 6 ++--- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/arch/arm/kernel/atags_parse.c b/arch/arm/kernel/atags_parse.c index 14512e6..cffcbc2 100644 --- a/arch/arm/kernel/atags_parse.c +++ b/arch/arm/kernel/atags_parse.c @@ -43,19 +43,19 @@ static struct { struct tag_mem32 mem; struct tag_header hdr3; } default_tags __initdata = { - { tag_size(tag_core), ATAG_CORE }, - { 1, PAGE_SIZE, 0xff }, - { tag_size(tag_mem32), ATAG_MEM }, - { MEM_SIZE }, - { 0, ATAG_NONE } + { atag32_to_cpu(tag_size(tag_core)), atag32_to_cpu(ATAG_CORE) }, + { atag32_to_cpu(1), atag32_to_cpu(PAGE_SIZE), atag32_to_cpu(0xff) }, + { atag32_to_cpu(tag_size(tag_mem32)), atag32_to_cpu(ATAG_MEM) }, + { atag32_to_cpu(MEM_SIZE) }, + { atag32_to_cpu(0), atag32_to_cpu(ATAG_NONE) } }; static int __init parse_tag_core(const struct tag *tag) { - if (tag->hdr.size > 2) { - if ((tag->u.core.flags & 1) == 0) + if (atag32_to_cpu(tag->hdr.size) > 2) { + if ((atag32_to_cpu(tag->u.core.flags) & 1) == 0) root_mountflags &= ~MS_RDONLY; - ROOT_DEV = old_decode_dev(tag->u.core.rootdev); + ROOT_DEV = old_decode_dev(atag32_to_cpu(tag->u.core.rootdev)); } return 0; } @@ -64,7 +64,7 @@ __tagtable(ATAG_CORE, parse_tag_core); static int __init parse_tag_mem32(const struct tag *tag) { - return arm_add_memory(tag->u.mem.start, tag->u.mem.size); + return arm_add_memory(atag32_to_cpu(tag->u.mem.start), atag32_to_cpu(tag->u.mem.size)); } __tagtable(ATAG_MEM, parse_tag_mem32); @@ -91,13 +91,14 @@ __tagtable(ATAG_VIDEOTEXT, parse_tag_videotext); static int __init parse_tag_ramdisk(const struct tag *tag) { extern int rd_size, rd_image_start, rd_prompt, rd_doload; + unsigned int flags = atag32_to_cpu(tag->u.ramdisk.flags); - rd_image_start = tag->u.ramdisk.start; - rd_doload = (tag->u.ramdisk.flags & 1) == 0; - rd_prompt = (tag->u.ramdisk.flags & 2) == 0; + rd_image_start = atag32_to_cpu(tag->u.ramdisk.start); + rd_doload = (flags & 1) == 0; + rd_prompt = (flags & 2) == 0; - if (tag->u.ramdisk.size) - rd_size = tag->u.ramdisk.size; + if (atag32_to_cpu(tag->u.ramdisk.size)) + rd_size = atag32_to_cpu(tag->u.ramdisk.size); return 0; } @@ -107,8 +108,8 @@ __tagtable(ATAG_RAMDISK, parse_tag_ramdisk); static int __init parse_tag_serialnr(const struct tag *tag) { - system_serial_low = tag->u.serialnr.low; - system_serial_high = tag->u.serialnr.high; + system_serial_low = atag32_to_cpu(tag->u.serialnr.low); + system_serial_high = atag32_to_cpu(tag->u.serialnr.high); return 0; } @@ -116,7 +117,7 @@ __tagtable(ATAG_SERIAL, parse_tag_serialnr); static int __init parse_tag_revision(const struct tag *tag) { - system_rev = tag->u.revision.rev; + system_rev = atag32_to_cpu(tag->u.revision.rev); return 0; } @@ -150,7 +151,7 @@ static int __init parse_tag(const struct tag *tag) struct tagtable *t; for (t = &__tagtable_begin; t < &__tagtable_end; t++) - if (tag->hdr.tag == t->tag) { + if (atag32_to_cpu(tag->hdr.tag) == t->tag) { t->parse(tag); break; } @@ -164,17 +165,17 @@ static int __init parse_tag(const struct tag *tag) */ static void __init parse_tags(const struct tag *t) { - for (; t->hdr.size; t = tag_next(t)) + for_each_tag(t, t) if (!parse_tag(t)) printk(KERN_WARNING "Ignoring unrecognised tag 0x%08x\n", - t->hdr.tag); + atag32_to_cpu(t->hdr.tag)); } static void __init squash_mem_tags(struct tag *tag) { - for (; tag->hdr.size; tag = tag_next(tag)) - if (tag->hdr.tag == ATAG_MEM) + for_each_tag(tag, tag) + if (tag->hdr.tag == atag32_to_cpu(ATAG_MEM)) tag->hdr.tag = ATAG_NONE; } @@ -213,10 +214,10 @@ struct machine_desc * __init setup_machine_tags(phys_addr_t __atags_pointer, * If we have the old style parameters, convert them to * a tag list. */ - if (tags->hdr.tag != ATAG_CORE) + if (tags->hdr.tag != atag32_to_cpu(ATAG_CORE)) convert_to_tag_list(tags); #endif - if (tags->hdr.tag != ATAG_CORE) { + if (tags->hdr.tag != atag32_to_cpu(ATAG_CORE)) { early_print("Warning: Neither atags nor dtb found\n"); tags = (struct tag *)&default_tags; } @@ -224,7 +225,7 @@ struct machine_desc * __init setup_machine_tags(phys_addr_t __atags_pointer, if (mdesc->fixup) mdesc->fixup(tags, &from, &meminfo); - if (tags->hdr.tag == ATAG_CORE) { + if (tags->hdr.tag == atag32_to_cpu(ATAG_CORE)) { if (meminfo.nr_banks != 0) squash_mem_tags(tags); save_atags(tags); diff --git a/arch/arm/kernel/atags_proc.c b/arch/arm/kernel/atags_proc.c index 42a1a14..50e7e9c 100644 --- a/arch/arm/kernel/atags_proc.c +++ b/arch/arm/kernel/atags_proc.c @@ -46,18 +46,18 @@ static int __init init_atags_procfs(void) struct buffer *b; size_t size; - if (tag->hdr.tag != ATAG_CORE) { + if (tag->hdr.tag != atag32_to_cpu(ATAG_CORE)) { printk(KERN_INFO "No ATAGs?"); return -EINVAL; } - for (; tag->hdr.size; tag = tag_next(tag)) + for_each_tag(tag, tag) ; /* include the terminating ATAG_NONE */ size = (char *)tag - atags_copy + sizeof(struct tag_header); - WARN_ON(tag->hdr.tag != ATAG_NONE); + WARN_ON(tag->hdr.tag != atag32_to_cpu(ATAG_NONE)); b = kmalloc(sizeof(*b) + size, GFP_KERNEL); if (!b)