Bluetooth: refactor endpoint lookup
Subsystems (2)
cover Bluetooth: refactor endpoint lookup
Use the common USB helper for looking up bulk and interrupt endpoints instead of open coding.
Johan
Johan Hovold (2):
Bluetooth: btusb: refactor endpoint lookup
Bluetooth: btmtk: refactor endpoint lookup
drivers/bluetooth/btmtk.c | 29 ++++------------------ drivers/bluetooth/btusb.c | 51 ++++++--------------------------------- 2 files changed, 13 insertions(+), 67 deletions(-)
Signature · 1 line
2.52.0
PATCH 1/2 Bluetooth: btusb: refactor endpoint lookup
Use the common USB helper for looking up bulk and interrupt endpoints instead of open coding.
--- drivers/bluetooth/btusb.c | 51 ++++++--------------------------------- 1 file changed, 8 insertions(+), 43 deletions(-)
drivers/bluetooth/btusb.c +8 -43
@@ -3674,31 +3674,14 @@ static inline int __set_diag_interface(struct hci_dev *hdev) {struct btusb_data *data =hci_get_drvdata (hdev);struct usb_interface *intf = data->diag; -int i; +int ret;if (!data->diag)return -ENODEV ; - data->diag_tx_ep =NULL ; - data->diag_rx_ep =NULL ; - -for (i =0 ; i < intf->cur_altsetting->desc.bNumEndpoints; i++) { -struct usb_endpoint_descriptor *ep_desc; - - ep_desc = &intf->cur_altsetting->endpoint[i].desc; - -if (!data->diag_tx_ep &&usb_endpoint_is_bulk_out (ep_desc)) { - data->diag_tx_ep = ep_desc; -continue ; - } - -if (!data->diag_rx_ep &&usb_endpoint_is_bulk_in (ep_desc)) { - data->diag_rx_ep = ep_desc; -continue ; - } - } - -if (!data->diag_tx_ep || !data->diag_rx_ep) { + ret =usb_find_common_endpoints (intf->cur_altsetting, &data->diag_rx_ep, + &data->diag_tx_ep,NULL ,NULL ); +if (ret) {bt_dev_err (hdev,"invalid diagnostic descriptors" );return -ENODEV ; }
@@ -4024,12 +4007,11 @@ static struct hci_drv btusb_hci_drv = {static int btusb_probe (struct usb_interface *intf,const struct usb_device_id *id) { -struct usb_endpoint_descriptor *ep_desc;struct gpio_desc *reset_gpio;struct btusb_data *data;struct hci_dev *hdev;unsigned ifnum_base; -int i, err, priv_size; +int err, priv_size;BT_DBG ("intf %p id %p" , intf, id);
@@ -4066,26 +4048,9 @@ static int btusb_probe(struct usb_interface *intf,if (!data)return -ENOMEM ; -for (i =0 ; i < intf->cur_altsetting->desc.bNumEndpoints; i++) { - ep_desc = &intf->cur_altsetting->endpoint[i].desc; - -if (!data->intr_ep &&usb_endpoint_is_int_in (ep_desc)) { - data->intr_ep = ep_desc; -continue ; - } - -if (!data->bulk_tx_ep &&usb_endpoint_is_bulk_out (ep_desc)) { - data->bulk_tx_ep = ep_desc; -continue ; - } - -if (!data->bulk_rx_ep &&usb_endpoint_is_bulk_in (ep_desc)) { - data->bulk_rx_ep = ep_desc; -continue ; - } - } - -if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) { + err =usb_find_common_endpoints (intf->cur_altsetting, &data->bulk_rx_ep, + &data->bulk_tx_ep, &data->intr_ep,NULL ); +if (err) {kfree (data);return -ENODEV ; }
Signature · 1 line
2.52.0
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=1074462
---Test result---
Test Summary:
CheckPatch PENDING 0.34 seconds GitLint PENDING 0.40 seconds SubjectPrefix PASS 0.22 seconds BuildKernel PASS 26.62 seconds CheckAllWarning PASS 29.36 seconds CheckSparse PASS 28.29 seconds BuildKernel32 PASS 25.82 seconds TestRunnerSetup PASS 568.19 seconds TestRunner_l2cap-tester PASS 28.30 seconds TestRunner_iso-tester PASS 38.29 seconds TestRunner_bnep-tester PASS 6.37 seconds TestRunner_mgmt-tester FAIL 112.29 seconds TestRunner_rfcomm-tester PASS 9.41 seconds TestRunner_sco-tester FAIL 14.48 seconds TestRunner_ioctl-tester PASS 10.29 seconds TestRunner_mesh-tester FAIL 12.47 seconds TestRunner_smp-tester PASS 8.68 seconds TestRunner_userchan-tester PASS 6.72 seconds IncrementalBuild PENDING 0.93 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner Output:
Total: 494, Passed: 485 (98.2%), Failed: 5, Not Run: 4
Failed Test Cases
Adv. connectable & connected (central) - Success Failed 0.136 seconds Adv. non-connectable & connected (central) - Success Failed 0.134 seconds Ext Adv. connectable & connected (central) Failed 0.172 seconds Ext Adv. non-connectable & connected (central) Failed 0.179 seconds Read Exp Feature - Success Failed 0.105 seconds
##############################
Test: TestRunner_sco-tester - FAIL
Desc: Run sco-tester with test-runner
Output:
WARNING: possible circular locking dependency detected
BUG: sleeping function called from invalid context at net/core/sock.c:3782
Total: 30, Passed: 30 (100.0%), Failed: 0, Not Run: 0
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0
Failed Test Cases
Mesh - Send cancel - 1 Timed out 2.683 seconds Mesh - Send cancel - 2 Timed out 1.992 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
PATCH 2/2 Bluetooth: btmtk: refactor endpoint lookup
In reply to Johan HovoldUse the common USB helper for looking up bulk and interrupt endpoints instead of open coding.
--- drivers/bluetooth/btmtk.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-)
drivers/bluetooth/btmtk.c +5 -24
@@ -983,7 +983,7 @@ static int __set_mtk_intr_interface(struct hci_dev *hdev) {struct btmtk_data *btmtk_data =hci_get_priv (hdev);struct usb_interface *intf = btmtk_data->isopkt_intf; -int i, err; +int err;if (!btmtk_data->isopkt_intf)return -ENODEV ;
@@ -994,29 +994,10 @@ static int __set_mtk_intr_interface(struct hci_dev *hdev)return err; } - btmtk_data->isopkt_tx_ep =NULL ; - btmtk_data->isopkt_rx_ep =NULL ; - -for (i =0 ; i < intf->cur_altsetting->desc.bNumEndpoints; i++) { -struct usb_endpoint_descriptor *ep_desc; - - ep_desc = &intf->cur_altsetting->endpoint[i].desc; - -if (!btmtk_data->isopkt_tx_ep && -usb_endpoint_is_int_out (ep_desc)) { - btmtk_data->isopkt_tx_ep = ep_desc; -continue ; - } - -if (!btmtk_data->isopkt_rx_ep && -usb_endpoint_is_int_in (ep_desc)) { - btmtk_data->isopkt_rx_ep = ep_desc; -continue ; - } - } - -if (!btmtk_data->isopkt_tx_ep || - !btmtk_data->isopkt_rx_ep) { + err =usb_find_common_endpoints (intf->cur_altsetting,NULL ,NULL , + &btmtk_data->isopkt_rx_ep, + &btmtk_data->isopkt_tx_ep); +if (err) {bt_dev_err (hdev,"invalid interrupt descriptors" );return -ENODEV ; }
Signature · 1 line
2.52.0
This series was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 11 lines · On Mon, 30 Mar 2026 11:41:32 +0200 you wrote:
Use the common USB helper for looking up bulk and interrupt endpoints instead of open coding.
Johan
Johan Hovold (2):
Bluetooth: btusb: refactor endpoint lookup
Bluetooth: btmtk: refactor endpoint lookup[...]
Here is the summary with links:
- [1/2] Bluetooth: btusb: refactor endpoint lookup
https://git.kernel.org/bluetooth/bluetooth-next/c/8b686971c812 - [2/2] Bluetooth: btmtk: refactor endpoint lookup https://git.kernel.org/bluetooth/bluetooth-next/c/d01e702fc7a1
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html