Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: centralize default value initialization.

This patch centralized the initialization of default parameters. This
is required to allow clients to more easily customize the default
system parameters.

Signed-off-by: Alain Michaud <alainm@chromium.org>
Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by

Alain Michaud and committed by
Marcel Holtmann
10873f99 7e90de4a

+40 -21
+18
include/net/bluetooth/hci_core.h
··· 295 295 __u8 le_scan_type; 296 296 __u16 le_scan_interval; 297 297 __u16 le_scan_window; 298 + __u16 le_scan_int_suspend; 299 + __u16 le_scan_window_suspend; 300 + __u16 le_scan_int_discovery; 301 + __u16 le_scan_window_discovery; 302 + __u16 le_scan_int_adv_monitor; 303 + __u16 le_scan_window_adv_monitor; 304 + __u16 le_scan_int_connect; 305 + __u16 le_scan_window_connect; 298 306 __u16 le_conn_min_interval; 299 307 __u16 le_conn_max_interval; 300 308 __u16 le_conn_latency; ··· 330 322 __u16 devid_vendor; 331 323 __u16 devid_product; 332 324 __u16 devid_version; 325 + 326 + __u8 def_page_scan_type; 327 + __u16 def_page_scan_int; 328 + __u16 def_page_scan_window; 329 + __u8 def_inq_scan_type; 330 + __u16 def_inq_scan_int; 331 + __u16 def_inq_scan_window; 332 + __u16 def_br_lsto; 333 + __u16 def_page_timeout; 334 + __u16 def_multi_adv_rotation_duration; 333 335 334 336 __u16 pkt_type; 335 337 __u16 esco_type;
+4 -10
net/bluetooth/hci_conn.c
··· 789 789 790 790 memset(p, 0, sizeof(*p)); 791 791 792 - /* Set window to be the same value as the interval to 793 - * enable continuous scanning. 794 - */ 795 - p->scan_interval = cpu_to_le16(hdev->le_scan_interval); 796 - p->scan_window = p->scan_interval; 792 + p->scan_interval = cpu_to_le16(hdev->le_scan_int_connect); 793 + p->scan_window = cpu_to_le16(hdev->le_scan_window_connect); 797 794 p->conn_interval_min = cpu_to_le16(conn->le_conn_min_interval); 798 795 p->conn_interval_max = cpu_to_le16(conn->le_conn_max_interval); 799 796 p->conn_latency = cpu_to_le16(conn->le_conn_latency); ··· 872 875 873 876 memset(&cp, 0, sizeof(cp)); 874 877 875 - /* Set window to be the same value as the interval to enable 876 - * continuous scanning. 877 - */ 878 - cp.scan_interval = cpu_to_le16(hdev->le_scan_interval); 879 - cp.scan_window = cp.scan_interval; 878 + cp.scan_interval = cpu_to_le16(hdev->le_scan_int_connect); 879 + cp.scan_window = cpu_to_le16(hdev->le_scan_window_connect); 880 880 881 881 bacpy(&cp.peer_addr, &conn->dst); 882 882 cp.peer_addr_type = conn->dst_type;
+13 -1
net/bluetooth/hci_core.c
··· 2982 2982 adv_instance->remaining_time = timeout; 2983 2983 2984 2984 if (duration == 0) 2985 - adv_instance->duration = HCI_DEFAULT_ADV_DURATION; 2985 + adv_instance->duration = hdev->def_multi_adv_rotation_duration; 2986 2986 else 2987 2987 adv_instance->duration = duration; 2988 2988 ··· 3400 3400 hdev->le_adv_max_interval = 0x0800; 3401 3401 hdev->le_scan_interval = 0x0060; 3402 3402 hdev->le_scan_window = 0x0030; 3403 + hdev->le_scan_int_suspend = 0x0400; 3404 + hdev->le_scan_window_suspend = 0x0012; 3405 + hdev->le_scan_int_discovery = DISCOV_LE_SCAN_INT; 3406 + hdev->le_scan_window_discovery = DISCOV_LE_SCAN_WIN; 3407 + hdev->le_scan_int_connect = 0x0060; 3408 + hdev->le_scan_window_connect = 0x0060; 3403 3409 hdev->le_conn_min_interval = 0x0018; 3404 3410 hdev->le_conn_max_interval = 0x0028; 3405 3411 hdev->le_conn_latency = 0x0000; ··· 3421 3415 hdev->le_tx_def_phys = HCI_LE_SET_PHY_1M; 3422 3416 hdev->le_rx_def_phys = HCI_LE_SET_PHY_1M; 3423 3417 hdev->le_num_of_adv_sets = HCI_MAX_ADV_INSTANCES; 3418 + hdev->def_multi_adv_rotation_duration = HCI_DEFAULT_ADV_DURATION; 3424 3419 3425 3420 hdev->rpa_timeout = HCI_DEFAULT_RPA_TIMEOUT; 3426 3421 hdev->discov_interleaved_timeout = DISCOV_INTERLEAVED_TIMEOUT; ··· 3429 3422 hdev->conn_info_max_age = DEFAULT_CONN_INFO_MAX_AGE; 3430 3423 hdev->auth_payload_timeout = DEFAULT_AUTH_PAYLOAD_TIMEOUT; 3431 3424 hdev->min_enc_key_size = HCI_MIN_ENC_KEY_SIZE; 3425 + 3426 + /* default 1.28 sec page scan */ 3427 + hdev->def_page_scan_type = PAGE_SCAN_TYPE_STANDARD; 3428 + hdev->def_page_scan_int = 0x0800; 3429 + hdev->def_page_scan_window = 0x0012; 3432 3430 3433 3431 mutex_init(&hdev->lock); 3434 3432 mutex_init(&hdev->req_lock);
+5 -10
net/bluetooth/hci_request.c
··· 34 34 #define HCI_REQ_PEND 1 35 35 #define HCI_REQ_CANCELED 2 36 36 37 - #define LE_SUSPEND_SCAN_WINDOW 0x0012 38 - #define LE_SUSPEND_SCAN_INTERVAL 0x0400 39 - 40 37 void hci_req_init(struct hci_request *req, struct hci_dev *hdev) 41 38 { 42 39 skb_queue_head_init(&req->cmd_q); ··· 363 366 /* 160 msec page scan interval */ 364 367 acp.interval = cpu_to_le16(0x0100); 365 368 } else { 366 - type = PAGE_SCAN_TYPE_STANDARD; /* default */ 367 - 368 - /* default 1.28 sec page scan */ 369 - acp.interval = cpu_to_le16(0x0800); 369 + type = hdev->def_page_scan_type; 370 + acp.interval = cpu_to_le16(hdev->def_page_scan_int); 370 371 } 371 372 372 - acp.window = cpu_to_le16(0x0012); 373 + acp.window = cpu_to_le16(hdev->def_page_scan_window); 373 374 374 375 if (__cpu_to_le16(hdev->page_scan_interval) != acp.interval || 375 376 __cpu_to_le16(hdev->page_scan_window) != acp.window) ··· 922 927 filter_policy |= 0x02; 923 928 924 929 if (hdev->suspended) { 925 - window = LE_SUSPEND_SCAN_WINDOW; 926 - interval = LE_SUSPEND_SCAN_INTERVAL; 930 + window = hdev->le_scan_window_suspend; 931 + interval = hdev->le_scan_int_suspend; 927 932 } else { 928 933 window = hdev->le_scan_window; 929 934 interval = hdev->le_scan_interval;