From patchwork Fri Feb 27 15:55:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 5901721 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 44E4C9F38E for ; Fri, 27 Feb 2015 15:58:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 64B5720219 for ; Fri, 27 Feb 2015 15:58:48 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A36A22024F for ; Fri, 27 Feb 2015 15:58:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YRNH9-0005BW-K9; Fri, 27 Feb 2015 15:56:27 +0000 Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YRNGs-0004pg-UN for linux-arm-kernel@lists.infradead.org; Fri, 27 Feb 2015 15:56:11 +0000 Received: by widex7 with SMTP id ex7so1129357wid.1 for ; Fri, 27 Feb 2015 07:55:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=73XiqwRf76dMV+s2Wmn6ipP4oukYYt9CdsZKP82toEw=; b=oYWcD3lu4k3XRjAD4JIA6z0RUOvdHgHZ8a3AOIyemS+5lt/4xReqjm8giGrDItbgh3 ekOlXcwZXzoniwbo5bwH+dC5R6FW432+6xlXfR1ejHWUrlUqDrLr0tOa3+W9qNwpNPxZ +pNNPKBvp8LAtmA1YO1xOxQBTDwo5eeZXU/ljNveFxCv77fZfBSeBGiS1BUJtCfj8D75 C6nGPALDEk/hOdfHsi/XQZsRQ6qzTWupiWBZbZzXRkWLqjRJcZTVilc8NfpvTHpoxhhd Mv+h2IVRbWJz4pcmgJiV6zJOB90eiTQcUtkoV3TBIoSb2Oc2QZTwaPKJLpOSqUe7jVKu /eew== X-Received: by 10.180.98.167 with SMTP id ej7mr7723925wib.87.1425052548847; Fri, 27 Feb 2015 07:55:48 -0800 (PST) Received: from Pali-Latitude.kolej.mff.cuni.cz (pali.kolej.mff.cuni.cz. [78.128.193.202]) by mx.google.com with ESMTPSA id fs8sm3369310wib.8.2015.02.27.07.55.45 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Feb 2015 07:55:46 -0800 (PST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Rob Herring , Russell King , Will Deacon , Ivaylo Dimitrov , Sebastian Reichel , Pavel Machek , Tony Lindgren , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [PATCH v2 2/2] arm: boot: convert ATAG_REVISION to DT revision field Date: Fri, 27 Feb 2015 16:55:28 +0100 Message-Id: <1425052528-18995-3-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1425052528-18995-1-git-send-email-pali.rohar@gmail.com> References: <201502271645.58765@pali> <1425052528-18995-1-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150227_075611_148388_BD274A07 X-CRM114-Status: GOOD ( 15.20 ) X-Spam-Score: -0.8 (/) Cc: "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , =?UTF-8?q?Pali=20Roh=C3=A1r?= X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;