16a98e383SMarcel Holtmann /* SPDX-License-Identifier: GPL-2.0 */ 26a98e383SMarcel Holtmann /* 36a98e383SMarcel Holtmann * BlueZ - Bluetooth protocol stack for Linux 46a98e383SMarcel Holtmann * 56a98e383SMarcel Holtmann * Copyright (C) 2021 Intel Corporation 66a98e383SMarcel Holtmann */ 76a98e383SMarcel Holtmann 86a98e383SMarcel Holtmann typedef int (*hci_cmd_sync_work_func_t)(struct hci_dev *hdev, void *data); 96a98e383SMarcel Holtmann typedef void (*hci_cmd_sync_work_destroy_t)(struct hci_dev *hdev, void *data, 106a98e383SMarcel Holtmann int err); 116a98e383SMarcel Holtmann 126a98e383SMarcel Holtmann struct hci_cmd_sync_work_entry { 136a98e383SMarcel Holtmann struct list_head list; 146a98e383SMarcel Holtmann hci_cmd_sync_work_func_t func; 156a98e383SMarcel Holtmann void *data; 166a98e383SMarcel Holtmann hci_cmd_sync_work_destroy_t destroy; 176a98e383SMarcel Holtmann }; 186a98e383SMarcel Holtmann 196a98e383SMarcel Holtmann /* Function with sync suffix shall not be called with hdev->lock held as they 206a98e383SMarcel Holtmann * wait the command to complete and in the meantime an event could be received 216a98e383SMarcel Holtmann * which could attempt to acquire hdev->lock causing a deadlock. 226a98e383SMarcel Holtmann */ 236a98e383SMarcel Holtmann struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen, 246a98e383SMarcel Holtmann const void *param, u32 timeout); 256a98e383SMarcel Holtmann struct sk_buff *hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen, 266a98e383SMarcel Holtmann const void *param, u32 timeout); 276a98e383SMarcel Holtmann struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen, 286a98e383SMarcel Holtmann const void *param, u8 event, u32 timeout); 296a98e383SMarcel Holtmann struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen, 306a98e383SMarcel Holtmann const void *param, u8 event, u32 timeout, 316a98e383SMarcel Holtmann struct sock *sk); 326a98e383SMarcel Holtmann int __hci_cmd_sync_status(struct hci_dev *hdev, u16 opcode, u32 plen, 336a98e383SMarcel Holtmann const void *param, u32 timeout); 346a98e383SMarcel Holtmann int __hci_cmd_sync_status_sk(struct hci_dev *hdev, u16 opcode, u32 plen, 356a98e383SMarcel Holtmann const void *param, u8 event, u32 timeout, 366a98e383SMarcel Holtmann struct sock *sk); 376a98e383SMarcel Holtmann 386a98e383SMarcel Holtmann void hci_cmd_sync_init(struct hci_dev *hdev); 396a98e383SMarcel Holtmann void hci_cmd_sync_clear(struct hci_dev *hdev); 406a98e383SMarcel Holtmann 416a98e383SMarcel Holtmann int hci_cmd_sync_queue(struct hci_dev *hdev, hci_cmd_sync_work_func_t func, 426a98e383SMarcel Holtmann void *data, hci_cmd_sync_work_destroy_t destroy); 43161510ccSLuiz Augusto von Dentz 44161510ccSLuiz Augusto von Dentz int hci_update_eir_sync(struct hci_dev *hdev); 45161510ccSLuiz Augusto von Dentz int hci_update_class_sync(struct hci_dev *hdev); 46cba6b758SLuiz Augusto von Dentz 47cba6b758SLuiz Augusto von Dentz int hci_update_eir_sync(struct hci_dev *hdev); 48cba6b758SLuiz Augusto von Dentz int hci_update_class_sync(struct hci_dev *hdev); 49cba6b758SLuiz Augusto von Dentz 50cba6b758SLuiz Augusto von Dentz int hci_update_random_address_sync(struct hci_dev *hdev, bool require_privacy, 51cba6b758SLuiz Augusto von Dentz bool rpa, u8 *own_addr_type); 52cba6b758SLuiz Augusto von Dentz 53cba6b758SLuiz Augusto von Dentz int hci_update_scan_rsp_data_sync(struct hci_dev *hdev, u8 instance); 54cba6b758SLuiz Augusto von Dentz int hci_update_adv_data_sync(struct hci_dev *hdev, u8 instance); 55cba6b758SLuiz Augusto von Dentz int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance, 56cba6b758SLuiz Augusto von Dentz bool force); 57cba6b758SLuiz Augusto von Dentz 58cba6b758SLuiz Augusto von Dentz int hci_setup_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance); 59cba6b758SLuiz Augusto von Dentz int hci_start_ext_adv_sync(struct hci_dev *hdev, u8 instance); 60cba6b758SLuiz Augusto von Dentz int hci_enable_ext_advertising_sync(struct hci_dev *hdev, u8 instance); 61cba6b758SLuiz Augusto von Dentz int hci_enable_advertising_sync(struct hci_dev *hdev); 62cba6b758SLuiz Augusto von Dentz 63cba6b758SLuiz Augusto von Dentz int hci_remove_advertising_sync(struct hci_dev *hdev, struct sock *sk, 64cba6b758SLuiz Augusto von Dentz u8 instance, bool force); 65cba6b758SLuiz Augusto von Dentz int hci_disable_advertising_sync(struct hci_dev *hdev); 66e8907f76SLuiz Augusto von Dentz 67e8907f76SLuiz Augusto von Dentz int hci_update_passive_scan_sync(struct hci_dev *hdev); 68ad383c2cSLuiz Augusto von Dentz int hci_update_passive_scan(struct hci_dev *hdev); 69*cf75ad8bSLuiz Augusto von Dentz 70*cf75ad8bSLuiz Augusto von Dentz int hci_dev_open_sync(struct hci_dev *hdev); 71*cf75ad8bSLuiz Augusto von Dentz int hci_dev_close_sync(struct hci_dev *hdev); 72*cf75ad8bSLuiz Augusto von Dentz 73*cf75ad8bSLuiz Augusto von Dentz int hci_powered_update_sync(struct hci_dev *hdev); 74*cf75ad8bSLuiz Augusto von Dentz int hci_set_powered_sync(struct hci_dev *hdev, u8 val); 75