From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from smtp2-g21.free.fr ([212.27.42.2]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1OEJ4l-0008BJ-Bm for barebox@lists.infradead.org; Tue, 18 May 2010 09:27:00 +0000 Received: from smtp2-g21.free.fr (localhost [127.0.0.1]) by smtp2-g21.free.fr (Postfix) with ESMTP id A40714B010C for ; Tue, 18 May 2010 11:26:56 +0200 (CEST) Received: from localhost.localdomain (pac33-2-82-240-38-71.fbx.proxad.net [82.240.38.71]) by smtp2-g21.free.fr (Postfix) with ESMTP for ; Tue, 18 May 2010 11:26:54 +0200 (CEST) From: =?utf-8?q?Eric=20B=C3=A9nard?= Date: Tue, 18 May 2010 11:26:48 +0200 Message-Id: <1274174808-9516-3-git-send-email-eric@eukrea.com> In-Reply-To: <1274174808-9516-2-git-send-email-eric@eukrea.com> References: <1274174808-9516-1-git-send-email-eric@eukrea.com> <1274174808-9516-2-git-send-email-eric@eukrea.com> 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-bounces@lists.infradead.org Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 3/3] commands: add i2c commands To: barebox@lists.infradead.org dGhlc2VzIGNvbW1hbmRzIGFsbG93IGxvdyBsZXZlbCBhY2Nlc3MgdG8gaTJjIGJ1cyBhbmQgY2Fu IGJlIHVzZWZ1bAp0byBzZXR1cCBhbiBpMmMgZGV2aWNlIHdpdGhvdXQgaGF2aW5nIHRvIGFkZCBj b2RlLCBjb21waWxlIGFuZCBmbGFzaApiYXJlYm94LgoKU2lnbmVkLW9mZi1ieTogRXJpYyBCw6lu YXJkIDxlcmljQGV1a3JlYS5jb20+Ci0tLQogY29tbWFuZHMvS2NvbmZpZyAgfCAgICA4ICsrCiBj b21tYW5kcy9NYWtlZmlsZS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kcik7CisJCXJldHVybiAwOworCX0KKwlyZXR1cm4gMTsKK30KKworc3RhdGljIGNvbnN0 IF9fbWF5YmVfdW51c2VkIGNoYXIgY21kX2kyY193cml0ZV9oZWxwW10gPQorIlVzYWdlOiBpMmNf d3JpdGUgW09QVElPTl0gLi4uIGhleGRhdGFzXG4iCisid3JpdGUgdG8gaTJjIGRldmljZS5cbiIK KyIgIC1hIDB4PGFkZHI+ICAgaTJjIGRldmljZSBhZGRyZXNzXG4iCisiICAtciAweDxyZWc+ICAg IHN0YXJ0IHJlZ2lzdGVyXG4iCisiICAtYyA8Y291bnQ+ICBieXRlIG51bWJlciB0byB3cml0ZVxu IjsKKworQkFSRUJPWF9DTURfU1RBUlQoaTJjX3dyaXRlKQorCS5jbWQJCT0gZG9faTJjX3dyaXRl LAorCS51c2FnZQkJPSAid3JpdGUgdG8gYW4gaTJjIGRldmljZSIsCisJQkFSRUJPWF9DTURfSEVM UChjbWRfaTJjX3dyaXRlX2hlbHApCitCQVJFQk9YX0NNRF9FTkQKKworc3RhdGljIGludCBkb19p MmNfcmVhZChzdHJ1Y3QgY29tbWFuZCAqY21kdHAsIGludCBhcmdjLCBjaGFyICphcmd2W10pCit7 CisJc3RydWN0IGkyY19jbGllbnQgKmNsaWVudDsKKwl2b2lkICpidWYgPSBOVUxMOworCWludCBj b3VudCA9IC0xLCBhZGRyID0gLTEsIHJlZyA9IC0xLCByZXQsIG9wdDsKKworCWlmIChhcmdjIDwg NCkKKwkJcmV0dXJuIENPTU1BTkRfRVJST1JfVVNBR0U7CisKKwl3aGlsZSAoKG9wdCA9IGdldG9w dChhcmdjLCBhcmd2LCAiYTpjOnI6IikpID4gMCkgeworCQlzd2l0Y2ggKG9wdCkgeworCQljYXNl ICdhJzoKKwkJCWFkZHIgPSBoZXgyX2JpbihvcHRhcmcpOworCQkJaWYgKGFkZHIgPCAwKQorCQkJ CXJldHVybiBDT01NQU5EX0VSUk9SX1VTQUdFOworCQkJYnJlYWs7CisJCWNhc2U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