[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1425052528-18995-3-git-send-email-pali.rohar@gmail.com>
Date: Fri, 27 Feb 2015 16:55:28 +0100
From: Pali Rohár <pali.rohar@...il.com>
To: Rob Herring <robherring2@...il.com>,
Russell King <linux@....linux.org.uk>,
Will Deacon <will.deacon@....com>,
Ivaylo Dimitrov <ivo.g.dimitrov.75@...il.com>,
Sebastian Reichel <sre@...ian.org>,
Pavel Machek <pavel@....cz>, Tony Lindgren <tony@...mide.com>,
Andreas Färber <afaerber@...e.de>
Cc: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
Pali Rohár <pali.rohar@...il.com>
Subject: [PATCH v2 2/2] arm: boot: convert ATAG_REVISION to DT revision field
ATAG_REVISION is unsigned number and revision in DT is stored as hexadecimal
string value. It means that it will be correctly parsed by kernel.
Signed-off-by: Pali Rohár <pali.rohar@...il.com>
---
arch/arm/boot/compressed/atags_to_fdt.c | 37 +++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c
index 9448aa0..b23748e 100644
--- a/arch/arm/boot/compressed/atags_to_fdt.c
+++ b/arch/arm/boot/compressed/atags_to_fdt.c
@@ -97,6 +97,39 @@ static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline)
setprop_string(fdt, "/chosen", "bootargs", cmdline);
}
+static void tohexstr(char * str, int size, unsigned int num)
+{
+ int len = 0;
+ int i, tmp;
+
+ if (size < 4) {
+ if (size > 0)
+ str[0] = 0;
+ return;
+ }
+
+ str[len++] = '0';
+ str[len++] = 'x';
+
+ while (len-1 < size && num) {
+ tmp = num % 16;
+ if (tmp >= 10)
+ tmp += 'A';
+ else
+ tmp += '0';
+ str[len++] = tmp;
+ num /= 16;
+ }
+
+ str[len] = 0;
+
+ for (i = 2; i < 2+(len-2)/2; ++i) {
+ tmp = str[i];
+ str[i] = str[len-i+1];
+ str[len-i+1] = tmp;
+ }
+}
+
/*
* Convert and fold provided ATAGs into the provided FDT.
*
@@ -171,6 +204,10 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)
cpu_to_fdt32(atag->u.mem.size);
}
+ } else if (atag->hdr.tag == ATAG_REVISION) {
+ char revision[11];
+ tohexstr(revision, sizeof(revision), atag->u.revision.rev);
+ setprop_string(fdt, "/", "revision", revision);
} else if (atag->hdr.tag == ATAG_INITRD2) {
uint32_t initrd_start, initrd_size;
initrd_start = atag->u.initrd.start;
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists