From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V1ZpV-0005W6-T5 for barebox@lists.infradead.org; Tue, 23 Jul 2013 10:29:02 +0000 From: Sascha Hauer Subject: [PATCH 4/4] UBI: reimport UBI from Linux v3.10 Date: Tue, 23 Jul 2013 12:28:02 +0200 Message-Id: <1374575282-9592-5-git-send-email-s.hauer@pengutronix.de> In-Reply-To: <1374575282-9592-1-git-send-email-s.hauer@pengutronix.de> References: <1374575282-9592-1-git-send-email-s.hauer@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 To: barebox@lists.infradead.org VGhpcyBpcyBhIGZyZXNoIFVCSSBpbXBvcnQgZnJvbSBMaW51eCB2My4xMAoKVGhpcyBpcyBkb25l IG1haW5seSB0byBnZXQgZmFzdG1hcCBzdXBwb3J0LgoKVGhpcyB3YXMgdGVzdGVkIHdpdGggdGhl IGkuTVggbmFuZCBkcml2ZXIsIHRoZSBNWFMgbmFuZCBkcml2ZXIgYW5kCm9uIENGSSBOT1IgZmxh c2guCgpTaWduZWQtb2ZmLWJ5OiBTYXNjaGEgSGF1ZXIgPHMuaGF1ZXJAcGVuZ3V0cm9uaXguZGU+ Ci0tLQogY29tbWFuZHMvS2NvbmZpZyAgICAgICAgICAgICAgICB8ICAgIDYgKy0KIGNvbW1hbmRz L3ViaS5jICAgICAgICAgICAgICAgICAgfCAgICAyICstCiBkcml2ZXJzL210ZC9NYWtlZmlsZSAg ICAgICAgICAgIHwgICAgMiArLQogZHJpdmVycy9tdGQvdWJpL0tjb25maWcgICAgICAgICB8ICAg ODEgKysKIGRyaXZlcnMvbXRkL3ViaS9NYWtlZmlsZSAgICAgICAgfCAgICA1ICsKIGRyaXZlcnMv bXRkL3ViaS9hdHRhY2guYyAgICAgICAgfCAxNzI4ICsrKysrKysrKysrKysrKysrKysrKysrKysr KysrKysrKysKIGRyaXZlcnMvbXRkL3ViaS9idWlsZC5jICAgICAgICAgfCAgNjc4ICsrKysrKysr KysrKysrCiBkcml2ZXJzL210ZC91YmkvY2Rldi5jICAgICAgICAgIHwgIDI1MyArKysrKwogZHJp dmVycy9tdGQvdWJpL2RlYnVnLmMgICAgICAgICB8ICAyMTQgKysrKysKIGRyaXZlcnMvbXRkL3Vi aS9kZWJ1Zy5oICAgICAgICAgfCAgMTI5ICsrKwogZHJpdmVycy9tdGQvdWJpL2ViYS5jICAgICAg ICAgICB8IDEzNTIgKysrKysrKysrKysrKysrKysrKysrKysrKysrCiBkcml2ZXJzL210ZC91Ymkv ZmFzdG1hcC5jICAgICAgIHwgMTUxNCArKysrKysrKysrKysrKysrKysrKysrKysrKysrKysKIGRy aXZlcnMvbXRkL3ViaS9pby5jICAgICAgICAgICAgfCAxNDE4ICsrKysrKysrKysrKysrKysrKysr KysrKysrKysKIGRyaXZlcnMvbXRkL3ViaS9rYXBpLmMgICAgICAgICAgfCAgNTc0ICsrKysrKysr KysrKwogZHJpdmVycy9tdGQvdWJpL21pc2MuYyAgICAgICAgICB8ICAxNTMgKysrCiBkcml2ZXJz L210ZC91YmkvdWJpLWJhcmVib3guaCAgIHwgICA3MSArKwogZHJpdmVycy9tdGQvdWJpL3ViaS5o ICAgICAgICAgICB8ICA5NzQgKysrKysrKysrKysrKysrKysrKwogZHJpdmVycy9tdGQvdWJpL3Vw ZC5jICAgICAgICAgICB8ICA0NDMgKysrKysrKysrCiBkcml2ZXJzL210ZC91Ymkvdm10LmMgICAg ICAgICAgIHwgIDYxOCArKysrKysrKysrKysrCiBkcml2ZXJzL210ZC91YmkvdnRibC5jICAgICAg ICAgIHwgIDg1OSArKysrKysrKysrKysrKysrKwogZHJp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QkJaWYgKGF2LT52b2xfdHlwZSA9PSBVQklfU1RBVElDX1ZPTFVNRSkgeworCQkJCWlm IChhZWItPmxudW0gPj0gYXYtPnVzZWRfZWJzKSB7CisJCQkJCXViaV9lcnIoImJhZCBsbnVtIG9y IHVzZWRfZWJzIik7CisJCQkJCWdvdG8gYmFkX2FlYjsKKwkJCQl9CisJCQl9IGVsc2UgeworCQkJ CWlmIChhdi0+dXNlZF9lYnMgIT0gMCkgeworCQkJCQl1YmlfZXJyKCJub24temVybyB1c2VkX2Vi cyIpOworCQkJCQlnb3RvIGJhZF9hZWI7CisJCQkJfQorCQkJfQorCisJCQlpZiAoYWViLT5sbnVt ID4gYXYtPmhpZ2hlc3RfbG51bSkgeworCQkJCXViaV9lcnIoImluY29ycmVjdCBoaWdoZXN0X2xu dW0gb3IgbG51bSIpOworCQkJCWdvdG8gYmFkX2FlYjsKKwkJCX0KKwkJfQorCisJCWlmIChhdi0+ bGViX2NvdW50ICE9IGxlYl9jb3VudCkgeworCQkJdWJpX2VycigiYmFkIGxlYl9jb3VudCwgJWQg b2JqZWN0cyBpbiB0aGUgdHJlZSIsCisJCQkJbGViX2NvdW50KTsKKwkJCWdvdG8gYmFkX2F2Owor CQl9CisKKwkJaWYgKCFsYXN0X2FlYikKKwkJCWNvbnRpbnVlOworCisJCWFlYiA9IGxhc3RfYWVi OworCisJCWlmIChhZWItPmxudW0gIT0gYXYtPmhpZ2hlc3RfbG51bSkgeworCQkJdWJpX2Vycigi YmFkIGhpZ2hlc3RfbG51bSIpOworCQkJZ290byBiYWRfYWViOworCQl9CisJfQorCisJaWYgKHZv bHNfZm91bmQgIT0gYWktPnZvbHNfZm91bmQpIHsKKwkJdWJpX2VycigiYmFkIGFpLT52b2xzX2Zv dW5kICVkLCBzaG91bGQgYmUgJWQiLAorCQkJYWktPnZvbHNfZm91bmQsIHZvbHNfZm91bmQpOwor CQlnb3RvIG91dDsKKwl9CisKKwkvKiBDaGVjayB0aGF0IGF0dGFjaGluZyBp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ERUJVR19IX18KKworI2lu Y2x1ZGUgPHN0ZGxpYi5oPgorCit2b2lkIHViaV9kdW1wX2ZsYXNoKHN0cnVjdCB1YmlfZGV2aWNl ICp1YmksIGludCBwbnVtLCBpbnQgb2Zmc2V0LCBpbnQgbGVuKTsKK3ZvaWQgdWJpX2R1bXBfZWNf aGRyKGNvbnN0IHN0cnVjdCB1YmlfZWNfaGRyICplY19oZHIpOwordm9pZCB1YmlfZHVtcF92aWRf aGRyKGNvbnN0IHN0cnVjdCB1YmlfdmlkX2hkciAqdmlkX2hkcik7CisKKyNkZWZpbmUgdWJpX2Fz c2VydChleHByKSAgZG8geyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgXAorCWlmICh1bmxpa2VseSghKGV4cHIpKSkgeyAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIFwKKwkJcHJfY3JpdCgiVUJJIGFzc2VydCBmYWlsZWQgaW4g JXMgYXQgJXVcbiIsICAgICAgICAgIFwKKwkJICAgICAgIF9fZnVuY19fLCBfX0xJTkVfXyk7ICAg ICAgICAgICAgICAgICAgICBcCisJCWR1bXBfc3RhY2soKTsgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICBcCisJfSAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorfSB3aGlsZSAoMCkK KworI2RlZmluZSB1YmlfZGJnX3ByaW50X2hleF9kdW1wKGwsIHBzLCBwdCwgciwgZywgYiwgbGVu LCBhKSAgICAgICAgICAgICAgICAgICBcCisJCXByaW50X2hleF9kdW1wKGwsIHBzLCBwdCwgciwg ZywgYiwgbGVuLCBhKQorCisjZGVmaW5lIHViaV9kYmdfbXNnKHR5cGUsIGZtdCwgLi4uKSBcCisJ cHJfZGVidWcoIlVCSSBEQkcgIiB0eXBlICI6ICIgZm10ICJcbiIsICAgICAgIFwKK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BzZXE6IDB4JXgsIGV4cGVjdGVkOiAweCV4IiwKKwkJCQli ZTMyX3RvX2NwdShlY2gtPmltYWdlX3NlcSksIHViaS0+aW1hZ2Vfc2VxKTsKKwkJCWVyciA9IFVC SV9CQURfRkFTVE1BUDsKKwkJCWdvdG8gb3V0OworCQl9CisKKwkJZXJyID0gdWJpX2lvX3JlYWRf dmlkX2hkcih1YmksIHBudW0sIHZoLCAwKTsKKwkJaWYgKGVyciA9PSBVQklfSU9fRkYgfHwgZXJy ID09IFVCSV9JT19GRl9CSVRGTElQUykgeworCQkJdW5zaWduZWQgbG9uZyBsb25nIGVjID0gYmU2 NF90b19jcHUoZWNoLT5lYyk7CisJCQl1bm1hcF9wZWIoYWksIHBudW0pOworCQkJZGJnX2JsZCgi QWRkaW5nIFBFQiB0byBmcmVlOiAlaSIsIHBudW0pOworCQkJaWYgKGVyciA9PSBVQklfSU9fRkZf QklURkxJUFMpCisJCQkJYWRkX2FlYihhaSwgbGZyZWUsIHBudW0sIGVjLCAxKTsKKwkJCWVsc2UK KwkJCQlhZGRfYWViKGFpLCBsZnJlZSwgcG51bSwgZWMsIDApOworCQkJY29udGludWU7CisJCX0g ZWxzZSBpZiAoZXJyID09IDAgfHwgZXJyID09IFVCSV9JT19CSVRGTElQUykgeworCQkJZGJnX2Js ZCgiRm91bmQgbm9uIGVtcHR5IFBFQjolaSBpbiBwb29sIiwgcG51bSk7CisKKwkJCWlmIChlcnIg PT0gVUJJX0lPX0JJVEZMSVBTKQorCQkJCXNjcnViID0gMTsKKworCQkJZm91bmRfb3JwaGFuID0g MDsKKwkJCWxpc3RfZm9yX2VhY2hfZW50cnkodG1wX2FlYiwgZWJhX29ycGhhbnMsIHUubGlzdCkg eworCQkJCWlmICh0bXBfYWViLT5wbnVtID09IHBudW0pIHsKKwkJCQkJZm91bmRfb3JwaGFuID0g MTsKKwkJCQkJYnJlYWs7CisJCQkJfQorCQkJfQorCQkJaWYgKGZvdW5kX29ycGhhbikgeworCQkJ CWtmcmVlKHRtcF9hZWIpOworCQkJCWxpc3RfZGVsKCZ0bXBfYWViLT51Lmxpc3QpOworCQkJfQor CisJCQluZXdfYWViID0ga3phbGxvYyhzaXplb2YoKm5ld19hZWIpLCBHRlBfS0VSTkVMKTsKKwkJ CWlmICghbmV3X2FlYikgeworCQkJCXJldCA9IC1FTk9NRU07CisJCQkJZ290byBvdXQ7CisJCQl9 CisKKwkJCW5ld19hZWItPmVjID0gYmU2NF90b19jcHUoZWNoLT5lYyk7CisJCQluZXdfYWViLT5w bnVtID0gcG51bTsKKwkJCW5ld19hZWItPmxudW0gPSBiZTMyX3RvX2NwdSh2aC0+bG51bSk7CisJ CQluZXdfYWViLT5zcW51bSA9IGJlNjRfdG9fY3B1KHZoLT5zcW51bSk7CisJCQluZXdfYWViLT5j b3B5X2ZsYWcgPSB2aC0+Y29weV9mbGFnOworCQkJbmV3X2FlYi0+c2NydWIgPSBzY3J1YjsKKwor CQkJaWYgKCptYXhfc3FudW0gPCBuZXdfYWViLT5zcW51bSkKKwkJCQkqbWF4X3NxbnVtID0gbmV3 X2FlYi0+c3FudW07CisKKwkJCWVyciA9IHByb2Nlc3NfcG9vbF9hZWIodWJpLCBhaSwgdmgsIG5l d19hZWIpOworCQkJaWYgKGVycikgeworCQkJCXJldCA9IGVyciA+IDAgPyBVQklfQkFEX0ZBU1RN QVAgOiBlcnI7CisJCQkJZ290byBvdXQ7CisJCQl9CisJCX0gZWxzZSB7CisJCQkvKiBXZSBhcmUg cGFyYW5vaWQgYW5kIGZhbGwgYmFjayB0byBzY2FubmluZyBtb2RlICovCisJCQl1YmlfZXJyKCJm YXN0bWFwIHBvb2wgUEVCcyBjb250YWlucyBkYW1hZ2VkIFBFQnMhIik7CisJCQlyZXQgPSBlcnIg PiAwID8gVUJJX0JBRF9GQVNUTUFQIDogZXJyOworCQkJZ290byBvdXQ7CisJCX0KKworCX0KKwor b3V0OgorCXViaV9mcmVlX3ZpZF9oZHIodWJpLCB2aCk7CisJa2ZyZW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isJfQorCisJaWYgKHViaS0+bm9yX2ZsYXNoKSB7CisJCWVyciA9IG5vcl9l cmFzZV9wcmVwYXJlKHViaSwgcG51bSk7CisJCWlmIChlcnIpCisJCQlyZXR1cm4gZXJyOworCX0K KworCWlmICh0b3J0dXJlKSB7CisJCXJldCA9IHRvcnR1cmVfcGViKHViaSwgcG51bSk7CisJCWlm IChyZXQgPCAwKQorCQkJcmV0dXJuIHJldDsKKwl9CisKKwllcnIgPSBkb19zeW5jX2VyYXNlKHVi aSwgcG51bSk7CisJaWYgKGVycikKKwkJcmV0dXJuIGVycjsKKworCXJldHVybiByZXQgKyAxOwor fQorCisvKioKKyAqIHViaV9pb19pc19iYWQgLSBjaGVjayBpZiBhIHBoeXNpY2FsIGVyYXNlYmxv Y2sgaXMgYmFkLgorICogQHViaTogVUJJIGRldmljZSBkZXNjcmlwdGlvbiBvYmplY3QKKyAqIEBw bnVtOiB0aGUgcGh5c2ljYWwgZXJhc2VibG9jayBudW1iZXIgdG8gY2hlY2sKKyAqCisgKiBUaGlz IGZ1bmN0aW9uIHJldHVybnMgYSBwb3NpdGl2ZSBudW1iZXIgaWYgdGhlIHBoeXNpY2FsIGVyYXNl YmxvY2sgaXMgYmFkLAorICogemVybyBpZiBub3QsIGFuZCBhIG5lZ2F0aXZlIGVycm9yIGNvZGUg aWYgYW4gZXJyb3Igb2NjdXJyZWQuCisgKi8KK2ludCB1YmlfaW9faXNfYmFkKGNvbnN0IHN0cnVj dCB1YmlfZGV2aWNlICp1YmksIGludCBwbnVtKQoreworCXN0cnVjdCBtdGRfaW5mbyAqbXRkID0g dWJpLT5tdGQ7CisKKwl1YmlfYXNzZXJ0KHBudW0gPj0gMCAmJiBwbnVtIDwgdWJpLT5wZWJfY291 bnQpOworCisJaWYgKHViaS0+YmFkX2FsbG93ZWQpIHsKKwkJaW50IHJldDsKKworCQlyZXQgPSBt dGRfYmxvY2tfaXNiYWQobXRkLCAobG9mZl90KXBudW0gKiB1YmktPnBlYl9zaXplKT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nVmOworCXNpemVfdCBmbV9zaXplOworCisJLyogV2Vhci1sZXZlbGluZyBz dWItc3lzdGVtJ3Mgc3R1ZmYgKi8KKwlzdHJ1Y3QgcmJfcm9vdCB1c2VkOworCXN0cnVjdCByYl9y b290IGVycm9uZW91czsKKwlzdHJ1Y3QgcmJfcm9vdCBmcmVlOworCWludCBmcmVlX2NvdW50Owor CXN0cnVjdCByYl9yb290IHNjcnViOworCXN0cnVjdCBsaXN0X2hlYWQgcHFbVUJJX1BST1RfUVVF VUVfTEVOXTsKKwlpbnQgcHFfaGVhZDsKKwlpbnQgd2xfc2NoZWR1bGVkOworCXN0cnVjdCB1Ymlf d2xfZW50cnkgKipsb29rdXB0Ymw7CisJc3RydWN0IHViaV93bF9lbnRyeSAqbW92ZV9mcm9tOwor CXN0cnVjdCB1Ymlfd2xfZW50cnkgKm1vdmVfdG87CisJaW50IG1vdmVfdG9fcHV0OworCXN0cnVj dCBsaXN0X2hlYWQgd29ya3M7CisJaW50IHdvcmtzX2NvdW50OworCXN0cnVjdCB0YXNrX3N0cnVj dCAqYmd0X3RocmVhZDsKKwlpbnQgdGhyZWFkX2VuYWJsZWQ7CisJY2hhciBiZ3RfbmFtZVtzaXpl b2YoVUJJX0JHVF9OQU1FX1BBVFRFUk4pKzJdOworCisJLyogSS9PIHN1Yi1zeXN0ZW0ncyBzdHVm ZiAqLworCWxvbmcgbG9uZyBmbGFzaF9zaXplOworCWludCBwZWJfY291bnQ7CisJaW50IHBlYl9z aXplOworCWludCBiYWRfcGViX2NvdW50OworCWludCBnb29kX3BlYl9jb3VudDsKKwlpbnQgY29y cl9wZWJfY291bnQ7CisJaW50IGVycm9uZW91c19wZWJfY291bnQ7CisJaW50IG1heF9lcnJvbmVv dXM7CisJaW50IG1pbl9pb19zaXplOworCWludCBoZHJzX21pbl9pb19zaXplOworCWludCByb19t b2RlOworCWludCBsZWJfc2l6ZTsKKwlpbnQgbGViX3N0YXJ0OworCWludCBlY19oZHJfYWxzaXpl OworCWlud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2x1bWVzKQorICog QGxhc3RfZGF0YV9zaXplOiBhbW91bnQgb2YgZGF0YSBpbiB0aGUgbGFzdCBsb2dpY2FsIGVyYXNl YmxvY2sgb2YgdGhpcworICogICAgICAgICAgICAgICAgICB2b2x1bWUgKGFsd2F5cyBlcXVpdmFs ZW50IHRvIHRoZSB1c2FibGUgbG9naWNhbCBlcmFzZWJsb2NrCisgKiAgICAgICAgICAgICAgICAg IHNpemUgaW4gY2FzZSBvZiBkeW5hbWljIHZvbHVtZXMpCisgKiBAZGF0YV9wYWQ6IGhvdyBtYW55 IGJ5dGVzIGF0IHRoZSBlbmQgb2YgbG9naWNhbCBlcmFzZWJsb2NrcyBvZiB0aGlzIHZvbHVtZQor ICogICAgICAgICAgICBhcmUgbm90IHVzZWQgKGR1ZSB0byB2b2x1bWUgYWxpZ25tZW50KQorICog QGNvbXBhdDogY29tcGF0aWJpbGl0eSBmbGFncyBvZiB0aGlzIHZvbHVtZQorICogQHJiOiBsaW5r IGluIHRoZSB2b2x1bWUgUkItdHJlZQorICogQHJvb3Q6IHJvb3Qgb2YgdGhlIFJCLXRyZWUgY29u dGFpbmluZyBhbGwgdGhlIGVyYXNlYmxvY2sgYmVsb25naW5nIHRvIHRoaXMKKyAqICAgICAgICB2 b2x1bWUgKCZzdHJ1Y3QgdWJpX2FpbmZfcGViIG9iamVjdHMpCisgKgorICogT25lIG9iamVjdCBv ZiB0aGlzIHR5cGUgaXMgYWxsb2NhdGVkIGZvciBlYWNoIHZvbHVtZSB3aGVuIGF0dGFjaGluZyBh biBNVEQKKyAqIGRldmljZS4KKyAqLworc3RydWN0IHViaV9haW5mX3ZvbHVtZSB7CisJaW50IHZv bF9pZDsKKwlpbnQgaGlnaGVzdF9sbnVtOworCWludCBsZWJfY291bnQ7CisJaW50IHZvbF90eXBl OworCWludCB1c2VkX2ViczsKKwlpbnQgbGFzdF9kYXRhX3NpemU7CisJaW50IGRhdGFfcGFkOwor CWludCBjb21wYXQ7CisJc3RydWN0IHJiX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HJ1Y3QgdWJpX2RldmljZSAqdWJpKTsKK2ludCB1 Ymlfc2Nhbl9mYXN0bWFwKHN0cnVjdCB1YmlfZGV2aWNlICp1YmksIHN0cnVjdCB1YmlfYXR0YWNo X2luZm8gKmFpLAorCQkgICAgIGludCBmbV9hbmNob3IpOwordm9pZCB1YmlfZnJlZV9mYXN0bWFw KHN0cnVjdCB1YmlfZGV2aWNlICp1YmkpOworLyoKKyAqIHViaV9yYl9mb3JfZWFjaF9lbnRyeSAt IHdhbGsgYW4gUkItdHJlZS4KKyAqIEByYjogYSBwb2ludGVyIHRvIHR5cGUgJ3N0cnVjdCByYl9u b2RlJyB0byB1c2UgYXMgYSBsb29wIGNvdW50ZXIKKyAqIEBwb3M6IGEgcG9pbnRlciB0byBSQi10 cmVlIGVudHJ5IHR5cGUgdG8gdXNlIGFzIGEgbG9vcCBjb3VudGVyCisgKiBAcm9vdDogUkItdHJl ZSdzIHJvb3QKKyAqIEBtZW1iZXI6IHRoZSBuYW1lIG9mIHRoZSAnc3RydWN0IHJiX25vZGUnIHdp dGhpbiB0aGUgUkItdHJlZSBlbnRyeQorICovCisjZGVmaW5lIHViaV9yYl9mb3JfZWFjaF9lbnRy eShyYiwgcG9zLCByb290LCBtZW1iZXIpICAgICAgICAgICAgICAgICAgICAgICAgIFwKKwlmb3Ig KHJiID0gcmJfZmlyc3Qocm9vdCksICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICBcCisJICAgICBwb3MgPSAocmIgPyBjb250YWluZXJfb2YocmIsIHR5cGVvZigqcG9z KSwgbWVtYmVyKSA6IE5VTEwpOyAgICAgXAorCSAgICAgcmI7ICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKwkgICAgIHJiID0gcmJf bmV4dChyYiksICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBc CisJICAgICBwb3MgPSAocmIgPyBjb250YWlu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T5m bV93bF9wb29sOworCisJaWYgKCFwb29sLT5zaXplIHx8ICF3bF9wb29sLT5zaXplIHx8IHBvb2wt PnVzZWQgPT0gcG9vbC0+c2l6ZSB8fAorCSAgICB3bF9wb29sLT51c2VkID09IHdsX3Bvb2wtPnNp emUpCisJCXViaV91cGRhdGVfZmFzdG1hcCh1YmkpOworCisJLyogd2UgZ290IG5vdCBhIHNpbmds ZSBmcmVlIFBFQiAqLworCWlmICghcG9vbC0+c2l6ZSkKKwkJcmV0ID0gLUVOT1NQQzsKKwllbHNl IHsKKwkJcmV0ID0gcG9vbC0+cGVic1twb29sLT51c2VkKytdOworCQlwcm90X3F1ZXVlX2FkZCh1 YmksIHViaS0+bG9va3VwdGJsW3JldF0pOworCX0KKworCXJldHVybiByZXQ7Cit9CisKKy8qIGdl dF9wZWJfZm9yX3dsIC0gcmV0dXJucyBhIFBFQiB0byBiZSB1c2VkIGludGVybmFsbHkgYnkgdGhl IFdMIHN1Yi1zeXN0ZW0uCisgKgorICogQHViaTogVUJJIGRldmljZSBkZXNjcmlwdGlvbiBvYmpl Y3QKKyAqLworc3RhdGljIHN0cnVjdCB1Ymlfd2xfZW50cnkgKmdldF9wZWJfZm9yX3dsKHN0cnVj dCB1YmlfZGV2aWNlICp1YmkpCit7CisJc3RydWN0IHViaV9mbV9wb29sICpwb29sID0gJnViaS0+ Zm1fd2xfcG9vbDsKKwlpbnQgcG51bTsKKworCWlmIChwb29sLT51c2VkID09IHBvb2wtPnNpemUg fHwgIXBvb2wtPnNpemUpIHsKKwkJdWJpX3VwZGF0ZV9mYXN0bWFwKHViaSk7CisJCWlmIChwb29s LT51c2VkID09IHBvb2wtPnNpemUgfHwgIXBvb2wtPnNpemUpCisJCQlCVUcoKTsKKwl9CisKKwlw bnVtID0gcG9vbC0+cGVic1twb29sLT51c2VkKytdOworCisJcmV0dXJuIHViaS0+bG9va3VwdGJs W3BudW1dOworfQorI2Vsc2UKK3N0YXRpYyBzdHJ1Y3QgdWJpX3dsX2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3Jr c19jb3VudCAtPSAxOworCQkJCXViaV9hc3NlcnQodWJpLT53b3Jrc19jb3VudCA+PSAwKTsKKwor CQkJCWVyciA9IHdyay0+ZnVuYyh1YmksIHdyaywgMCk7CisJCQkJaWYgKGVycikKKwkJCQkJcmV0 dXJuIGVycjsKKworCQkJCWZvdW5kID0gMTsKKwkJCQlicmVhazsKKwkJCX0KKwkJfQorCX0KKwor CXJldHVybiBlcnI7Cit9CisKKy8qKgorICogdHJlZV9kZXN0cm95IC0gZGVzdHJveSBhbiBSQi10 cmVlLgorICogQHJvb3Q6IHRoZSByb290IG9mIHRoZSB0cmVlIHRvIGRlc3Ryb3kKKyAqLworc3Rh dGljIHZvaWQgdHJlZV9kZXN0cm95KHN0cnVjdCByYl9yb290ICpyb290KQoreworCXN0cnVjdCBy Yl9ub2RlICpyYjsKKwlzdHJ1Y3QgdWJpX3dsX2VudHJ5ICplOworCisJcmIgPSByb290LT5yYl9u b2RlOworCXdoaWxlIChyYikgeworCQlpZiAocmItPnJiX2xlZnQpCisJCQlyYiA9IHJiLT5yYl9s ZWZ0OworCQllbHNlIGlmIChyYi0+cmJfcmlnaHQpCisJCQlyYiA9IHJiLT5yYl9yaWdodDsKKwkJ ZWxzZSB7CisJCQllID0gcmJfZW50cnkocmIsIHN0cnVjdCB1Ymlfd2xfZW50cnksIHUucmIpOwor CisJCQlyYiA9IHJiX3BhcmVudChyYik7CisJCQlpZiAocmIpIHsKKwkJCQlpZiAocmItPnJiX2xl ZnQgPT0gJmUtPnUucmIpCisJCQkJCXJiLT5yYl9sZWZ0ID0gTlVMTDsKKwkJCQllbHNlCisJCQkJ CXJiLT5yYl9yaWdodCA9IE5VTEw7CisJCQl9CisKKwkJCWtmcmVlKGUpOworCQl9CisJfQorfQor CisvKioKKyAqIGNhbmNlbF9wZW5kaW5nIC0gY2FuY2VsIGFsbCBwZW5kaW5nIHdvcmtzLgorICog QHViaTogVUJJIGRldmljZSBkZXNjcmlwdGlvbiBvYmplY3QKKyAq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it9OworCisvKgorICogQ29tcGF0aWJpbGl0 eSBjb25zdGFudHMgdXNlZCBieSBpbnRlcm5hbCB2b2x1bWVzLgorICoKKyAqIEBVQklfQ09NUEFU X0RFTEVURTogZGVsZXRlIHRoaXMgaW50ZXJuYWwgdm9sdW1lIGJlZm9yZSBhbnl0aGluZyBpcyB3 cml0dGVuCisgKiAgICAgICAgICAgICAgICAgICAgIHRvIHRoZSBmbGFzaAorICogQFVCSV9DT01Q QVRfUk86IGF0dGFjaCB0aGlzIGRldmljZSBpbiByZWFkLW9ubHkgbW9kZQorICogQFVCSV9DT01Q QVRfUFJFU0VSVkU6IHByZXNlcnZlIHRoaXMgaW50ZXJuYWwgdm9sdW1lIC0gZG8gbm90IHRvdWNo IGl0cworICogICAgICAgICAgICAgICAgICAgICAgIHBoeXNpY2FsIGVyYXNlYmxvY2tzLCBkb24n dCBhbGxvdyB0aGUgd2Vhci1sZXZlbGluZworICogICAgICAgICAgICAgICAgICAgICAgIHN1Yi1z eXN0ZW0gdG8gbW92ZSB0aGVtCisgKiBAVUJJX0NPTVBBVF9SRUpFQ1Q6IHJlamVjdCB0aGlzIFVC SSBpbWFnZQorICovCitlbnVtIHsKKwlVQklfQ09NUEFUX0RFTEVURSAgID0gMSwKKwlVQklfQ09N UEFUX1JPICAgICAgID0gMiwKKwlVQklfQ09NUEFUX1BSRVNFUlZFID0gNCwKKwlVQklfQ09NUEFU X1JFSkVDVCAgID0gNQorfTsKKworLyogU2l6ZXMgb2YgVUJJIGhlYWRlcnMgKi8KKyNkZWZpbmUg VUJJX0VDX0hEUl9TSVpFICBzaXplb2Yoc3RydWN0IHViaV9lY19oZHIpCisjZGVmaW5lIFVCSV9W SURfSERSX1NJWkUgc2l6ZW9mKHN0cnVjdCB1YmlfdmlkX2hkcikKKworLyogU2l6ZXMgb2YgVUJJ IGhlYWRlcnMgd2l0aG91dCB0aGUgZW5kaW5nIENSQyAqLworI2RlZmluZSBVQklfRUNfSERSX1NJ WkVfQ1JDICAoV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