[PATCH] Bluetooth: Add bluetooth error information for error codes
From: Meng Tang
Date: Thu Apr 28 2022 - 09:05:10 EST
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@xxxxxxxxxxxxx>
---
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