瀏覽代碼

Bluetooth: Add opcode parameter to hci_req_complete_t callback

When hci_req_run() calls its provided complete function and one of the
HCI commands in the sequence fails, then provide the opcode of failing
command. In case of success HCI_OP_NOP is provided since all commands
completed.

This patch fixes the prototype of hci_req_complete_t and all its users.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Marcel Holtmann 10 年之前
父節點
當前提交
1904a853fa
共有 5 個文件被更改,包括 34 次插入26 次删除
  1. 1 1
      include/net/bluetooth/bluetooth.h
  2. 1 1
      net/bluetooth/hci_conn.c
  3. 5 4
      net/bluetooth/hci_core.c
  4. 2 1
      net/bluetooth/hci_request.c
  5. 25 19
      net/bluetooth/mgmt.c

+ 1 - 1
include/net/bluetooth/bluetooth.h

@@ -273,7 +273,7 @@ struct l2cap_ctrl {
 
 
 struct hci_dev;
 struct hci_dev;
 
 
-typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status);
+typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status, u16 opcode);
 
 
 struct hci_req_ctrl {
 struct hci_req_ctrl {
 	bool			start;
 	bool			start;

+ 1 - 1
net/bluetooth/hci_conn.c

@@ -633,7 +633,7 @@ void hci_le_conn_failed(struct hci_conn *conn, u8 status)
 	mgmt_reenable_advertising(hdev);
 	mgmt_reenable_advertising(hdev);
 }
 }
 
 
-static void create_le_conn_complete(struct hci_dev *hdev, u8 status)
+static void create_le_conn_complete(struct hci_dev *hdev, u8 status, u16 opcode)
 {
 {
 	struct hci_conn *conn;
 	struct hci_conn *conn;
 
 

+ 5 - 4
net/bluetooth/hci_core.c

@@ -141,7 +141,7 @@ static const struct file_operations dut_mode_fops = {
 
 
 /* ---- HCI requests ---- */
 /* ---- HCI requests ---- */
 
 
-static void hci_req_sync_complete(struct hci_dev *hdev, u8 result)
+static void hci_req_sync_complete(struct hci_dev *hdev, u8 result, u16 opcode)
 {
 {
 	BT_DBG("%s result 0x%2.2x", hdev->name, result);
 	BT_DBG("%s result 0x%2.2x", hdev->name, result);
 
 
@@ -2754,7 +2754,7 @@ void hci_conn_params_clear_all(struct hci_dev *hdev)
 	BT_DBG("All LE connection parameters were removed");
 	BT_DBG("All LE connection parameters were removed");
 }
 }
 
 
-static void inquiry_complete(struct hci_dev *hdev, u8 status)
+static void inquiry_complete(struct hci_dev *hdev, u8 status, u16 opcode)
 {
 {
 	if (status) {
 	if (status) {
 		BT_ERR("Failed to start inquiry: status %d", status);
 		BT_ERR("Failed to start inquiry: status %d", status);
@@ -2766,7 +2766,8 @@ static void inquiry_complete(struct hci_dev *hdev, u8 status)
 	}
 	}
 }
 }
 
 
-static void le_scan_disable_work_complete(struct hci_dev *hdev, u8 status)
+static void le_scan_disable_work_complete(struct hci_dev *hdev, u8 status,
+					  u16 opcode)
 {
 {
 	/* General inquiry access code (GIAC) */
 	/* General inquiry access code (GIAC) */
 	u8 lap[3] = { 0x33, 0x8b, 0x9e };
 	u8 lap[3] = { 0x33, 0x8b, 0x9e };
@@ -4159,7 +4160,7 @@ void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status)
 
 
 call_complete:
 call_complete:
 	if (req_complete)
 	if (req_complete)
-		req_complete(hdev, status);
+		req_complete(hdev, status, status ? opcode : HCI_OP_NOP);
 }
 }
 
 
 static void hci_rx_work(struct work_struct *work)
 static void hci_rx_work(struct work_struct *work)

+ 2 - 1
net/bluetooth/hci_request.c

@@ -533,7 +533,8 @@ void __hci_update_background_scan(struct hci_request *req)
 	}
 	}
 }
 }
 
 
-static void update_background_scan_complete(struct hci_dev *hdev, u8 status)
+static void update_background_scan_complete(struct hci_dev *hdev, u8 status,
+					    u16 opcode)
 {
 {
 	if (status)
 	if (status)
 		BT_DBG("HCI request failed to update background scanning: "
 		BT_DBG("HCI request failed to update background scanning: "

+ 25 - 19
net/bluetooth/mgmt.c

@@ -1251,7 +1251,7 @@ static int send_settings_rsp(struct sock *sk, u16 opcode, struct hci_dev *hdev)
 			    sizeof(settings));
 			    sizeof(settings));
 }
 }
 
 
