Bluetooth: hci_core: Remove usage of hci_req_sync
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH 1/5 Bluetooth: hci_core: Remove usage of hci_req_sync
From: Luiz Augusto von Dentz <[email protected]>
hci_request functions are considered deprecated so this replaces the usage of hci_req_sync with hci_inquiry_sync.
--- include/net/bluetooth/hci_sync.h | 2 ++ net/bluetooth/hci_core.c | 26 ++++---------------------- net/bluetooth/hci_sync.c | 10 +++++----- 3 files changed, 11 insertions(+), 27 deletions(-)
include/net/bluetooth/hci_sync.h +2 -0
@@ -131,6 +131,8 @@ int hci_update_discoverable(struct hci_dev *hdev);int hci_update_connectable_sync (struct hci_dev *hdev); +int hci_inquiry_sync (struct hci_dev *hdev,u8 length,u8 num_rsp); +int hci_start_discovery_sync (struct hci_dev *hdev);int hci_stop_discovery_sync (struct hci_dev *hdev);
net/bluetooth/hci_core.c +4 -22
@@ -312,26 +312,6 @@ static int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf)return copied; } -static int hci_inq_req (struct hci_request *req,unsigned long opt) -{ -struct hci_inquiry_req *ir = (struct hci_inquiry_req *) opt; -struct hci_dev *hdev = req->hdev; -struct hci_cp_inquiry cp; - -BT_DBG ("%s" , hdev->name); - -if (test_bit (HCI_INQUIRY , &hdev->flags)) -return 0 ; - -/* Start Inquiry */ -memcpy (&cp.lap, &ir->lap,3 ); - cp.length = ir->length; - cp.num_rsp = ir->num_rsp; -hci_req_add (req,HCI_OP_INQUIRY ,sizeof (cp), &cp); - -return 0 ; -} -int hci_inquiry (void __user *arg) {__u8 __user *ptr = arg;
@@ -380,8 +360,10 @@ int hci_inquiry(void __user *arg) timeo = ir.length *msecs_to_jiffies (2000 );if (do_inquiry) { - err =hci_req_sync (hdev, hci_inq_req, (unsigned long ) &ir, - timeo,NULL ); +hci_req_sync_lock (hdev); + err =hci_inquiry_sync (hdev, ir.length, ir.num_rsp); +hci_req_sync_unlock (hdev); +if (err <0 ) goto done;
net/bluetooth/hci_sync.c +5 -5
@@ -347,10 +347,9 @@ static int scan_disable_sync(struct hci_dev *hdev, void *data)return hci_scan_disable_sync (hdev); } -static int hci_inquiry_sync (struct hci_dev *hdev,u8 length);static int interleaved_inquiry_sync (struct hci_dev *hdev,void *data) { -return hci_inquiry_sync (hdev,DISCOV_INTERLEAVED_INQUIRY_LEN ); +return hci_inquiry_sync (hdev,DISCOV_INTERLEAVED_INQUIRY_LEN ,0 ); }static void le_scan_disable (struct work_struct *work)
@@ -5662,7 +5661,7 @@ int hci_update_connectable_sync(struct hci_dev *hdev)return hci_update_passive_scan_sync (hdev); } -static int hci_inquiry_sync (struct hci_dev *hdev,u8 length) +int hci_inquiry_sync (struct hci_dev *hdev,u8 length,u8 num_rsp) {const u8 giac[3 ] = {0x33 ,0x8b ,0x9e };const u8 liac[3 ] = {0x00 ,0x8b ,0x9e };
@@ -5685,6 +5684,7 @@ static int hci_inquiry_sync(struct hci_dev *hdev, u8 length)memcpy (&cp.lap, giac,sizeof (cp.lap)); cp.length = length; + cp.num_rsp = num_rsp;return __hci_cmd_sync_status (hdev,HCI_OP_INQUIRY ,sizeof (cp), &cp,HCI_CMD_TIMEOUT );
@@ -5771,7 +5771,7 @@ static int hci_start_interleaved_discovery_sync(struct hci_dev *hdev)if (err)return err; -return hci_inquiry_sync (hdev,DISCOV_BREDR_INQUIRY_LEN ); +return hci_inquiry_sync (hdev,DISCOV_BREDR_INQUIRY_LEN ,0 ); }int hci_start_discovery_sync (struct hci_dev *hdev)
@@ -5783,7 +5783,7 @@ int hci_start_discovery_sync(struct hci_dev *hdev)switch (hdev->discovery.type) {case DISCOV_TYPE_BREDR : -return hci_inquiry_sync (hdev,DISCOV_BREDR_INQUIRY_LEN ); +return hci_inquiry_sync (hdev,DISCOV_BREDR_INQUIRY_LEN ,0 );case DISCOV_TYPE_INTERLEAVED :/* When running simultaneous discovery, the LE scanning time * should occupy the whole discovery time sine BR/EDR inquiry
Signature · 1 line
2.45.2
Luiz Augusto von Dentz
maintainerPATCH 2/5 Bluetooth: hci_core: Don't use hci_prepare_cmd
From: Luiz Augusto von Dentz <[email protected]>
This replaces the instance of hci_prepare_cmd with hci_cmd_sync_alloc since the former is part of hci_request.c which is considered deprecated.
--- include/net/bluetooth/hci_sync.h | 4 ++++ net/bluetooth/hci_core.c | 4 ++-- net/bluetooth/hci_sync.c | 5 ++--- 3 files changed, 8 insertions(+), 5 deletions(-)
include/net/bluetooth/hci_sync.h +4 -0
@@ -20,6 +20,10 @@ struct hci_cmd_sync_work_entry { };struct adv_info ; + +struct sk_buff *hci_cmd_sync_alloc (struct hci_dev *hdev,u16 opcode,u32 plen, +const void *param,struct sock *sk); +/* Function with sync suffix shall not be called with hdev->lock held as they * wait the command to complete and in the meantime an event could be received * which could attempt to acquire hdev->lock causing a deadlock.
net/bluetooth/hci_core.c +2 -2
@@ -3057,7 +3057,7 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen,BT_DBG ("%s opcode 0x%4.4x plen %d" , hdev->name, opcode, plen); - skb =hci_prepare_cmd (hdev, opcode, plen, param); + skb =hci_cmd_sync_alloc (hdev, opcode, plen, param,NULL );if (!skb) {bt_dev_err (hdev,"no memory for command" );return -ENOMEM ;
@@ -3092,7 +3092,7 @@ int __hci_cmd_send(struct hci_dev *hdev, u16 opcode, u32 plen,return -EINVAL ; } - skb =hci_prepare_cmd (hdev, opcode, plen, param); + skb =hci_cmd_sync_alloc (hdev, opcode, plen, param,NULL );if (!skb) {bt_dev_err (hdev,"no memory for command (opcode 0x%4.4x)" , opcode);
net/bluetooth/hci_sync.c +2 -3
@@ -49,9 +49,8 @@ static void hci_cmd_sync_complete(struct hci_dev *hdev, u8 result, u16 opcode,wake_up_interruptible (&hdev->req_wait_q); } -static struct sk_buff *hci_cmd_sync_alloc (struct hci_dev *hdev,u16 opcode, -u32 plen,const void *param, -struct sock *sk) +struct sk_buff *hci_cmd_sync_alloc (struct hci_dev *hdev,u16 opcode,u32 plen, +const void *param,struct sock *sk) {int len =HCI_COMMAND_HDR_SIZE + plen;struct hci_command_hdr *hdr;
Signature · 1 line
2.45.2
Luiz Augusto von Dentz
maintainerPATCH 3/5 Bluetooth: hci_sync: Move handling of interleave_scan
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This moves handling of interleave_scan work to hci_sync.c since hci_request.c is deprecated.
--- net/bluetooth/hci_core.c | 3 +-- net/bluetooth/hci_sync.c | 53 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 7 deletions(-)
net/bluetooth/hci_core.c +1 -2
@@ -2555,7 +2555,6 @@ struct hci_dev *hci_alloc_dev_priv(int sizeof_priv)INIT_DELAYED_WORK (&hdev->ncmd_timer, hci_ncmd_timeout);hci_devcd_setup (hdev); -hci_request_setup (hdev);hci_init_sysfs (hdev);discovery_init (hdev);
@@ -4077,7 +4076,7 @@ static void hci_send_cmd_sync(struct hci_dev *hdev, struct sk_buff *skb)return ; } -if (hci_req_status_pend (hdev) && +if (hdev->req_status ==HCI_REQ_PEND && !hci_dev_test_and_set_flag (hdev,HCI_CMD_PENDING )) {kfree_skb (hdev->req_skb); hdev->req_skb =skb_clone (hdev->sent_cmd,GFP_KERNEL );
net/bluetooth/hci_sync.c +48 -5
71 lines not on this page · raw message
Signature · 1 line
2.45.2
Luiz Augusto von Dentz
maintainerPATCH 4/5 Bluetooth: hci_sync: Remove remaining dependencies of hci_request
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This removes the dependencies of hci_req_init and hci_request_cancel_all from hci_sync.c.
--- include/net/bluetooth/hci_sync.h | 17 +++++++++++++++++ net/bluetooth/hci_sync.c | 14 +++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-)
include/net/bluetooth/hci_sync.h +17 -0
@@ -8,6 +8,23 @@#define UINT_PTR (_handle) ((void *)((uintptr_t)_handle))#define PTR_UINT (_ptr) ((uintptr_t)((void *)_ptr)) +#define HCI_REQ_DONE 0 +#define HCI_REQ_PEND 1 +#define HCI_REQ_CANCELED 2 + +#define hci_req_sync_lock (hdev) mutex_lock(&hdev->req_lock) +#define hci_req_sync_unlock (hdev) mutex_unlock(&hdev->req_lock) + +struct hci_request { +struct hci_dev *hdev; +struct sk_buff_head cmd_q; + +/* If something goes wrong when building the HCI request, the error +* value is stored in this field. +*/ +int err; +}; +typedef int (*hci_cmd_sync_work_func_t )(struct hci_dev *hdev,void *data);typedef void (*hci_cmd_sync_work_destroy_t )(struct hci_dev *hdev,void *data,int err);
net/bluetooth/hci_sync.c +11 -3
@@ -12,7 +12,6 @@#include <net/bluetooth/hci_core.h> #include <net/bluetooth/mgmt.h> -#include "hci_request.h" #include "hci_codec.h" #include "hci_debugfs.h" #include "smp.h"
@@ -146,6 +145,13 @@ static int hci_cmd_sync_run(struct hci_request *req)return 0 ; } +static void hci_request_init (struct hci_request *req,struct hci_dev *hdev) +{ +skb_queue_head_init (&req->cmd_q); + req->hdev = hdev; + req->err =0 ; +} +/* This function requires the caller holds hdev->req_lock. */ struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen, const void *param, u8 event, u32 timeout,
@@ -157,7 +163,7 @@ struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen,bt_dev_dbg (hdev,"Opcode 0x%4.4x" , opcode); -hci_req_init (&req, hdev); +hci_request_init (&req, hdev);hci_cmd_sync_add (&req, opcode, plen, param, event, sk);
@@ -5056,7 +5062,9 @@ int hci_dev_close_sync(struct hci_dev *hdev)cancel_delayed_work (&hdev->ncmd_timer);cancel_delayed_work (&hdev->le_scan_disable); -hci_request_cancel_all (hdev); +hci_cmd_sync_cancel_sync (hdev,ENODEV ); + +cancel_interleave_scan (hdev);if (hdev->adv_instance_timeout) {cancel_delayed_work_sync (&hdev->adv_instance_expire);
Signature · 1 line
2.45.2
Luiz Augusto von Dentz
maintainerPATCH 5/5 Bluetooth: Remove hci_request.{c,h}
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This removes hci_request.{c,h} since it shall no longer be used.
--- include/net/bluetooth/bluetooth.h | 4 + net/bluetooth/Makefile | 3 +- net/bluetooth/hci_conn.c | 1 - net/bluetooth/hci_core.c | 1 - net/bluetooth/hci_debugfs.c | 1 - net/bluetooth/hci_event.c | 1 - net/bluetooth/hci_request.c | 903 ------------------------------ net/bluetooth/hci_request.h | 71 --- net/bluetooth/mgmt.c | 1 - net/bluetooth/msft.c | 1 - 10 files changed, 5 insertions(+), 982 deletions(-) delete mode 100644 net/bluetooth/hci_request.c delete mode 100644 net/bluetooth/hci_request.h
include/net/bluetooth/bluetooth.h +4 -0
@@ -441,6 +441,10 @@ typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status, u16 opcode);typedef void (*hci_req_complete_skb_t )(struct hci_dev *hdev,u8 status,u16 opcode,struct sk_buff *skb); +void hci_req_cmd_complete (struct hci_dev *hdev,u16 opcode,u8 status, +hci_req_complete_t *req_complete, +hci_req_complete_skb_t *req_complete_skb); +#define HCI_REQ_START BIT(0)#define HCI_REQ_SKB BIT(1)
net/bluetooth/Makefile +1 -2
@@ -14,8 +14,7 @@ bluetooth_6lowpan-y := 6lowpan.o bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \ hci_sock.o hci_sysfs.o l2cap_core.o l2cap_sock.o smp.o lib.o \ - ecdh_helper.o hci_request.o mgmt_util.o mgmt_config.o hci_codec.o \ - eir.o hci_sync.o + ecdh_helper.o mgmt_util.o mgmt_config.o hci_codec.o eir.o hci_sync.o bluetooth-$(CONFIG_DEV_COREDUMP) += coredump.o
net/bluetooth/hci_conn.c +0 -1
@@ -34,7 +34,6 @@#include <net/bluetooth/iso.h> #include <net/bluetooth/mgmt.h> -#include "hci_request.h" #include "smp.h" #include "eir.h"
net/bluetooth/hci_core.c +0 -1
@@ -40,7 +40,6 @@#include <net/bluetooth/l2cap.h> #include <net/bluetooth/mgmt.h> -#include "hci_request.h" #include "hci_debugfs.h" #include "smp.h" #include "leds.h"
net/bluetooth/hci_debugfs.c +0 -1
@@ -28,7 +28,6 @@#include <net/bluetooth/hci_core.h> #include "smp.h" -#include "hci_request.h" #include "hci_debugfs.h" #define DEFINE_QUIRK_ATTRIBUTE (__name, __quirk) \
net/bluetooth/hci_event.c +0 -1
@@ -33,7 +33,6 @@#include <net/bluetooth/hci_core.h> #include <net/bluetooth/mgmt.h> -#include "hci_request.h" #include "hci_debugfs.h" #include "hci_codec.h" #include "smp.h"
net/bluetooth/hci_request.c deleted +0 -903
903 lines not on this page · raw message
net/bluetooth/hci_request.h deleted +0 -71
71 lines not on this page · raw message
net/bluetooth/mgmt.c +0 -1
@@ -33,7 +33,6 @@#include <net/bluetooth/l2cap.h> #include <net/bluetooth/mgmt.h> -#include "hci_request.h" #include "smp.h" #include "mgmt_util.h" #include "mgmt_config.h"
net/bluetooth/msft.c +0 -1
@@ -7,7 +7,6 @@#include <net/bluetooth/hci_core.h> #include <net/bluetooth/mgmt.h> -#include "hci_request.h" #include "mgmt_util.h" #include "msft.h"
Signature · 1 line
2.45.2
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=867299
---Test result---
Test Summary:
CheckPatch FAIL 6.56 seconds GitLint PASS 1.41 seconds SubjectPrefix PASS 0.52 seconds BuildKernel PASS 30.40 seconds CheckAllWarning WARNING 33.38 seconds CheckSparse WARNING 39.04 seconds CheckSmatch WARNING 103.14 seconds BuildKernel32 PASS 29.41 seconds TestRunnerSetup PASS 542.03 seconds TestRunner_l2cap-tester PASS 20.59 seconds TestRunner_iso-tester PASS 42.01 seconds TestRunner_bnep-tester PASS 4.86 seconds TestRunner_mgmt-tester FAIL 116.25 seconds TestRunner_rfcomm-tester PASS 7.83 seconds TestRunner_sco-tester PASS 15.12 seconds TestRunner_ioctl-tester PASS 8.05 seconds TestRunner_mesh-tester PASS 6.00 seconds TestRunner_smp-tester PASS 7.35 seconds TestRunner_userchan-tester PASS 5.15 seconds IncrementalBuild FAIL 75.24 seconds
Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[v1,5/5] Bluetooth: Remove hci_request.{c,h}
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #192:
deleted file mode 100644
total: 0 errors, 1 warnings, 0 checks, 61 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/src/13718647.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.
##############################
Test: CheckAllWarning - WARNING
Desc: Run linux kernel with all warning enabled
Output:net/bluetooth/hci_core.c: In function ‘hci_inquiry’:net/bluetooth/hci_core.c:320:7: warning: variable ‘timeo’ set but not used [-Wunused-but-set-variable] 320 | long timeo; | ^~~~~net/bluetooth/hci_core.c: In function ‘hci_inquiry’:net/bluetooth/hci_core.c:320:7: warning: variable ‘timeo’ set but not used [-Wunused-but-set-variable] 320 | long timeo; | ^~~~~net/bluetooth/hci_core.c: In function ‘hci_inquiry’:net/bluetooth/hci_core.c:320:7: warning: variable ‘timeo’ set but not used [-Wunused-but-set-variable] 320 | long timeo; | ^~~~~net/bluetooth/hci_core.c: In function ‘hci_inquiry’:net/bluetooth/hci_core.c:320:7: warning: variable ‘timeo’ set but not used [-Wunused-but-set-variable] 320 | long timeo; | ^~~~~
##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 492, Passed: 489 (99.4%), Failed: 1, Not Run: 2
Failed Test Cases
LL Privacy - Add Device 4 (2 Devices to AL) Failed 0.168 seconds
##############################
Test: IncrementalBuild - FAIL
Desc: Incremental build with the patches in the series
Output:
[v1,4/5] Bluetooth: hci_sync: Remove remaining dependencies of hci_request
In file included from net/bluetooth/hci_core.c:43:net/bluetooth/hci_request.h:32:8: error: redefinition of ‘struct hci_request’
32 | struct hci_request {
| ^~~~~~~~~~~
In file included from ./include/net/bluetooth/hci_core.h:34,
from net/bluetooth/hci_core.c:39:
./include/net/bluetooth/hci_sync.h:18:8: note: originally defined here
18 | struct hci_request {
| ^~~~~~~~~~~make[4]: *** [scripts/Makefile.build:244: net/bluetooth/hci_core.o] Error 1 make[3]: *** [scripts/Makefile.build:485: net/bluetooth] Error 2 make[2]: *** [scripts/Makefile.build:485: net] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/github/workspace/src/src/Makefile:1934: .] Error 2
make: *** [Makefile:240: __sub-make] Error 2
---
Regards,
Linux Bluetooth