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.85_2 #1 (Red Hat Linux)) id 1boR57-0004u3-4x for barebox@lists.infradead.org; Mon, 26 Sep 2016 08:16:10 +0000 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Mon, 26 Sep 2016 10:15:43 +0200 Message-Id: <20160926081543.16088-1-u.kleine-koenig@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/RFT] scripts: kwboot: improve reliability on Armada XP To: barebox@lists.infradead.org Cc: Thomas Petazzoni , Kevin Smith , Stefan Roese VGhpcyBpbnRyb2R1Y2VzIHNldmVyYWwgY2hhbmdlcyB0aGF0IGltcHJvdmUgcHVzaGluZyBhIGJv b3QgaW1hZ2UgdmlhClVBUlQgdG8gYW4gQXJtYWRhIFhQIGJhc2VkIG1hY2hpbmUgKE5ldGdlYXIg Uk4gMjEyMCB3aXRoIEJvb3RST00gMS4yMCkuClRoZXkgd2VyZSBmb3VuZCBieSBpbnNwZWN0aW5n IHRoZSBzb3VyY2UsIHRoZSBhY3R1YWwgY29tbXVuaWNhdGlvbiBhbmQKZGlzYXNzZW1ibGluZyB0 aGUgYm9vdCBST00uCgpUaGUgY2hhbmdlcyBhcmU6CiAtIERvbid0IHVzZSBub24tYmxvY2tpbmcg b3Blbi4gVGhpcyBwcmV2ZW50cyB0cnlpbmcgdG8gcmVhZCB0aGUgYW5zd2VyCiAgIGZyb20gdGhl IFNvQyBiZWZvcmUgdGhlIG1hZ2ljIHNlcXVlbmNlIHdhcyBzZW50LgogLSBEb24ndCBmbHVzaCB0 aGUgaW5wdXQgYWZ0ZXIgZWF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QkJYnJlYWs7CisJcmMgPSB0Y2ZsdXNoKHR0eSwg VENJT0ZMVVNIKTsKKwlpZiAocmMpCisJCXJldHVybiByYzsKIAorCWRvIHsKIAkJcmMgPSBrd2Jv b3RfdHR5X3NlbmQodHR5LCBtc2csIDgpOwogCQlpZiAocmMpIHsKIAkJCXVzbGVlcChLV0JPT1Rf TVNHX1JFUV9ERUxBWSAqIDEwMDApOwpAQCAtMjg1LDEyICsyODUsMjAgQEAga3dib290X2Jvb3Rt c2coaW50IHR0eSwgdm9pZCAqbXNnKQogCQl9CiAKIAkJcmMgPSBrd2Jvb3RfdHR5X3JlY3YodHR5 LCAmYywgMSwgS1dCT09UX01TR19SU1BfVElNRU8pOwotCi0JCWt3Ym9vdF9zcGlubmVyKCk7CisJ CXdoaWxlICghcmMgJiYgYyAhPSBOQUspIHsKKwkJCWlmIChjID09ICdcXCcpCisJCQkJa3dib290 X3ByaW50digiXFxcXCIsIGMpOworCQkJZWxzZSBpZiAoaXNwcmludChjKSkKKwkJCQlrd2Jvb3Rf cHJpbnR2KCIlYyIsIGMpOworCQkJZWxzZQorCQkJCWt3Ym9vdF9wcmludHYoIlxceCUwMmhoeCIs IGMpOworCisJCQlyYyA9IGt3Ym9vdF90dHlfcmVjdih0dHksICZjLCAxLCBLV0JPT1RfTVNHX1JT UF9USU1FTyk7CisJCX0KIAogCX0gd2hpbGUgKHJjIHx8IGMgIT0gTkFLKTsKIAotCWt3Ym9vdF9w cmludHYoIlxuIik7CisJa3dib290X3ByaW50digiXG5Hb3QgZXhwZWN0ZWQgTkFLXG4iKTsKIAog CXJldHVybiByYzsKIH0KQEAgLTM0OSw2ICszNTcsNDggQEAga3dib290X3htX21ha2VibG9jayhz dHJ1Y3Qga3dib290X2Jsb2NrICpibG9jaywgY29uc3Qgdm9pZCAqZGF0YSwKIAlyZXR1cm4gbjsK IH0KIAorI2RlZmluZSBtaW4oYSwgYikgKChhKSA8IChiKSA/IChhKSA6IChiKSkKKworc3RhdGlj IGludAora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