From patchwork Thu Apr 28 13:04:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Meng Tang X-Patchwork-Id: 567319 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B3C9C433EF for ; Thu, 28 Apr 2022 13:05:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346764AbiD1NI2 (ORCPT ); Thu, 28 Apr 2022 09:08:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346409AbiD1NIZ (ORCPT ); Thu, 28 Apr 2022 09:08:25 -0400 Received: from smtpbguseast1.qq.com (smtpbguseast1.qq.com [54.204.34.129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B4978565F for ; Thu, 28 Apr 2022 06:05:10 -0700 (PDT) X-QQ-mid: bizesmtp67t1651151084t0ubflmf Received: from localhost.localdomain ( [58.240.82.166]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 28 Apr 2022 21:04:38 +0800 (CST) X-QQ-SSF: 01400000002000E0M000000A0000000 X-QQ-FEAT: ZHWZeLXy+8e6BJiTYangnhOr5IcHo9PDpnvWd/LzUXHVBYP5Ns70+NJtTUtxx L01MpdLZwTtCieUxlV8UIGqzjZfGRszS7pO8xh6GIBpyVBzL7HR/q1gSfEyLMHiTUWPYb6e LzytBKJhBvGYQDlAvnb1PJcM5l9U8f7C0jrWpYitUp8ANcew4BSSrFywwKiT8/7SKMXi1aM NvRixxfd88NJhhjN7sGdtrFCaq0BBxCC0b2dfsA71mGdGzxE3SGnt77lmuNQNcengdztGt8 pl0GwkrVhYcJv2ejnebUG5rudHVO0oD6yKydmspMLdzTUNVpJDPPuL71y0ye/og60cAbfKf RFIcLQgPtwtvRxgh9eAC9xLtEg8iLQE6STJYzpRxlRiyRIs8+0= X-QQ-GoodBg: 1 From: Meng Tang To: marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Meng Tang Subject: [PATCH] Bluetooth: Add bluetooth error information for error codes Date: Thu, 28 Apr 2022 21:04:35 +0800 Message-Id: <20220428130435.896-1-tangmeng@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybgforeign:qybgforeign10 X-QQ-Bgrelay: 1 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Bluetooth error codes to Unix errno mapping is not completed. For example, the following Bluetooth error codes are directly classified as ENOSYS. /* Possible error codes */ #define HCI_SCO_INTERVAL_REJECTED 0x1C #define HCI_SCO_AIR_MODE_REJECTED 0x1D #define HCI_UNSPECIFIED_ERROR 0x1F #define HCI_ROLE_CHANGE_NOT_ALLOWED 0x21 #define HCI_LMP_RESPONSE_TIMEOUT 0x22 #define HCI_UNIT_KEY_USED 0x26 #define HCI_INSTANT_PASSED 0x28 As a result, when these error codes occur in Bluetooth, ENOSYS is always returned, and users cannot know the specific error codes of Bluetooth, thus affecting the positioning of Bluetooth problems. This will make it difficult to locate and analyze Bluetooth issues. Therefore, I added information for bluetooth error codes that are not currently mapped to help users get bluetooth error codes. Signed-off-by: Meng Tang --- net/bluetooth/lib.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/net/bluetooth/lib.c b/net/bluetooth/lib.c index 5326f41a58b7..eaf952de0ef9 100644 --- a/net/bluetooth/lib.c +++ b/net/bluetooth/lib.c @@ -122,6 +122,14 @@ int bt_to_errno(__u16 code) case 0x1b: return ECONNREFUSED; + case 0x1c: + printk(KERN_ERR "Bluetooth: errno(0x%02x), SCO Interval Rejected", code); + return ENOSYS; + + case 0x1d: + printk(KERN_ERR "Bluetooth: errno(0x%02x), SCO Air Mode Rejected", code); + return ENOSYS; + case 0x19: case 0x1e: case 0x23: @@ -129,7 +137,28 @@ int bt_to_errno(__u16 code) case 0x25: return EPROTO; + case 0x1f: + printk(KERN_ERR "Bluetooth: errno(0x%02x), Unspecified Error", code); + return ENOSYS; + + case 0x21: + printk(KERN_ERR "Bluetooth: errno(0x%02x), Role Change Not Allowed", code); + return ENOSYS; + + case 0x22: + printk(KERN_ERR "Bluetooth: errno(0x%02x), LMP Response Timeout", code); + return ENOSYS; + + case 0x26: + printk(KERN_ERR "Bluetooth: errno(0x%02x), Unit Key Used", code); + return ENOSYS; + + case 0x28: + printk(KERN_ERR "Bluetooth: errno(0x%02x), Instant Passed", code); + return ENOSYS; + default: + printk(KERN_ERR "Bluetooth: errno(0x%02x), Error code unknown", code); return ENOSYS; } }