Bluetooth: Split hci_update_page_scan into two functions
Subsystems (2)
PATCH 1/2 Bluetooth: Split hci_update_page_scan into two functions
From: Johan Hedberg <[email protected]>
To keep the parameter list and its semantics clear it makes sense to split the hci_update_page_scan function into two separate functions: one taking a hci_dev and another taking a hci_request. The one taking a hci_dev constructs its own hci_request and then calls the other function.
--- include/net/bluetooth/hci_core.h | 3 ++- net/bluetooth/hci_core.c | 17 ++++++++++++----- net/bluetooth/hci_event.c | 4 ++-- net/bluetooth/mgmt.c | 16 ++++++++-------- 4 files changed, 24 insertions(+), 16 deletions(-)
include/net/bluetooth/hci_core.h +2 -1
@@ -1306,7 +1306,8 @@ bool hci_req_pending(struct hci_dev *hdev);void hci_req_add_le_scan_disable (struct hci_request *req);void hci_req_add_le_passive_scan (struct hci_request *req); -void hci_update_page_scan (struct hci_dev *hdev,struct hci_request *req); +void hci_update_page_scan (struct hci_dev *hdev); +void __hci_update_page_scan (struct hci_request *req);struct sk_buff *__hci_cmd_sync (struct hci_dev *hdev,u16 opcode,u32 plen,const void *param,u32 timeout);
net/bluetooth/hci_core.c +12 -5
@@ -5787,8 +5787,9 @@ static bool disconnected_whitelist_entries(struct hci_dev *hdev)return false; } -void hci_update_page_scan (struct hci_dev *hdev,struct hci_request *req) +void __hci_update_page_scan (struct hci_request *req) { +struct hci_dev *hdev = req->hdev;u8 scan;if (!test_bit (HCI_BREDR_ENABLED , &hdev->dev_flags))
@@ -5812,8 +5813,14 @@ void hci_update_page_scan(struct hci_dev *hdev, struct hci_request *req)if (test_bit (HCI_DISCOVERABLE , &hdev->dev_flags)) scan |=SCAN_INQUIRY ; -if (req) -hci_req_add (req,HCI_OP_WRITE_SCAN_ENABLE ,1 , &scan); -else -hci_send_cmd (hdev,HCI_OP_WRITE_SCAN_ENABLE ,1 , &scan); +hci_req_add (req,HCI_OP_WRITE_SCAN_ENABLE ,1 , &scan); +} + +void hci_update_page_scan (struct hci_dev *hdev) +{ +struct hci_request req; + +hci_req_init (&req, hdev); +__hci_update_page_scan (&req); +hci_req_run (&req,NULL ); }
net/bluetooth/hci_event.c +2 -2
@@ -2127,7 +2127,7 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)hci_send_cmd (hdev,HCI_OP_READ_REMOTE_FEATURES ,sizeof (cp), &cp); -hci_update_page_scan (hdev,NULL ); +hci_update_page_scan (hdev); }/* Set packet type for incoming connection */
@@ -2308,7 +2308,7 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)if (test_bit (HCI_CONN_FLUSH_KEY , &conn->flags))hci_remove_link_key (hdev, &conn->dst); -hci_update_page_scan (hdev,NULL ); +hci_update_page_scan (hdev); } params =hci_conn_params_lookup (hdev, &conn->dst, conn->dst_type);
net/bluetooth/mgmt.c +8 -8
@@ -1566,7 +1566,7 @@ static void set_discoverable_complete(struct hci_dev *hdev, u8 status)* entries. */ hci_req_init (&req, hdev); -hci_update_page_scan (hdev, &req); +__hci_update_page_scan (&req);update_class (&req);hci_req_run (&req,NULL );
@@ -1813,7 +1813,7 @@ static void set_connectable_complete(struct hci_dev *hdev, u8 status)if (conn_changed || discov_changed) {new_settings (hdev, cmd->sk); -hci_update_page_scan (hdev,NULL ); +hci_update_page_scan (hdev);if (discov_changed)mgmt_update_adv_data (hdev);hci_update_background_scan (hdev);
@@ -1847,7 +1847,7 @@ static int set_connectable_update_settings(struct hci_dev *hdev,return err;if (changed) { -hci_update_page_scan (hdev,NULL ); +hci_update_page_scan (hdev);hci_update_background_scan (hdev);return new_settings (hdev, sk); }
@@ -4697,7 +4697,7 @@ static int set_bredr(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)hci_req_init (&req, hdev);write_fast_connectable (&req, false); -hci_update_page_scan (hdev, &req); +__hci_update_page_scan (&req);/* Since only the advertising data flags will change, there * is no need to update the scan response data.
@@ -5473,7 +5473,7 @@ static int add_device(struct sock *sk, struct hci_dev *hdev,if (err) goto unlock; -hci_update_page_scan (hdev,NULL ); +hci_update_page_scan (hdev); goto added; }
@@ -5556,7 +5556,7 @@ static int remove_device(struct sock *sk, struct hci_dev *hdev, goto unlock; } -hci_update_page_scan (hdev,NULL ); +hci_update_page_scan (hdev);device_removed (sk, hdev, &cp->addr.bdaddr, cp->addr.type);
@@ -5607,7 +5607,7 @@ static int remove_device(struct sock *sk, struct hci_dev *hdev,kfree (b); } -hci_update_page_scan (hdev,NULL ); +hci_update_page_scan (hdev);list_for_each_entry_safe (p, tmp, &hdev->le_conn_params, list) {if (p->auto_connect ==HCI_AUTO_CONN_DISABLED )
@@ -6139,7 +6139,7 @@ static int powered_update_hci(struct hci_dev *hdev)if (lmp_bredr_capable (hdev)) {write_fast_connectable (&req, false); -hci_update_page_scan (hdev, &req); +__hci_update_page_scan (&req);update_class (&req);update_name (&req);update_eir (&req);
Signature · 1 line
2.1.0
PATCH 2/2 Bluetooth: Split hci_request helpers to hci_request.[ch]
From: Johan Hedberg <[email protected]>
None of the hci_request related things in net/bluetooth/hci_core.h are needed anywhere outside of the core bluetooth module. This patch creates a new net/bluetooth/hci_request.c file with its corresponding h-file and moves the functionality there from hci_core.c and hci_core.h.
--- include/net/bluetooth/hci_core.h | 25 --- net/bluetooth/Makefile | 2 +- net/bluetooth/hci_conn.c | 1 + net/bluetooth/hci_core.c | 370 +----------------------------------- net/bluetooth/hci_event.c | 1 + net/bluetooth/hci_request.c | 397 +++++++++++++++++++++++++++++++++++++++ net/bluetooth/hci_request.h | 51 +++++ net/bluetooth/mgmt.c | 1 + 8 files changed, 453 insertions(+), 395 deletions(-) create mode 100644 net/bluetooth/hci_request.c create mode 100644 net/bluetooth/hci_request.h
include/net/bluetooth/hci_core.h +0 -25
@@ -1284,31 +1284,8 @@ static inline int hci_check_conn_params(u16 min, u16 max, u16 latency,int hci_register_cb (struct hci_cb *hcb);int hci_unregister_cb (struct hci_cb *hcb); -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; -}; - -void hci_req_init (struct hci_request *req,struct hci_dev *hdev); -int hci_req_run (struct hci_request *req,hci_req_complete_t complete); -void hci_req_add (struct hci_request *req,u16 opcode,u32 plen, -const void *param); -void hci_req_add_ev (struct hci_request *req,u16 opcode,u32 plen, -const void *param,u8 event); -void hci_req_cmd_complete (struct hci_dev *hdev,u16 opcode,u8 status);bool hci_req_pending (struct hci_dev *hdev); -void hci_req_add_le_scan_disable (struct hci_request *req); -void hci_req_add_le_passive_scan (struct hci_request *req); - -void hci_update_page_scan (struct hci_dev *hdev); -void __hci_update_page_scan (struct hci_request *req); -struct sk_buff *__hci_cmd_sync (struct hci_dev *hdev,u16 opcode,u32 plen,const void *param,u32 timeout); struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen,
@@ -1418,8 +1395,6 @@ u8 hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, u16 latency,void hci_le_start_enc (struct hci_conn *conn,__le16 ediv,__le64 rand,__u8 ltk[16 ]); -int hci_update_random_address (struct hci_request *req,bool require_privacy, -u8 *own_addr_type);void hci_copy_identity_address (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 *bdaddr_type);
net/bluetooth/Makefile +1 -1
@@ -13,6 +13,6 @@ 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 sco.o lib.o \ - a2mp.o amp.o ecc.o + a2mp.o amp.o ecc.o hci_request.o subdir-ccflags-y += -D__CHECK_ENDIAN__
net/bluetooth/hci_conn.c +1 -0
@@ -30,6 +30,7 @@#include <net/bluetooth/hci_core.h> #include <net/bluetooth/l2cap.h> +#include "hci_request.h" #include "smp.h" #include "a2mp.h"
net/bluetooth/hci_core.c +1 -369
405 lines not on this page · raw message
net/bluetooth/hci_event.c +1 -0
@@ -30,6 +30,7 @@#include <net/bluetooth/hci_core.h> #include <net/bluetooth/mgmt.h> +#include "hci_request.h" #include "a2mp.h" #include "amp.h" #include "smp.h"
net/bluetooth/hci_request.c new file +397 -0
397 lines not on this page · raw message
net/bluetooth/hci_request.h new file +51 -0
51 lines not on this page · raw message
net/bluetooth/mgmt.c +1 -0
@@ -32,6 +32,7 @@#include <net/bluetooth/l2cap.h> #include <net/bluetooth/mgmt.h> +#include "hci_request.h" #include "smp.h" #define MGMT_VERSION 1
Signature · 1 line
2.1.0
Marcel Holtmann
maintainerRe: [PATCH 2/2] Bluetooth: Split hci_request helpers to hci_request.[ch]
Hi Johan,
Quoted 16 lines
None of the
hci_requestrelated things innet/bluetooth/hci_core.hare needed anywhere outside of the core bluetooth module. This patch creates a newnet/bluetooth/hci_request.cfile with its corresponding h-file and moves the functionality there fromhci_core.candhci_core.h.Signed-off-by Johan Hedberg <[email protected]>---
include/net/bluetooth/hci_core.h | 25 --- net/bluetooth/Makefile | 2 +- net/bluetooth/hci_conn.c | 1 + net/bluetooth/hci_core.c | 370 +----------------------------------- net/bluetooth/hci_event.c | 1 + net/bluetooth/hci_request.c | 397 +++++++++++++++++++++++++++++++++++++++ net/bluetooth/hci_request.h | 51 +++++ net/bluetooth/mgmt.c | 1 + 8 files changed, 453 insertions(+), 395 deletions(-)
Quoted 2 lines
create mode 100644
net/bluetooth/hci_request.c
create mode 100644net/bluetooth/hci_request.h
patch has been applied to bluetooth-next tree.
Regards
Marcel
Marcel Holtmann
maintainerHi Johan,
Quoted 6 lines
To keep the parameter list and its semantics clear it makes sense to split the
hci_update_page_scanfunction into two separate functions: one taking ahci_devand another taking ahci_request. The one taking ahci_devconstructs its ownhci_requestand then calls the other function.
Quoted 7 lines
Signed-off-by Johan Hedberg <[email protected]>---
include/net/bluetooth/hci_core.h | 3 ++- net/bluetooth/hci_core.c | 17 ++++++++++++----- net/bluetooth/hci_event.c | 4 ++-- net/bluetooth/mgmt.c | 16 ++++++++-------- 4 files changed, 24 insertions(+), 16 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel