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 merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7LHo-00069t-QG for barebox@lists.infradead.org; Tue, 02 Oct 2018 14:04:45 +0000 From: Sascha Hauer Date: Tue, 2 Oct 2018 16:03:59 +0200 Message-Id: <20181002140403.3735-11-s.hauer@pengutronix.de> In-Reply-To: <20181002140403.3735-1-s.hauer@pengutronix.de> References: <20181002140403.3735-1-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 Subject: [PATCH 10/14] fs: ubifs: remove not needed code To: Barebox List VGhpcyBwYXRjaCBhZ2dyZXNzaXZlbHkgcmVtb3ZlcyBzdHVmZiB0aGF0IHdlIGRvIG5vdCBuZWVk IGluIGEgcmVhZG9ubHkKaW1wbGVtZW50YXRpb246CgotIHdyaXRlIGJ1ZmZlcmluZyBzdXBwb3J0 Ci0gbHB0L2x0YWIgY29kZQotIGdhcmJhZ2UgY29sbGVjdG9yCi0gZXZlcnl0aGluZyB1bmRlciAj aWZuZGVmIF9fQkFSRUJPWF9fCgpUaGlzIGRlY3JlYXNlcyB0aGUgYmluYXJ5IHNpemUgYnkgYWJv dXQgNWsgb24gQVJNLCBidXQgdGhlIG1haW4gcmVhc29uCmZvciBkb2luZyB0aGlzIGlzIHRoZSBp ZGVhIHRoYXQgdGhpbmdzIHRoYXQgYXJlIG5vdCB0aGVyZSBkb24ndCBuZWVkIHRvCmJlIHN5bmNl ZCB3aXRoIHVwc3RyZWFtIHViaWZzIGNvZGUuClRoZSBfX0JBUkVCT1hfXyBpZmRlZmZlcnkgbWFr ZXMgdGhlIGNvZGUgdmVyeSBoYXJkIHR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i aWZzX2RlYnVnZ2luZ19leGl0IC0gZnJlZSBkZWJ1Z2dpbmcgZGF0YS4KLSAqIEBjOiBVQklGUyBm aWxlLXN5c3RlbSBkZXNjcmlwdGlvbiBvYmplY3QKLSAqLwotdm9pZCB1Ymlmc19kZWJ1Z2dpbmdf ZXhpdChzdHJ1Y3QgdWJpZnNfaW5mbyAqYykKLXsKLQlrZnJlZShjLT5kYmcpOwotfQotI2VuZGlm CmRpZmYgLS1naXQgYS9mcy91Ymlmcy9kZWJ1Zy5oIGIvZnMvdWJpZnMvZGVidWcuaAppbmRleCA3 MjU4N2I1MGI2Li45YWZiMTZkODk3IDEwMDY0NAotLS0gYS9mcy91Ymlmcy9kZWJ1Zy5oCisrKyBi L2ZzL3ViaWZzL2RlYnVnLmgKQEAgLTEzNywzNSArMTM3LDYgQEAgc3RydWN0IHViaWZzX2dsb2Jh bF9kZWJ1Z19pbmZvIHsKIAl1bnNpZ25lZCBpbnQgdHN0X3JjdnJ5OjE7CiB9OwogCi0jaWZuZGVm IF9fQkFSRUJPWF9fCi0jZGVmaW5lIHViaWZzX2Fzc2VydChleHByKSBkbyB7ICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAotCWlmICh1bmxpa2VseSghKGV4 cHIpKSkgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAot CQlwcl9jcml0KCJVQklGUyBhc3NlcnQgZmFpbGVkIGluICVzIGF0ICV1IChwaWQgJWQpXG4iLCAg ICAgICAgICBcCi0JCSAgICAgICBfX2Z1bmNfXywgX19MSU5FX18sIGN1cnJlbnQtPnBpZCk7ICAg ICAgICAgICAgICAgICAgICAgIFwKLQkJZHVtcF9zdGFjaygpOyAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAotCX0gICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAotfSB3aGls ZSAoMCkKLQotI2RlZmluZSB1Ymlmc19hc3NlcnRfY210X2xvY2tlZChjKSBkbyB7ICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKLQlpZiAodW5saWtlbHkoZG93bl93cml0 ZV90cnlsb2NrKCYoYyktPmNvbW1pdF9zZW0pKSkgeyAgICAgICAgICAgICAgICAgIFwKLQkJdXBf d3JpdGUoJihjKS0+Y29tbWl0X3NlbSk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgXAotCQlwcl9jcml0KCJjb21taXQgbG9jayBpcyBub3QgbG9ja2VkIVxuIik7ICAgICAgICAg ICAgICAgICAgICAgICBcCi0JCXViaWZzX2Fzc2VydCgwKTsgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIFwKLQl9ICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKLX0gd2hpbGUgKDAp Ci0KLSNkZWZpbmUgdWJpZnNfZGJnX21zZyh0eXBlLCBmbXQsIC4uLikgXAotCXByX2RlYnVnKCJV QklGUyBEQkcgIiB0eXBlICIgKHBpZCAlZCk6ICIgZm10ICJcbiIsIGN1cnJlbnQtPnBpZCwgICAg ICAgXAotCQkgIyNfX1ZBX0FSR1NfXykKLQotI2RlZmluZSBEQkdfS0VZX0JVRl9MRU4gNDgKLSNk ZWZpbmUgdWJpZnNfZGJnX21zZ19rZXkodHlwZSwga2V5LCBmbXQsIC4uLikgZG8geyAgICAgICAg ICAgICAgICAgICAgICAgICAgICBcCi0JY2hhciBfX3RtcF9rZXlfYnVmW0RCR19LRVlfQlVGX0xF Tl07ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi0JcHJfZGVidWcoIlVCSUZT IERCRyAiIHR5cGUgIiAocGlkICVkKTogIiBmbXQgIiVzXG4iLCBjdXJyZW50LT5waWQsICA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TMyKQotICovCi1zdGF0aWMgdm9pZCBw YWNrX2JpdHModWludDhfdCAqKmFkZHIsIGludCAqcG9zLCB1aW50MzJfdCB2YWwsIGludCBucmJp dHMpCi17Ci0JdWludDhfdCAqcCA9ICphZGRyOwotCWludCBiID0gKnBvczsKLQotCXViaWZzX2Fz c2VydChucmJpdHMgPiAwKTsKLQl1Ymlmc19hc3NlcnQobnJiaXRzIDw9IDMyKTsKLQl1Ymlmc19h c3NlcnQoKnBvcyA+PSAwKTsKLQl1Ymlmc19hc3NlcnQoKnBvcyA8IDgpOwotCXViaWZzX2Fzc2Vy dCgodmFsID4+IG5yYml0cykgPT0gMCB8fCBucmJpdHMgPT0gMzIpOwotCWlmIChiKSB7Ci0JCSpw IHw9ICgodWludDhfdCl2YWwpIDw8IGI7Ci0JCW5yYml0cyArPSBiOwotCQlpZiAobnJiaXRzID4g OCkgewotCQkJKisrcCA9ICh1aW50OF90KSh2YWwgPj49ICg4IC0gYikpOwotCQkJaWYgKG5yYml0 cyA+IDE2KSB7Ci0JCQkJKisrcCA9ICh1aW50OF90KSh2YWwgPj49IDgpOwotCQkJCWlmIChucmJp dHMgPiAyNCkgewotCQkJCQkqKytwID0gKHVpbnQ4X3QpKHZhbCA+Pj0gOCk7Ci0JCQkJCWlmIChu cmJpdHMgPiAzMikKLQkJCQkJCSorK3AgPSAodWludDhfdCkodmFsID4+PSA4KTsKLQkJCQl9Ci0J CQl9Ci0JCX0KLQl9IGVsc2UgewotCQkqcCA9ICh1aW50OF90KXZhbDsKLQkJaWYgKG5yYml0cyA+ IDgpIHsKLQkJCSorK3AgPSAodWludDhfdCkodmFsID4+PSA4KTsKLQkJCWlmIChucmJpdHMgPiAx NikgewotCQkJCSorK3AgPSAodWludDhfdCkodmFsID4+PSA4KTsKLQkJCQlpZiAobnJiaXRzID4g MjQpCi0JCQkJCSorK3AgPSAodWludDhfdCkodmFsID4+PSA4KTsKLQkJCX0KLQkJfQotCX0KLQli ID0gbnJiaXRzICYgNzsKL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FnZXMgKi8KLSNkZWZpbmUgdWJpZnNfd2Fy bihjLCBmbXQsIC4uLikgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAotCXBy X3dhcm4oIlVCSUZTIHdhcm5pbmcgKHViaSVkOiVkIHBpZCAlZCk6ICVzOiAiIGZtdCAiXG4iLCAg IFwKLQkJKGMpLT52aS51YmlfbnVtLCAoYyktPnZpLnZvbF9pZCwgY3VycmVudC0+cGlkLCAgICAg IFwKLQkJX19mdW5jX18sICMjX19WQV9BUkdTX18pCi0jZWxzZQogI2RlZmluZSB1Ymlmc19lcnIo YywgZm10LCAuLi4pICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCiAJcHJf ZXJyKCJVQklGUyBlcnJvciAodWJpJWQ6JWQgcGlkICVkKTogJXM6ICIgZm10ICJcbiIsICAgICAg XAogCSAgICAgICAoYyktPnZpLnViaV9udW0sIChjKS0+dmkudm9sX2lkLCAwLCAgICAgICAgICAg ICAgICAgIFwKQEAgLTExNCw3ICs2NSw2IEBAIHN0cnVjdCBwYWdlIHsKIAlwcl93YXJuKCJVQklG UyB3YXJuaW5nICh1YmklZDolZCBwaWQgJWQpOiAlczogIiBmbXQgIlxuIiwgICBcCiAJCShjKS0+ dmkudWJpX251bSwgKGMpLT52aS52b2xfaWQsIDAsICAgICAgICAgICAgICAgICBcCiAJCV9fZnVu Y19fLCAjI19fVkFfQVJHU19fKQotI2VuZGlmCiAKIC8qCiAgKiBBIHZhcmlhbnQgb2YgJ3ViaWZz X2VycigpJyB3aGljaCB0YWtlcyB0aGUgVUJJRlMgZmlsZS1zeXRlbSBkZXNjcmlwdGlvbgpAQCAt OTAzLDEwICs4NTMsOCBAQCBzdHJ1Y3QgdWJpZnNfY29tcHJlc3NvciB7CiAJc3RydWN0IG11dGV4 ICpkZWNvbXBfbXV0ZXg7CiAJY29uc3QgY2hhciAqbmFtZTsKIAljb25zdCBjaGFyICpjYXBpX25h bWU7Ci0jaWZkZWYgX19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