Return-path: Received: from mail-qy0-f174.google.com ([209.85.216.174]:37422 "EHLO mail-qy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750711Ab1IUAhu (ORCPT ); Tue, 20 Sep 2011 20:37:50 -0400 Received: by qyk30 with SMTP id 30so4517386qyk.19 for ; Tue, 20 Sep 2011 17:37:49 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 20 Sep 2011 21:37:49 -0300 Message-ID: (sfid-20110921_023754_291947_55D32455) Subject: Re: [PATCH v2 3/4] NFC: basic NCI protocol implementation From: Lauro Ramos Venancio To: "Elias, Ilan" Cc: "aloisio.almeida@openbossa.org" , "samuel@sortiz.org" , "linville@tuxdriver.com" , "linux-wireless@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-wireless-owner@vger.kernel.org List-ID: SGkgSWxhbiwKCjIwMTEvOS8xMyBFbGlhcywgSWxhbiA8aWxhbmVAdGkuY29tPjoKPiBUaGUgTkZD IENvbnRyb2xsZXIgSW50ZXJmYWNlIChOQ0kpIGlzIGEgc3RhbmRhcmQKPiBjb21tdW5pY2F0aW9u IHByb3RvY29sIGJldHdlZW4gYW4gTkZDIENvbnRyb2xsZXIgKE5GQ0MpCj4gYW5kIGEgRGV2aWNl IEhvc3QgKERIKSwgZGVmaW5lZCBieSB0aGUgTkZDIEZvcnVtLgo+Cj4gU2lnbmVkLW9mZi1ieTog SWxhbiBFbGlhcyA8aWxhbmVAdGkuY29tPgo+IC0tLQoKCj4gKwo+ICtzdGF0aWMgdm9pZCBuY2lf aW5pdF9jb21wbGV0ZV9yZXEoc3RydWN0IG5jaV9kZXYgKm5kZXYsIHVuc2lnbmVkIGxvbmcgb3B0 KQo+ICt7Cj4gKyDCoCDCoCDCoCBzdHJ1Y3QgbmNpX3JmX2Rpc2NfbWFwX2NtZCBjbWQ7Cj4gKyDC oCDCoCDCoCBzdHJ1Y3QgbmNpX2NvcmVfY29ubl9jcmVhdGVfY21kIG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