Return-Path: From: "Zhang, Zhenhua" To: "linux-bluetooth@vger.kernel.org" Date: Mon, 14 Sep 2009 18:02:03 +0800 Subject: ioctl(RFCOMMCREATEDEV) failed: File descriptor in bad state Message-ID: <0463F45F3606F4428ED35AC8C709F92E089A4160F9@pdsmsx502.ccr.corp.intel.com> Content-Type: text/plain; charset="gb2312" MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org List-ID: RGVhciBhbGwsDQoNCkkgYW0gY2FsbGluZyBpb2N0bChSRkNPTU1DUkVBVEVERVYpIHRvIGNyZWF0 ZSB0dHkgZGV2aWNlIGZyb20gYSByZmNvbW0gZmQgDQp1c2luZyBoYW5kcy1mcmVlIHByb2ZpbGUu IElmIHRoZSBIRiBzZW5kIGNvbm5lY3Rpb24gcmVxdWVzdCB0byBBRyBhbmQgbWFrZQ0KcmZjb21t IGNvbm5lY3QsIHRoZSB0dHkgY291bGQgYmUgbWFkZSBzdWNjZXNzZnVsbHkuIEhvd2V2ZXIsIGlm IHRoZSANCkFHKG1vYmlsZSkgc2lkZSBtYWtlIHJlcXVlc3QgdG8gY3JlYXRlIHJmY29tbSBjb25u ZWN0aW9uLCB0aGUgcmZjb21tIGNvdWxkDQpiZSBjcmVhdGVkIGJ1dCBmYWlsIHRvIGNyZWF0ZSB0 aGUgdHR5IGRldmljZS4gVGhlIGtlcm5lbCByZXR1cm5zIGVycm9yIA0KYmVjYXVzZSBzb2NrZXQg aXMgbm90IGNvbm5lY3RlZCwgc2VlIGJlbG93IGNvZGUuIEFueSBpZGVhPyBUaGFua3MgbXVjaCEN CiANCiAgICAgaWYgKHJlcS5mbGFncyAmICgxIDw8IFJGQ09NTV9SRVVTRV9ETEMpKSB7DQogICAg ICAgICAgICAgICAvKiBTb2NrZXQgbXVzdCBiZSBjb25uZWN0ZWQgKi8NCiAgICAgICAgICAgICAg IGlmIChzay0+c2tfc3RhdGUgIT0gQlRfQ09OTkVDVEVEKQ0KICAgICAgICAgICAgICAgICAgICAg ICAgcm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