Bluetooth: Add hci_cmd_sync_cancel to public API
authorBenjamin Berg <bberg@redhat.com>
Fri, 3 Dec 2021 14:59:00 +0000 (15:59 +0100)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 3 Dec 2021 18:41:59 +0000 (10:41 -0800)
After transfer errors it makes sense to cancel an ongoing synchronous
command that cannot complete anymore. To permit this, export the old
hci_req_sync_cancel function as hci_cmd_sync_cancel in the API.

Signed-off-by: Benjamin Berg <bberg@redhat.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
include/net/bluetooth/hci_sync.h
net/bluetooth/hci_request.c
net/bluetooth/hci_request.h
net/bluetooth/hci_sync.c

index 0336c1b..f4034bf 100644 (file)
@@ -37,6 +37,7 @@ int __hci_cmd_sync_status_sk(struct hci_dev *hdev, u16 opcode, u32 plen,
 
 void hci_cmd_sync_init(struct hci_dev *hdev);
 void hci_cmd_sync_clear(struct hci_dev *hdev);
+void hci_cmd_sync_cancel(struct hci_dev *hdev, int err);
 
 int hci_cmd_sync_queue(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
                       void *data, hci_cmd_sync_work_destroy_t destroy);
index 58d640a..a2607db 100644 (file)
@@ -111,22 +111,6 @@ void hci_req_sync_complete(struct hci_dev *hdev, u8 result, u16 opcode,
        }
 }
 
-void hci_req_sync_cancel(struct hci_dev *hdev, int err)
-{
-       bt_dev_dbg(hdev, "err 0x%2.2x", err);
-
-       if (hdev->req_status == HCI_REQ_PEND) {
-               hdev->req_result = err;
-               hdev->req_status = HCI_REQ_CANCELED;
-
-               cancel_delayed_work_sync(&hdev->cmd_timer);
-               cancel_delayed_work_sync(&hdev->ncmd_timer);
-               atomic_set(&hdev->cmd_cnt, 1);
-
-               wake_up_interruptible(&hdev->req_wait_q);
-       }
-}
-
 /* Execute request and wait for completion. */
 int __hci_req_sync(struct hci_dev *hdev, int (*func)(struct hci_request *req,
                                                     unsigned long opt),
@@ -2708,7 +2692,7 @@ void hci_request_setup(struct hci_dev *hdev)
 
 void hci_request_cancel_all(struct hci_dev *hdev)
 {
-       hci_req_sync_cancel(hdev, ENODEV);
+       hci_cmd_sync_cancel(hdev, ENODEV);
 
        cancel_work_sync(&hdev->discov_update);
        cancel_work_sync(&hdev->scan_update);
index 5f8e884..8d39e94 100644 (file)
@@ -64,7 +64,6 @@ int hci_req_sync(struct hci_dev *hdev, int (*req)(struct hci_request *req,
 int __hci_req_sync(struct hci_dev *hdev, int (*func)(struct hci_request *req,
                                                     unsigned long opt),
                   unsigned long opt, u32 timeout, u8 *hci_status);
-void hci_req_sync_cancel(struct hci_dev *hdev, int err);
 
 struct sk_buff *hci_prepare_cmd(struct hci_dev *hdev, u16 opcode, u32 plen,
                                const void *param);
index ad86caf..7ac6c17 100644 (file)
@@ -335,6 +335,23 @@ void hci_cmd_sync_clear(struct hci_dev *hdev)
        }
 }
 
+void hci_cmd_sync_cancel(struct hci_dev *hdev, int err)
+{
+       bt_dev_dbg(hdev, "err 0x%2.2x", err);
+
+       if (hdev->req_status == HCI_REQ_PEND) {
+               hdev->req_result = err;
+               hdev->req_status = HCI_REQ_CANCELED;
+
+               cancel_delayed_work_sync(&hdev->cmd_timer);
+               cancel_delayed_work_sync(&hdev->ncmd_timer);
+               atomic_set(&hdev->cmd_cnt, 1);
+
+               wake_up_interruptible(&hdev->req_wait_q);
+       }
+}
+EXPORT_SYMBOL(hci_cmd_sync_cancel);
+
 int hci_cmd_sync_queue(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
                       void *data, hci_cmd_sync_work_destroy_t destroy)
 {