From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from inx.pm.waw.pl ([195.116.170.130]) by canuck.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1PUogP-0001fj-6W for barebox@lists.infradead.org; Mon, 20 Dec 2010 22:58:23 +0000 From: Krzysztof Halasa In-Reply-To: (Krzysztof Halasa's message of "Mon, 20 Dec 2010 23:30:03 +0100") Date: Mon, 20 Dec 2010 23:58:11 +0100 Message-ID: MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: barebox-bounces@lists.infradead.org Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 6] ARM: support big/little endian switching in "bootz". To: barebox@lists.infradead.org QVJNOiBzdXBwb3J0IGJpZy9saXR0bGUgZW5kaWFuIHN3aXRjaGluZyBpbiAiYm9vdHoiLgpQZXJo YXBzIG9uZSBzaG91bGQgbWFrZSB0aGlzIGNvbmRpdGlvbmFsPyBNb3N0bHkgZm9yIGJpZy1lbmRp YW4KQmFyZWJveCBsb2FkaW5nIGxpdHRsZS1lbmRpYW4gKGUuZy4gYXJtZWwgRGViaWFuKSBMaW51 eC4KClNpZ25lZC1vZmYtYnk6IEtyenlzenRvZiBIYcWCYXNhIDxraGNAcG0ud2F3LnBsPgoKZGlm ZiAtLWdpdCBhL2FyY2gvYXJtL2xpYi9hcm1saW51eC5jIGIvYXJjaC9hcm0vbGliL2FybWxpbnV4 LmMKaW5kZXggZjgyNmRhNi4uNGQxYzc1NyAxMDA2NDQKLS0tIGEvYXJjaC9hcm0vbGliL2FybWxp bnV4LmMKKysrIGIvYXJjaC9hcm0vbGliL2FybWxpbnV4LmMKQEAgLTQxLDYgKzQxLDcgQEAKICNp bmNsdWRlIDxhc20vc2V0dXAuaD4KICNpbmNsdWRlIDxhc20vYmFyZWJveC1hcm0uaD4KICNpbmNs dWRlIDx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