linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: Add bluetooth error information for error codes
@ 2022-04-28 13:04 Meng Tang
  2022-04-28 13:42 ` bluez.test.bot
  0 siblings, 1 reply; 2+ messages in thread
From: Meng Tang @ 2022-04-28 13:04 UTC (permalink / raw)
  To: marcel, johan.hedberg, luiz.dentz, davem, kuba, pabeni
  Cc: linux-bluetooth, netdev, linux-kernel, Meng Tang

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




^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-28 13:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-28 13:04 [PATCH] Bluetooth: Add bluetooth error information for error codes Meng Tang
2022-04-28 13:42 ` bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).