-static void clean_up_hci_complete(struct hci_dev *hdev, u8 status)
+static void clean_up_hci_complete(struct hci_dev *hdev, u8 status, u16 opcode)
 {
 {
 	BT_DBG("%s status 0x%02x", hdev->name, status);
 	BT_DBG("%s status 0x%02x", hdev->name, status);
 
 
@@ -1518,7 +1518,8 @@ static u8 mgmt_le_support(struct hci_dev *hdev)
 		return MGMT_STATUS_SUCCESS;
 		return MGMT_STATUS_SUCCESS;
 }
 }
 
 
-static void set_discoverable_complete(struct hci_dev *hdev, u8 status)
+static void set_discoverable_complete(struct hci_dev *hdev, u8 status,
+				      u16 opcode)
 {
 {
 	struct pending_cmd *cmd;
 	struct pending_cmd *cmd;
 	struct mgmt_mode *cp;
 	struct mgmt_mode *cp;
@@ -1777,7 +1778,8 @@ static void write_fast_connectable(struct hci_request *req, bool enable)
 		hci_req_add(req, HCI_OP_WRITE_PAGE_SCAN_TYPE, 1, &type);
 		hci_req_add(req, HCI_OP_WRITE_PAGE_SCAN_TYPE, 1, &type);
 }
 }
 
 
-static void set_connectable_complete(struct hci_dev *hdev, u8 status)
+static void set_connectable_complete(struct hci_dev *hdev, u8 status,
+				     u16 opcode)
 {
 {
 	struct pending_cmd *cmd;
 	struct pending_cmd *cmd;
 	struct mgmt_mode *cp;
 	struct mgmt_mode *cp;
@@ -2195,7 +2197,7 @@ unlock:
 	return err;
 	return err;
 }
 }
 
 
-static void le_enable_complete(struct hci_dev *hdev, u8 status)
+static void le_enable_complete(struct hci_dev *hdev, u8 status, u16 opcode)
 {
 {
 	struct cmd_lookup match = { NULL, hdev };
 	struct cmd_lookup match = { NULL, hdev };
 
 
@@ -2385,7 +2387,7 @@ unlock:
 	hci_dev_unlock(hdev);
 	hci_dev_unlock(hdev);
 }
 }
 
 
-static void add_uuid_complete(struct hci_dev *hdev, u8 status)
+static void add_uuid_complete(struct hci_dev *hdev, u8 status, u16 opcode)
 {
 {
 	BT_DBG("status 0x%02x", status);
 	BT_DBG("status 0x%02x", status);
 
 
@@ -2464,7 +2466,7 @@ static bool enable_service_cache(struct hci_dev *hdev)
 	return false;
 	return false;
 }
 }
 
 
-static void remove_uuid_complete(struct hci_dev *hdev, u8 status)
+static void remove_uuid_complete(struct hci_dev *hdev, u8 status, u16 opcode)
 {
 {
 	BT_DBG("status 0x%02x", status);
 	BT_DBG("status 0x%02x", status);
 
 
@@ -2549,7 +2551,7 @@ unlock:
 	return err;
 	return err;
 }
 }
 
 
-static void set_class_complete(struct hci_dev *hdev, u8 status)
+static void set_class_complete(struct hci_dev *hdev, u8 status, u16 opcode)
 {
 {
 	BT_DBG("status 0x%02x", status);
 	BT_DBG("status 0x%02x", status);
 
 
@@ -3483,7 +3485,7 @@ static void update_name(struct hci_request *req)
 	hci_req_add(req, HCI_OP_WRITE_LOCAL_NAME, sizeof(cp), &cp);
 	hci_req_add(req, HCI_OP_WRITE_LOCAL_NAME, sizeof(cp), &cp);
 }
 }
 
 
-static void set_name_complete(struct hci_dev *hdev, u8 status)
+static void set_name_complete(struct hci_dev *hdev, u8 status, u16 opcode)
 {
 {
 	struct mgmt_cp_set_local_name *cp;
 	struct mgmt_cp_set_local_name *cp;
 	struct pending_cmd *cmd;
 	struct pending_cmd *cmd;
@@ -3834,7 +3836,8 @@ static bool trigger_discovery(struct hci_request *req, u8 *status)
 	return true;
 	return true;
 }
 }
 
 
-static void start_discovery_complete(struct hci_dev *hdev, u8 status)
+static void start_discovery_complete(struct hci_dev *hdev, u8 status,
+				     u16 opcode)
 {
 {
 	struct pending_cmd *cmd;
 	struct pending_cmd *cmd;
 	unsigned long timeout;
 	unsigned long timeout;
@@ -4063,7 +4066,7 @@ failed:
 	return err;
 	return err;
 }
 }
 
 
