From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b4oM5-0000ZM-DA for barebox@lists.infradead.org; Mon, 23 May 2016 11:49:06 +0000 From: =?UTF-8?q?Ulrich=20=C3=96lmann?= Date: Mon, 23 May 2016 13:48:41 +0200 Message-Id: <1464004122-15815-2-git-send-email-u.oelmann@pengutronix.de> In-Reply-To: <1464004122-15815-1-git-send-email-u.oelmann@pengutronix.de> References: <1464004122-15815-1-git-send-email-u.oelmann@pengutronix.de> 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" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 1/2] images: write checksum into barebox header To: Barebox List RnJvbTogSmFuIEx1ZWJiZSA8amx1QHBlbmd1dHJvbml4LmRlPgoKU2lnbmVkLW9mZi1ieTogSmFu IEx1ZWJiZSA8amx1QHBlbmd1dHJvbml4LmRlPgpTaWduZWQtb2ZmLWJ5OiBVbHJpY2ggw5ZsbWFu biA8dS5vZWxtYW5uQHBlbmd1dHJvbml4LmRlPgotLS0KIGltYWdlcy9NYWtlZmlsZSAgICAgIHwg ICAzICstCiBpbmNsdWRlL2ZpbGV0eXBlLmggICB8ICAgMiArCiBzY3JpcHRzLy5naXRpZ25vcmUg ICB8ICAgMSArCiBzY3JpcHRzL01ha2VmaWxlICAgICB8ICAgMSArCiBzY3JpcHRzL2JhcmVib3hj cmMuYyB8IDIxOSArKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysr KysrKysKIDUgZmlsZXMgY2hhbmdlZCwgMjI1IGluc2VydGlvbnMoKyksIDEgZGVsZXRpb24oLSkK IGNyZWF0ZSBtb2RlIDEwMDY0NC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ocCArIDEpKSB7CisJCQlmcHJpbnRmKHN0ZGVyciwgImVt YmVkZGVkIGNoZWNrc3VtIGlzIGZhdWx0eVxuIik7CisJCQlyZXQgPSBFWF9DSEVDS1NVTV9GQVVM VFk7CisJCX0KKwl9IGVsc2UgeworCQlpZiAoZndyaXRlKCZjcmMsIHNpemVvZih1aW50MzJfdCks IDEsIGltYWdlKSAhPSAxKSB7CisJCQlwZXJyb3IoImZ3cml0ZSIpOworCQkJcmV0ID0gRVhfSU9f RVJST1I7CisJCX0KKwl9CisKK291dDoKKwlmcmVlKGJ1Zik7CisJcmV0dXJuIHJldDsKK30KKwor aW50IG1haW4oaW50IGFyZ2MsIGNoYXIgKmFyZ3ZbXSkKK3sKKwlGSUxFICppbWFnZTsKKwlib29s IGNoZWNrID0gZmFsc2U7CisJYm9vbCBmb3JjZSA9IGZhbHNlOworCWludCBvcHQ7CisJaW50IHJl dDsKKwlvZmZfdCBzaXplOworCisJd2hpbGUoKG9wdCA9IGdldG9wdChhcmdjLCBhcmd2LCAiY2Yi KSkgIT0gLTEpIHsKKwkJc3dpdGNoIChvcHQpIHsKKwkJY2FzZSAnYyc6CisJCQljaGVjayA9IHRy dWU7CisJCQlicmVhazsKKwkJY2FzZSAnZic6CisJCQlmb3JjZSA9IHRydWU7CisJCQlicmVhazsK KwkJfQorCX0KKworCWlmIChvcHRpbmQgPj0gYXJnYykgeworCQl1c2FnZShhcmd2WzBdKTsKKwkJ ZXhpdChFWF9XUk9OR19VU0FHRSk7CisJfQorCisJaW1hZ2UgPSBmb3Blbihhcmd2W29wdGluZF0s IGNoZWNrID8gInIiIDogInIrIik7CisJaWYgKGltYWdlID09IE5VTEwpIHsKKwkJcGVycm9yKCJm b3BlbiIpOworCQlleGl0KEVYX0lPX0VSUk9SKTsKKwl9CisKKwlpZiAoZnNlZWtvKGltYWdlLCAw LCBTRUVLX0VORCkgPT0gLTEpIHsKKwkJcGVycm9yKCJmc2Vla28iKTsKKwkJZXhpdChFWF9JT19F UlJ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