Clean-up stale/unused hci_request.c code
Subsystems (2)
cover Clean-up stale/unused hci_request.c code
This will be a growing patch-set of conversions and dead-code removal towards the goal of retiring hci_request.c
The patch sets will be split amoung the work queues and delayed work queues as initialized in hci_request_setup(), with the ultimate goal of eliminating hci_request.c entirely.
Brian Gix (3):
Bluetooth: Remove dead code from hci_request.c
Bluetooth: Remove update_scan hci_request dependancy
Bluetooth: Convert delayed discov_off to hci_sync
include/net/bluetooth/hci_core.h | 2 - include/net/bluetooth/hci_sync.h | 1 + net/bluetooth/hci_event.c | 4 +- net/bluetooth/hci_request.c | 417 ------------------------------- net/bluetooth/hci_request.h | 7 - net/bluetooth/hci_sync.c | 10 + net/bluetooth/mgmt.c | 40 ++- 7 files changed, 49 insertions(+), 432 deletions(-)
Signature · 1 line
2.36.1
PATCH 1/3 Bluetooth: Remove dead code from hci_request.c
The discov_update work queue is no longer used as a result of the hci_sync rework.
The __hci_req_hci_power_on() function is no longer referenced in the code as a result of the hci_sync rework.
--- include/net/bluetooth/hci_core.h | 1 - net/bluetooth/hci_request.c | 311 ------------------------------- net/bluetooth/hci_request.h | 2 - 3 files changed, 314 deletions(-)
include/net/bluetooth/hci_core.h +0 -1
@@ -523,7 +523,6 @@ struct hci_dev {struct work_struct cmd_work;struct work_struct tx_work; -struct work_struct discov_update;struct work_struct scan_update;struct delayed_work le_scan_disable;struct delayed_work le_scan_restart;
net/bluetooth/hci_request.c +0 -311
337 lines not on this page · raw message
net/bluetooth/hci_request.h +0 -2
@@ -68,8 +68,6 @@ int __hci_req_sync(struct hci_dev *hdev, int (*func)(struct hci_request *req,struct sk_buff *hci_prepare_cmd (struct hci_dev *hdev,u16 opcode,u32 plen,const void *param); -int __hci_req_hci_power_on (struct hci_dev *hdev); -void __hci_req_write_fast_connectable (struct hci_request *req,bool enable);void __hci_req_update_name (struct hci_request *req);void __hci_req_update_eir (struct hci_request *req);
Signature · 1 line
2.36.1
This is an automated email and please do not reply to this email.
Dear Submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.
----- Output -----
error: patch failed: net/bluetooth/hci_request.c:2269
error: net/bluetooth/hci_request.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch
Please resolve the issue and submit the patches again.
---
Regards,
Linux Bluetooth
PATCH 2/3 Bluetooth: Remove update_scan hci_request dependancy
In reply to Brian GixThis removes the remaining calls to HCI_OP_WRITE_SCAN_ENABLE from hci_request call chains, and converts them to hci_sync calls.
--- include/net/bluetooth/hci_core.h | 1 - include/net/bluetooth/hci_sync.h | 1 + net/bluetooth/hci_event.c | 4 ++-- net/bluetooth/hci_request.c | 17 ----------------- net/bluetooth/hci_request.h | 5 ----- net/bluetooth/hci_sync.c | 10 ++++++++++ net/bluetooth/mgmt.c | 8 ++++---- 7 files changed, 17 insertions(+), 29 deletions(-)
include/net/bluetooth/hci_core.h +0 -1
@@ -523,7 +523,6 @@ struct hci_dev {struct work_struct cmd_work;struct work_struct tx_work; -struct work_struct scan_update;struct delayed_work le_scan_disable;struct delayed_work le_scan_restart;
include/net/bluetooth/hci_sync.h +1 -0
@@ -78,6 +78,7 @@ int hci_read_clock_sync(struct hci_dev *hdev, struct hci_cp_read_clock *cp);int hci_write_fast_connectable_sync (struct hci_dev *hdev,bool enable);int hci_update_scan_sync (struct hci_dev *hdev); +int hci_update_scan (struct hci_dev *hdev);int hci_write_le_host_supported_sync (struct hci_dev *hdev,u8 le,u8 simul); int hci_remove_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance,
net/bluetooth/hci_event.c +2 -2
@@ -3178,7 +3178,7 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, void *data,hci_send_cmd (hdev,HCI_OP_READ_REMOTE_FEATURES ,sizeof (cp), &cp); -hci_req_update_scan (hdev); +hci_update_scan (hdev); }/* Set packet type for incoming connection */
@@ -3376,7 +3376,7 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, void *data,if (test_and_clear_bit (HCI_CONN_FLUSH_KEY , &conn->flags))hci_remove_link_key (hdev, &conn->dst); -hci_req_update_scan (hdev); +hci_update_scan (hdev); } params =hci_conn_params_lookup (hdev, &conn->dst, conn->dst_type);
net/bluetooth/hci_request.c +0 -17
@@ -1863,21 +1863,6 @@ void __hci_req_update_scan(struct hci_request *req)hci_req_add (req,HCI_OP_WRITE_SCAN_ENABLE ,1 , &scan); } -static int update_scan (struct hci_request *req,unsigned long opt) -{ -hci_dev_lock (req->hdev); -__hci_req_update_scan (req); -hci_dev_unlock (req->hdev); -return 0 ; -} - -static void scan_update_work (struct work_struct *work) -{ - struct hci_dev *hdev = container_of(work, struct hci_dev, scan_update); - -hci_req_sync (hdev, update_scan,0 ,HCI_CMD_TIMEOUT ,NULL ); -} -static u8 get_service_classes (struct hci_dev *hdev) {struct bt_uuid *uuid;
@@ -2390,7 +2375,6 @@ static void discov_off(struct work_struct *work)void hci_request_setup (struct hci_dev *hdev) { -INIT_WORK (&hdev->scan_update, scan_update_work);INIT_DELAYED_WORK (&hdev->discov_off, discov_off);INIT_DELAYED_WORK (&hdev->le_scan_disable, le_scan_disable_work);INIT_DELAYED_WORK (&hdev->le_scan_restart, le_scan_restart_work);
@@ -2402,7 +2386,6 @@ void hci_request_cancel_all(struct hci_dev *hdev) {__hci_cmd_sync_cancel (hdev,ENODEV ); -cancel_work_sync (&hdev->scan_update);cancel_delayed_work_sync (&hdev->discov_off);cancel_delayed_work_sync (&hdev->le_scan_disable);cancel_delayed_work_sync (&hdev->le_scan_restart);
net/bluetooth/hci_request.h +0 -5
@@ -108,11 +108,6 @@ bool hci_req_stop_discovery(struct hci_request *req);int hci_req_configure_datapath (struct hci_dev *hdev,struct bt_codec *codec); -static inline void hci_req_update_scan (struct hci_dev *hdev) -{ -queue_work (hdev->req_workqueue, &hdev->scan_update); -} -void __hci_req_update_scan (struct hci_request *req); int hci_update_random_address(struct hci_request *req, bool require_privacy,
net/bluetooth/hci_sync.c +10 -0
@@ -2259,6 +2259,16 @@ int hci_update_passive_scan_sync(struct hci_dev *hdev)return err; } +static int update_scan_sync (struct hci_dev *hdev,void *data) +{ +return hci_update_scan_sync (hdev); +} + +int hci_update_scan (struct hci_dev *hdev) +{ +return hci_cmd_sync_queue (hdev, update_scan_sync,NULL ,NULL ); +} +static int update_passive_scan_sync (struct hci_dev *hdev,void *data) {return hci_update_passive_scan_sync (hdev);
net/bluetooth/mgmt.c +4 -4
@@ -1675,7 +1675,7 @@ static int set_connectable_update_settings(struct hci_dev *hdev,return err;if (changed) { -hci_req_update_scan (hdev); +hci_update_scan (hdev);hci_update_passive_scan (hdev);return new_settings (hdev, sk); }
@@ -7575,7 +7575,7 @@ static int add_device(struct sock *sk, struct hci_dev *hdev,if (err) goto unlock; -hci_req_update_scan (hdev); +hci_update_scan (hdev); goto added; }
@@ -7689,7 +7689,7 @@ static int remove_device(struct sock *sk, struct hci_dev *hdev, goto unlock; } -hci_req_update_scan (hdev); +hci_update_scan (hdev);device_removed (sk, hdev, &cp->addr.bdaddr, cp->addr.type);
@@ -7753,7 +7753,7 @@ static int remove_device(struct sock *sk, struct hci_dev *hdev,kfree (b); } -hci_req_update_scan (hdev); +hci_update_scan (hdev);list_for_each_entry_safe (p, tmp, &hdev->le_conn_params, list) {if (p->auto_connect ==HCI_AUTO_CONN_DISABLED )
Signature · 1 line
2.36.1
PATCH 3/3 Bluetooth: Convert delayed discov_off to hci_sync
In reply to Brian GixThe timed ending of Discoverability was handled in hci_requst.c, with calls using the deprecated hci_req_add() mechanism. Converted to live inside mgmt.c using the same delayed work queue, but with hci_sync version of hci_update_discoverable().
--- net/bluetooth/hci_request.c | 89 ------------------------------------- net/bluetooth/mgmt.c | 32 +++++++++++++ 2 files changed, 32 insertions(+), 89 deletions(-)
net/bluetooth/hci_request.c +0 -89
@@ -1903,69 +1903,6 @@ void __hci_req_update_class(struct hci_request *req)hci_req_add (req,HCI_OP_WRITE_CLASS_OF_DEV ,sizeof (cod), cod); } -static void write_iac (struct hci_request *req) -{ -struct hci_dev *hdev = req->hdev; -struct hci_cp_write_current_iac_lap cp; - -if (!hci_dev_test_flag (hdev,HCI_DISCOVERABLE )) -return ; - -if (hci_dev_test_flag (hdev,HCI_LIMITED_DISCOVERABLE )) { -/* Limited discoverable mode */ - cp.num_iac =min_t (u8, hdev->num_iac,2 ); - cp.iac_lap[0 ] =0x00 ;/* LIAC */ - cp.iac_lap[1 ] =0x8b ; - cp.iac_lap[2 ] =0x9e ; - cp.iac_lap[3 ] =0x33 ;/* GIAC */ - cp.iac_lap[4 ] =0x8b ; - cp.iac_lap[5 ] =0x9e ; - }else { -/* General discoverable mode */ - cp.num_iac =1 ; - cp.iac_lap[0 ] =0x33 ;/* GIAC */ - cp.iac_lap[1 ] =0x8b ; - cp.iac_lap[2 ] =0x9e ; - } - -hci_req_add (req,HCI_OP_WRITE_CURRENT_IAC_LAP , - (cp.num_iac *3 ) +1 , &cp); -} - -static int discoverable_update (struct hci_request *req,unsigned long opt) -{ -struct hci_dev *hdev = req->hdev; - -hci_dev_lock (hdev); - -if (hci_dev_test_flag (hdev,HCI_BREDR_ENABLED )) { -write_iac (req); -__hci_req_update_scan (req); -__hci_req_update_class (req); - } - -/* Advertising instances don't use the global discoverable setting, so -* only update AD if advertising was enabled using Set Advertising. -*/ -if (hci_dev_test_flag (hdev,HCI_ADVERTISING )) { -__hci_req_update_adv_data (req,0x00 ); - -/* Discoverable mode affects the local advertising -* address in limited privacy mode. -*/ -if (hci_dev_test_flag (hdev,HCI_LIMITED_PRIVACY )) { -if (ext_adv_capable (hdev)) -__hci_req_start_ext_adv (req,0x00 ); -else -__hci_req_enable_advertising (req); - } - } - -hci_dev_unlock (hdev); - -return 0 ; -} -void __hci_abort_conn (struct hci_request *req,struct hci_conn *conn,u8 reason) {
@@ -2349,33 +2286,8 @@ int hci_req_configure_datapath(struct hci_dev *hdev, struct bt_codec *codec)return err; } -static void discov_off (struct work_struct *work) -{ - struct hci_dev *hdev = container_of(work, struct hci_dev, - discov_off.work); - -bt_dev_dbg (hdev,"" ); - -hci_dev_lock (hdev); - -/* When discoverable timeout triggers, then just make sure -* the limited discoverable flag is cleared. Even in the case -* of a timeout triggered from general discoverable, it is -* safe to unconditionally clear the flag. -*/ -hci_dev_clear_flag (hdev,HCI_LIMITED_DISCOVERABLE ); -hci_dev_clear_flag (hdev,HCI_DISCOVERABLE ); - hdev->discov_timeout =0 ; - -hci_dev_unlock (hdev); - -hci_req_sync (hdev, discoverable_update,0 ,HCI_CMD_TIMEOUT ,NULL ); -mgmt_new_settings (hdev); -} -void hci_request_setup (struct hci_dev *hdev) { -INIT_DELAYED_WORK (&hdev->discov_off, discov_off);INIT_DELAYED_WORK (&hdev->le_scan_disable, le_scan_disable_work);INIT_DELAYED_WORK (&hdev->le_scan_restart, le_scan_restart_work);INIT_DELAYED_WORK (&hdev->adv_instance_expire, adv_timeout_expire);
@@ -2386,7 +2298,6 @@ void hci_request_cancel_all(struct hci_dev *hdev) {__hci_cmd_sync_cancel (hdev,ENODEV ); -cancel_delayed_work_sync (&hdev->discov_off);cancel_delayed_work_sync (&hdev->le_scan_disable);cancel_delayed_work_sync (&hdev->le_scan_restart);
net/bluetooth/mgmt.c +32 -0
@@ -1084,6 +1084,31 @@ static void mesh_send_done(struct work_struct *work)hci_cmd_sync_queue (hdev, mesh_send_done_sync,NULL , mesh_next); } +static void discov_off (struct work_struct *work) +{ + struct hci_dev *hdev = container_of(work, struct hci_dev, + discov_off.work); + +bt_dev_dbg (hdev,"" ); + +hci_dev_lock (hdev); + +/* When discoverable timeout triggers, then just make sure +* the limited discoverable flag is cleared. Even in the case +* of a timeout triggered from general discoverable, it is +* safe to unconditionally clear the flag. +*/ +hci_dev_clear_flag (hdev,HCI_LIMITED_DISCOVERABLE ); +hci_dev_clear_flag (hdev,HCI_DISCOVERABLE ); + hdev->discov_timeout =0 ; + +hci_update_discoverable (hdev); + +mgmt_new_settings (hdev); + +hci_dev_unlock (hdev); +} +static void mgmt_init_hdev (struct sock *sk,struct hci_dev *hdev) {if (hci_dev_test_and_set_flag (hdev,HCI_MGMT ))
@@ -1091,6 +1116,7 @@ static void mgmt_init_hdev(struct sock *sk, struct hci_dev *hdev)BT_INFO ("MGMT ver %d.%d" ,MGMT_VERSION ,MGMT_REVISION ); +INIT_DELAYED_WORK (&hdev->discov_off, discov_off);INIT_DELAYED_WORK (&hdev->service_cache, service_cache_off);INIT_DELAYED_WORK (&hdev->rpa_expired, rpa_expired);INIT_DELAYED_WORK (&hdev->mesh_send_done, mesh_send_done);
@@ -9345,6 +9371,12 @@ void mgmt_index_removed(struct hci_dev *hdev)mgmt_index_event (MGMT_EV_EXT_INDEX_REMOVED , hdev, &ev,sizeof (ev),HCI_MGMT_EXT_INDEX_EVENTS ); + +/* Cancel any remaining timed work */ +cancel_delayed_work_sync (&hdev->discov_off); +cancel_delayed_work_sync (&hdev->service_cache); +cancel_delayed_work_sync (&hdev->rpa_expired); +cancel_delayed_work_sync (&hdev->mesh_send_done); }void mgmt_power_on (struct hci_dev *hdev,int err)
Signature · 1 line
2.36.1