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 1g9QvC-00038v-1Z for barebox@lists.infradead.org; Mon, 08 Oct 2018 08:29:47 +0000 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Mon, 8 Oct 2018 10:29:21 +0200 Message-Id: <20181008082921.26922-2-u.kleine-koenig@pengutronix.de> In-Reply-To: <20181008082921.26922-1-u.kleine-koenig@pengutronix.de> References: <20181008074936.7ilxnbq7sc5mphbu@pengutronix.de> <20181008082921.26922-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 v3 2/2] mci: implement command to switch a mmc device to enhanced mode To: barebox@lists.infradead.org VGhlIGNvbW1hbmQgc3RydWN0dXJlIGFsbG93cyBhZGRpbmcgbW9yZSBzdWJjb21tYW5kcyBhbmQg aXMgZGVzaWduZWQgdG8KbWF0Y2ggdGhlIExpbnV4IHByb2dyYW0gbW1jIGZyb20gdGhlIG1tYy11 dGlscy4gU28gbGF0ZXIgbW9yZSBjb21tYW5kcwpjYW4gZWFzaWx5IGJlIGFkZGVkIGlmIG5lZWQg YmUuCgpDb21wYXJlZCB0byBtbWMtdXRpbHMnCgoJbW1jIGVuaF9hcmVhIHNldCA8LXl8LW58LWM+ IDxzdGFydCBLaUI+IDxsZW5ndGggS2lCPiA8ZGV2aWNlPgoKdGhlIGNvbW1hbmQgdGhhdCBpcyBp bXBsZW1lbnRlZCBoZXJlICgKCgltbWMgZW5oX2FyZWEgc2V0bWF4IFstY10gPGRldmljZT4KCikg aXMgZWFzaWVyIHRvIHVzZSAoYmVjYXV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jdCBt Y2kgKm1jaSkKK3sKKwlpbnQgcmV0OworCisJcmV0ID0gbWNpX3N3aXRjaChtY2ksIEVYVF9DU0Rf UEFSVElUSU9OX1NFVFRJTkdfQ09NUExFVEVELCAxKTsKKwlpZiAocmV0KQorCQlwcmludGYoIkZh aWx1cmUgdG8gd3JpdGUgdG8gRVhUX0NTRF9QQVJUSVRJT05fU0VUVElOR19DT01QTEVURURcbiIp OworCisJcmV0dXJuIHJldDsKK30KKworc3RhdGljIHU4ICptY2lfZ2V0X2V4dF9jc2Qoc3RydWN0 IG1jaSAqbWNpKQoreworCXU4ICpleHRfY3NkOworCWludCByZXQ7CisKKwlleHRfY3NkID0geG1h bGxvYyg1MTIpOworCisJcmV0ID0gbWNpX3NlbmRfZXh0X2NzZChtY2ksIGV4dF9jc2QpOworCWlm IChyZXQpIHsKKwkJcHJpbnRmKCJGYWlsdXJlIHRvIHJlYWQgRVhUX0NTRCByZWdpc3RlclxuIik7 CisJCXJldHVybiBFUlJfUFRSKC1FSU8pOworCX0KKworCXJldHVybiBleHRfY3NkOworfQorCisv KiBlbmhfYXJlYSBzZXRtYXggWy1jXSAvZGV2L21tY1ggKi8KK3N0YXRpYyBpbnQgZG9fbW1jX2Vu aF9hcmVhKGludCBhcmdjLCBjaGFyICphcmd2W10pCit7CisJY2hhciAqZGV2cGF0aDsKKwlzdHJ1 Y3QgbWNpICptY2k7CisJdTggKmV4dF9jc2Q7CisJaW50IHNldF9jb21wbGV0ZWQgPSAwOworCWlu dCByZXQ7CisKKwlpZiAoYXJnYyA8IDIgfHwgc3RyY21wKGFyZ3ZbMV0sICJzZXRtYXgiKSAhPSAw KQorCQlnb3RvIHVzYWdlOworCisJaWYgKGFyZ2MgPT0gMykgeworCQkvKiBlbmhfYXJlYSBzZXRt YXggL2Rldi9tbWNYICovCisJCWRldnBhdGggPSBhcmd2WzJdOworCQlzZXRfY29tcGxldGVkID0g ZmFsc2U7CisJfSBlbHNlIGlmIChhcmdjID09IDQgfHwgc3R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