diff mbox series

Bluetooth: Add bluetooth error information for error codes

Message ID 20220428130435.896-1-tangmeng@uniontech.com
State New
Headers show
Series Bluetooth: Add bluetooth error information for error codes | expand

Commit Message

Meng Tang April 28, 2022, 1:04 p.m. UTC
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(+)

Comments

bluez.test.bot@gmail.com April 28, 2022, 1:42 p.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=636605

---Test result---

Test Summary:
CheckPatch                    FAIL      1.81 seconds
GitLint                       PASS      1.05 seconds
SubjectPrefix                 PASS      0.93 seconds
BuildKernel                   PASS      36.51 seconds
BuildKernel32                 PASS      32.21 seconds
Incremental Build with patchesPASS      43.91 seconds
TestRunner: Setup             PASS      545.79 seconds
TestRunner: l2cap-tester      PASS      19.20 seconds
TestRunner: bnep-tester       PASS      7.15 seconds
TestRunner: mgmt-tester       PASS      114.41 seconds
TestRunner: rfcomm-tester     PASS      10.85 seconds
TestRunner: sco-tester        PASS      10.47 seconds
TestRunner: smp-tester        PASS      10.58 seconds
TestRunner: userchan-tester   PASS      7.25 seconds

Details
##############################
Test: CheckPatch - FAIL - 1.81 seconds
Run checkpatch.pl script with rule in .checkpatch.conf
Bluetooth: Add bluetooth error information for error codes\WARNING:PREFER_PR_LEVEL: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then dev_err(dev, ... then pr_err(...  to printk(KERN_ERR ...
#91: FILE: net/bluetooth/lib.c:126:
+		printk(KERN_ERR "Bluetooth: errno(0x%02x), SCO Interval Rejected", code);

WARNING:ENOSYS: ENOSYS means 'invalid syscall nr' and nothing else
#92: FILE: net/bluetooth/lib.c:127:
+		return ENOSYS;

WARNING:USE_NEGATIVE_ERRNO: return of an errno should typically be negative (ie: return -ENOSYS)
#92: FILE: net/bluetooth/lib.c:127:
+		return ENOSYS;

WARNING:PREFER_PR_LEVEL: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then dev_err(dev, ... then pr_err(...  to printk(KERN_ERR ...
#95: FILE: net/bluetooth/lib.c:130:
+		printk(KERN_ERR "Bluetooth: errno(0x%02x), SCO Air Mode Rejected", code);

WARNING:ENOSYS: ENOSYS means 'invalid syscall nr' and nothing else
#96: FILE: net/bluetooth/lib.c:131:
+		return ENOSYS;

WARNING:USE_NEGATIVE_ERRNO: return of an errno should typically be negative (ie: return -ENOSYS)
#96: FILE: net/bluetooth/lib.c:131:
+		return ENOSYS;

WARNING:PREFER_PR_LEVEL: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then dev_err(dev, ... then pr_err(...  to printk(KERN_ERR ...
#106: FILE: net/bluetooth/lib.c:141:
+		printk(KERN_ERR "Bluetooth: errno(0x%02x), Unspecified Error", code);

WARNING:ENOSYS: ENOSYS means 'invalid syscall nr' and nothing else
#107: FILE: net/bluetooth/lib.c:142:
+		return ENOSYS;

WARNING:USE_NEGATIVE_ERRNO: return of an errno should typically be negative (ie: return -ENOSYS)
#107: FILE: net/bluetooth/lib.c:142:
+		return ENOSYS;

WARNING:PREFER_PR_LEVEL: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then dev_err(dev, ... then pr_err(...  to printk(KERN_ERR ...
#110: FILE: net/bluetooth/lib.c:145:
+		printk(KERN_ERR "Bluetooth: errno(0x%02x), Role Change Not Allowed", code);

WARNING:ENOSYS: ENOSYS means 'invalid syscall nr' and nothing else
#111: FILE: net/bluetooth/lib.c:146:
+		return ENOSYS;

WARNING:USE_NEGATIVE_ERRNO: return of an errno should typically be negative (ie: return -ENOSYS)
#111: FILE: net/bluetooth/lib.c:146:
+		return ENOSYS;

WARNING:PREFER_PR_LEVEL: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then dev_err(dev, ... then pr_err(...  to printk(KERN_ERR ...
#114: FILE: net/bluetooth/lib.c:149:
+		printk(KERN_ERR "Bluetooth: errno(0x%02x), LMP Response Timeout", code);

WARNING:ENOSYS: ENOSYS means 'invalid syscall nr' and nothing else
#115: FILE: net/bluetooth/lib.c:150:
+		return ENOSYS;

WARNING:USE_NEGATIVE_ERRNO: return of an errno should typically be negative (ie: return -ENOSYS)
#115: FILE: net/bluetooth/lib.c:150:
+		return ENOSYS;

WARNING:PREFER_PR_LEVEL: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then dev_err(dev, ... then pr_err(...  to printk(KERN_ERR ...
#118: FILE: net/bluetooth/lib.c:153:
+		printk(KERN_ERR "Bluetooth: errno(0x%02x), Unit Key Used", code);

WARNING:ENOSYS: ENOSYS means 'invalid syscall nr' and nothing else
#119: FILE: net/bluetooth/lib.c:154:
+		return ENOSYS;

WARNING:USE_NEGATIVE_ERRNO: return of an errno should typically be negative (ie: return -ENOSYS)
#119: FILE: net/bluetooth/lib.c:154:
+		return ENOSYS;

WARNING:PREFER_PR_LEVEL: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then dev_err(dev, ... then pr_err(...  to printk(KERN_ERR ...
#122: FILE: net/bluetooth/lib.c:157:
+		printk(KERN_ERR "Bluetooth: errno(0x%02x), Instant Passed", code);

WARNING:ENOSYS: ENOSYS means 'invalid syscall nr' and nothing else
#123: FILE: net/bluetooth/lib.c:158:
+		return ENOSYS;

WARNING:USE_NEGATIVE_ERRNO: return of an errno should typically be negative (ie: return -ENOSYS)
#123: FILE: net/bluetooth/lib.c:158:
+		return ENOSYS;

WARNING:PREFER_PR_LEVEL: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then dev_err(dev, ... then pr_err(...  to printk(KERN_ERR ...
#126: FILE: net/bluetooth/lib.c:161:
+		printk(KERN_ERR "Bluetooth: errno(0x%02x), Error code unknown", code);

total: 0 errors, 22 warnings, 0 checks, 42 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/12830665.patch has style problems, please review.

NOTE: Ignored message types: UNKNOWN_COMMIT_ID

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.




---
Regards,
Linux Bluetooth
diff mbox series

Patch

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;
 	}
 }