From: Meng Tang <tangmeng@uniontech.com>
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 <tangmeng@uniontech.com>
Subject: [PATCH] Bluetooth: Add bluetooth error information for error codes
Date: Thu, 28 Apr 2022 21:04:35 +0800 [thread overview]
Message-ID: <20220428130435.896-1-tangmeng@uniontech.com> (raw)
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 <tangmeng@uniontech.com>
---
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
reply other threads:[~2022-04-28 13:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220428130435.896-1-tangmeng@uniontech.com \
--to=tangmeng@uniontech.com \
--cc=davem@davemloft.net \
--cc=johan.hedberg@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox