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.92 #3 (Red Hat Linux)) id 1i7QNV-0004Vw-I7 for barebox@lists.infradead.org; Mon, 09 Sep 2019 20:35:15 +0000 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Mon, 9 Sep 2019 22:34:51 +0200 Message-Id: <20190909203451.13047-3-u.kleine-koenig@pengutronix.de> In-Reply-To: <20190909203451.13047-1-u.kleine-koenig@pengutronix.de> References: <20190909203451.13047-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 v4 2/2] mci: implement command to switch a mmc device to enhanced mode To: barebox@lists.infradead.org VGhlIGNvbW1hbmQgc3RydWN0dXJlIGFsbG93cyBhZGRpbmcgbW9yZSBzdWJjb21tYW5kcyBhbmQg aXMgZGVzaWduZWQgdG8KbWF0Y2ggdGhlIExpbnV4IHByb2dyYW0gbW1jIGZyb20gdGhlIG1tYy11 dGlscy4gU28gbGF0ZXIgbW9yZSBjb21tYW5kcwpjYW4gZWFzaWx5IGJlIGFkZGVkIGlmIG5lZWQg YmUuCgpDb21wYXJlZCB0byBtbWMtdXRpbHMnCgoJbW1jIGVuaF9hcmVhIHNldCA8LXl8LW58LWM+ IDxzdGFydCBLaUI+IDxsZW5ndGggS2lCPiA8ZGV2aWNlPgoKdGhlIGNvbW1hbmQgdGhhdCBpcyBp bXBsZW1lbnRlZCBoZXJlICgKCgltbWMgZW5oX2FyZWEgWy1jXSA8ZGV2aWNlPgoKKSBpcyBlYXNp ZXIgdG8gdXNlIChiZWNhdXNlIHlvdSBkb24ndCBoYXZlIHRvIGNoZWNr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FkeSBmaW5hbGl6ZWRcbiIpOworCQlnb3RvIGVycm9yOworCX0KKworCXJldCA9IG1t Y19lbmhfYXJlYV9zZXRtYXgobWNpLCBleHRfY3NkKTsKKwlpZiAocmV0KQorCQlnb3RvIGVycm9y OworCisJZnJlZShleHRfY3NkKTsKKworCWlmIChzZXRfY29tcGxldGVkKSB7CisJCXJldCA9IG1t Y19wYXJ0aXRpb25pbmdfY29tcGxldGUobWNpKTsKKwkJaWYgKHJldCkKKwkJCXJldHVybiBDT01N QU5EX0VSUk9SOworCQlwcmludGYoIk5vdyBwb3dlciBjeWNsZSB0aGUgZGV2aWNlIHRvIGxldCBp dCByZWNvbmZpZ3VyZSBpdHNlbGYuXG4iKTsKKwl9CisKKwlyZXR1cm4gQ09NTUFORF9TVUNDRVNT OworCitlcnJvcjoKKwlmcmVlKGV4dF9jc2QpOworCXJldHVybiBDT01NQU5EX0VSUk9SOworfQor CitzdGF0aWMgc3RydWN0IHsKKwljb25zdCBjaGFyICpjbWQ7CisJaW50ICgqZnVuYykoaW50IGFy Z2MsIGNoYXIgKmFyZ3ZbXSk7Cit9IG1tY19zdWJjbWRzW10gPSB7CisJeworCQkuY21kID0gImVu aF9hcmVhIiwKKwkJLmZ1bmMgPSBkb19tbWNfZW5oX2FyZWEsCisJfQorfTsKKworc3RhdGljIGlu dCBkb19tbWMoaW50IGFyZ2MsIGNoYXIgKmFyZ3ZbXSkKK3sKKwlzaXplX3QgaTsKKwlpbnQgKCpm dW5jKShpbnQgYXJnYywgY2hhciAqYXJndltdKSA9IE5VTEw7CisKKwlpZiAoYXJnYyA8IDIpIHsK KwkJcHJpbnRmKCJtbWM6IHJlcXVpcmVkIHN1YmNvbW1hbmQgbWlzc2luZ1xuIik7CisJCXJldHVy biAxOworCX0KKworCWZvciAoaSA9IDA7IGkgPCBBUlJBWV9TSVpFKG1tY19zdWJjbWRzKTsgKytp KSB7CisJCWlmIChzdHJjbXAobW1jX3N1YmNtZHNbaV0uY21kLCBhcmd2WzF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