-static void stop_discovery_complete(struct hci_dev *hdev, u8 status)
+static void stop_discovery_complete(struct hci_dev *hdev, u8 status, u16 opcode)
 {
 {
 	struct pending_cmd *cmd;
 	struct pending_cmd *cmd;
 
 
@@ -4289,7 +4292,8 @@ static int set_device_id(struct sock *sk, struct hci_dev *hdev, void *data,
 	return err;
 	return err;
 }
 }
 
 
-static void set_advertising_complete(struct hci_dev *hdev, u8 status)
+static void set_advertising_complete(struct hci_dev *hdev, u8 status,
+				     u16 opcode)
 {
 {
 	struct cmd_lookup match = { NULL, hdev };
 	struct cmd_lookup match = { NULL, hdev };
 
 
@@ -4496,7 +4500,8 @@ static int set_scan_params(struct sock *sk, struct hci_dev *hdev,
 	return err;
 	return err;
 }
 }
 
 
-static void fast_connectable_complete(struct hci_dev *hdev, u8 status)
+static void fast_connectable_complete(struct hci_dev *hdev, u8 status,
+				      u16 opcode)
 {
 {
 	struct pending_cmd *cmd;
 	struct pending_cmd *cmd;
 
 
@@ -4594,7 +4599,7 @@ unlock:
 	return err;
 	return err;
 }
 }
 
 
-static void set_bredr_complete(struct hci_dev *hdev, u8 status)
+static void set_bredr_complete(struct hci_dev *hdev, u8 status, u16 opcode)
 {
 {
 	struct pending_cmd *cmd;
 	struct pending_cmd *cmd;
 
 
@@ -5119,7 +5124,8 @@ static int conn_info_cmd_complete(struct pending_cmd *cmd, u8 status)
 	return err;
 	return err;
 }
 }
 
 
-static void conn_info_refresh_complete(struct hci_dev *hdev, u8 hci_status)
+static void conn_info_refresh_complete(struct hci_dev *hdev, u8 hci_status,
+				       u16 opcode)
 {
 {
 	struct hci_cp_read_rssi *cp;
 	struct hci_cp_read_rssi *cp;
 	struct pending_cmd *cmd;
 	struct pending_cmd *cmd;
@@ -5326,7 +5332,7 @@ complete:
 	return err;
 	return err;
 }
 }
 
 
-static void get_clock_info_complete(struct hci_dev *hdev, u8 status)
+static void get_clock_info_complete(struct hci_dev *hdev, u8 status, u16 opcode)
 {
 {
 	struct hci_cp_read_clock *hci_cp;
 	struct hci_cp_read_clock *hci_cp;
 	struct pending_cmd *cmd;
 	struct pending_cmd *cmd;
@@ -5504,7 +5510,7 @@ static void device_added(struct sock *sk, struct hci_dev *hdev,
 	mgmt_event(MGMT_EV_DEVICE_ADDED, hdev, &ev, sizeof(ev), sk);
 	mgmt_event(MGMT_EV_DEVICE_ADDED, hdev, &ev, sizeof(ev), sk);
 }
 }
 
 
-static void add_device_complete(struct hci_dev *hdev, u8 status)
+static void add_device_complete(struct hci_dev *hdev, u8 status, u16 opcode)
 {
 {
 	struct pending_cmd *cmd;
 	struct pending_cmd *cmd;
 
 
@@ -5627,7 +5633,7 @@ static void device_removed(struct sock *sk, struct hci_dev *hdev,
 	mgmt_event(MGMT_EV_DEVICE_REMOVED, hdev, &ev, sizeof(ev), sk);
 	mgmt_event(MGMT_EV_DEVICE_REMOVED, hdev, &ev, sizeof(ev), sk);
 }
 }
 
 
-static void remove_device_complete(struct hci_dev *hdev, u8 status)
+static void remove_device_complete(struct hci_dev *hdev, u8 status, u16 opcode)
 {
 {
 	struct pending_cmd *cmd;
 	struct pending_cmd *cmd;
 
 
@@ -6205,7 +6211,7 @@ static void restart_le_actions(struct hci_request *req)
 	__hci_update_background_scan(req);
 	__hci_update_background_scan(req);
 }
 }
 
 
-static void powered_complete(struct hci_dev *hdev, u8 status)
+static void powered_complete(struct hci_dev *hdev, u8 status, u16 opcode)
 {
 {
 	struct cmd_lookup match = { NULL, hdev };
 	struct cmd_lookup match = { NULL, hdev };
 
 
@@ -7316,7 +7322,7 @@ void mgmt_discovering(struct hci_dev *hdev, u8 discovering)
 	mgmt_event(MGMT_EV_DISCOVERING, hdev, &ev, sizeof(ev), NULL);
 	mgmt_event(MGMT_EV_DISCOVERING, hdev, &ev, sizeof(ev), NULL);
 }
 }
 
 
-static void adv_enable_complete(struct hci_dev *hdev, u8 status)
+static void adv_enable_complete(struct hci_dev *hdev, u8 status, u16 opcode)
 {
 {
 	BT_DBG("%s status %u", hdev->name, status);
 	BT_DBG("%s status %u", hdev->name, status);
 }
 }