Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp800780iob; Thu, 28 Apr 2022 11:25:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9hl7U5qnxXV7x3oTCoBLvJpggWGFmNHLUeKg3b2dYB5hj4oJdGqyFkZRAnL61iGIsHLeA X-Received: by 2002:a05:651c:1503:b0:24c:81df:e1f2 with SMTP id e3-20020a05651c150300b0024c81dfe1f2mr22682214ljf.182.1651170324628; Thu, 28 Apr 2022 11:25:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651170324; cv=none; d=google.com; s=arc-20160816; b=K+iwDMuz5ed2w1Z2ef+73rcbk1g9+/54PiCOsUKNKe7M5HAYYbT5yVPGk/bhbXl5EA fqOKO4VN8/k0MGXC84G5NZIMFRoLepsv0wfkJ0b+9MpqLd148vCx9KYomsc7k4tLJhud cOqBu+eWxo/7Cwve/R+oaE65Buk/4HxnGwrGr5hsoLs+2bm9sQ7s3fIZic8jOqahyCGx Ptwr9s/rNxRbAUgLloFm5DmijMKfZNgsryomF1MLKMPQTtBfQ+ov0WbJ/95xZFkG9XQz KzZ9fPPghtDpT6f6tHqSzqCSBv1ViE0i8szan6KHQBQlJIUfJBxukLG4Ikmr/ouI/HIC zpbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=KJ7U5hRlwFrKxQKDkXAnwq7VIn1WrwOjFNW+Tjqm0mE=; b=OCIoWsL0xGiJ33jGE2K5QFDOnkX0tTpQ6FhWbAAIWTkMxXlPRo1sb8JP2RBwwzVc9e 2htt15R8x6PS1G7Ef8VO52xOH/RY8BwjEB8UzqmMpAvA7XyILO2CslumEJPzMS82DAuU KnTPRuLyht/4LhjRO5jSOCRl29QcjdPLZEKMhGUyKbH5JmHUAQpDCpLnwZj8dM1mgheZ /xYnk18pf2eY2z6a4l3y3cF2JbMbA5lZOf5yaQJsbOhr13m4eS846jkvvEafrv7T5jwO U9w6JrhLHlFFfIi2g+lUQO5i6v18bB3HlZdwNPw6jEWP37tXSTL+FZa5Iyn9SPnr6jJh wr8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r4-20020ac25c04000000b00471f6fe30bfsi4574391lfp.380.2022.04.28.11.24.56; Thu, 28 Apr 2022 11:25:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345704AbiD1NIV (ORCPT + 99 others); Thu, 28 Apr 2022 09:08:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346409AbiD1NIT (ORCPT ); Thu, 28 Apr 2022 09:08:19 -0400 Received: from smtpbguseast1.qq.com (smtpbguseast1.qq.com [54.204.34.129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77748C52 for ; Thu, 28 Apr 2022 06:05:02 -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 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybgforeign:qybgforeign10 X-QQ-Bgrelay: 1 X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_XBL,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; } } -- 2.20.1