Skip to contentSkip to conversation

Bluetooth: Fix calls to __hci_cmd_sync()

PATCH In review Frederic Danis 2 participants 8 messages May 15, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v5 1/4 Bluetooth: Fix calls to __hci_cmd_sync()

Remove test of command reply status as it is already performed by __hci_cmd_sync().

__hci_cmd_sync_ev() function already returns an error if it got a non-zero status either through a Command Complete or a Command Status event.

For both of these events the status is collected up in the event handlers called by hci_event_packet() and then passed as the second parameter to req_complete_skb(). The req_complete_skb() callback in turn is hci_req_sync_complete() for __hci_cmd_sync_ev() which stores the status in hdev->req_result. The hdev->req_result is then further converted through bt_to_errno() back in __hci_cmd_sync_ev().

---
 net/bluetooth/hci_core.c | 5 -----
 1 file changed, 5 deletions(-)
net/bluetooth/hci_core.c +0 -5
index 4663c3d..db11b9d 100644
@@ -94,7 +94,6 @@ static ssize_t dut_mode_write(struct file *file, const char __user *user_buf,
 	char buf[32];
 	size_t buf_size = min(count, (sizeof(buf)-1));
 	bool enable;
-	int err;
 
 	if (!test_bit(HCI_UP, &hdev->flags))
 		return -ENETDOWN;
@@ -121,12 +120,8 @@ static ssize_t dut_mode_write(struct file *file, const char __user *user_buf,
 	if (IS_ERR(skb))
 		return PTR_ERR(skb);
 
-	err = -bt_to_errno(skb->data[0]);
 	kfree_skb(skb);
 
-	if (err < 0)
-		return err;
-
 	hci_dev_change_flag(hdev, HCI_DUT_MODE);
 
 	return count;
Signature · 1 line
1.9.1
#1 lore raw

PATCH v5 2/4 Bluetooth: btusb: Fix calls to __hci_cmd_sync()

Remove test of command reply status as it is already performed by __hci_cmd_sync().

__hci_cmd_sync_ev() function already returns an error if it got a non-zero status either through a Command Complete or a Command Status event.

For both of these events the status is collected up in the event handlers called by hci_event_packet() and then passed as the second parameter to req_complete_skb(). The req_complete_skb() callback in turn is hci_req_sync_complete() for __hci_cmd_sync_ev() which stores the status in hdev->req_result. The hdev->req_result is then further converted through bt_to_errno() back in __hci_cmd_sync_ev().

---
 drivers/bluetooth/btusb.c | 36 ------------------------------------
 1 file changed, 36 deletions(-)
drivers/bluetooth/btusb.c +0 -36
index df87016..b9f2821 100644
@@ -1577,12 +1577,6 @@ static int btusb_setup_intel(struct hci_dev *hdev)
 	}
 
 	ver = (struct intel_version *)skb->data;
-	if (ver->status) {
-		BT_ERR("%s Intel fw version event failed (%02x)", hdev->name,
-		       ver->status);
-		kfree_skb(skb);
-		return -bt_to_errno(ver->status);
-	}
 
 	BT_INFO("%s: read Intel version: %02x%02x%02x%02x%02x%02x%02x%02x%02x",
 		hdev->name, ver->hw_platform, ver->hw_variant,
@@ -1630,15 +1624,6 @@ static int btusb_setup_intel(struct hci_dev *hdev)
 		return PTR_ERR(skb);
 	}
 
-	if (skb->data[0]) {
-		u8 evt_status = skb->data[0];
-
-		BT_ERR("%s enable Intel manufacturer mode event failed (%02x)",
-		       hdev->name, evt_status);
-		kfree_skb(skb);
-		release_firmware(fw);
-		return -bt_to_errno(evt_status);
-	}
 	kfree_skb(skb);
 
 	disable_patch = 1;
@@ -1984,13 +1969,6 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
 	}
 
 	ver = (struct intel_version *)skb->data;
-	if (ver->status) {
-		BT_ERR("%s: Intel version command failure (%02x)",
-		       hdev->name, ver->status);
-		err = -bt_to_errno(ver->status);
-		kfree_skb(skb);
-		return err;
-	}
 
 	/* The hardware platform number has a fixed value of 0x37 and
 	 * for now only accept this single value.
@@ -2065,13 +2043,6 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
 	}
 
 	params = (struct intel_boot_params *)skb->data;
-	if (params->status) {
-		BT_ERR("%s: Intel boot parameters command failure (%02x)",
-		       hdev->name, params->status);
-		err = -bt_to_errno(params->status);
-		kfree_skb(skb);
-		return err;
-	}
 
 	BT_INFO("%s: Device revision is %u", hdev->name,
 		le16_to_cpu(params->dev_revid));
@@ -2304,13 +2275,6 @@ static void btusb_hw_error_intel(struct hci_dev *hdev, u8 code)
 		return;
 	}
 
-	if (skb->data[0] != 0x00) {
-		BT_ERR("%s: Exception info command failure (%02x)",
-		       hdev->name, skb->data[0]);
-		kfree_skb(skb);
-		return;
-	}
-
 	BT_ERR("%s: Exception info %s", hdev->name, (char *)(skb->data + 1));
 
 	kfree_skb(skb);
Signature · 1 line
1.9.1
maintainer
#2 lore raw

Re: [PATCH v5 2/4] Bluetooth: btusb: Fix calls to __hci_cmd_sync()

Hi Fred,

Quoted 14 lines

Remove test of command reply status as it is already performed by __hci_cmd_sync().

__hci_cmd_sync_ev() function already returns an error if it got a non-zero status either through a Command Complete or a Command Status event.

For both of these events the status is collected up in the event handlers called by hci_event_packet() and then passed as the second parameter to req_complete_skb(). The req_complete_skb() callback in turn is hci_req_sync_complete() for __hci_cmd_sync_ev() which stores the status in hdev->req_result. The hdev->req_result is then further converted through bt_to_errno() back in __hci_cmd_sync_ev().

Quoted 4 lines

---
drivers/bluetooth/btusb.c | 36 ------------------------------------

1 file changed, 36 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

#3 lore raw

PATCH v5 3/4 Bluetooth: btintel: Fix calls to __hci_cmd_sync()

In reply to Frederic Danis

Remove test of command reply status as it is already performed by __hci_cmd_sync().

__hci_cmd_sync_ev() function already returns an error if it got a non-zero status either through a Command Complete or a Command Status event.

For both of these events the status is collected up in the event handlers called by hci_event_packet() and then passed as the second parameter to req_complete_skb(). The req_complete_skb() callback in turn is hci_req_sync_complete() for __hci_cmd_sync_ev() which stores the status in hdev->req_result. The hdev->req_result is then further converted through bt_to_errno() back in __hci_cmd_sync_ev().

---
 drivers/bluetooth/btintel.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/bluetooth/btintel.c +0 -6
index 2d43d42..828f2f8 100644
@@ -53,12 +53,6 @@ int btintel_check_bdaddr(struct hci_dev *hdev)
 	}
 
 	bda = (struct hci_rp_read_bd_addr *)skb->data;
-	if (bda->status) {
-		BT_ERR("%s: Intel device address result failed (%02x)",
-		       hdev->name, bda->status);
-		kfree_skb(skb);
-		return -bt_to_errno(bda->status);
-	}
 
 	/* For some Intel based controllers, the default Bluetooth device
 	 * address 00:03:19:9E:8B:00 can be found. These controllers are
Signature · 1 line
1.9.1
maintainer
#4 lore raw

Re: [PATCH v5 3/4] Bluetooth: btintel: Fix calls to __hci_cmd_sync()

Hi Fred,

Quoted 14 lines

Remove test of command reply status as it is already performed by __hci_cmd_sync().

__hci_cmd_sync_ev() function already returns an error if it got a non-zero status either through a Command Complete or a Command Status event.

For both of these events the status is collected up in the event handlers called by hci_event_packet() and then passed as the second parameter to req_complete_skb(). The req_complete_skb() callback in turn is hci_req_sync_complete() for __hci_cmd_sync_ev() which stores the status in hdev->req_result. The hdev->req_result is then further converted through bt_to_errno() back in __hci_cmd_sync_ev().

Quoted 4 lines

---
drivers/bluetooth/btintel.c | 6 ------

1 file changed, 6 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

#5 lore raw

PATCH v5 4/4 Bluetooth: btbcm: Fix calls to __hci_cmd_sync()

In reply to Frederic Danis

Remove test of command reply status as it is already performed by __hci_cmd_sync().

__hci_cmd_sync_ev() function already returns an error if it got a non-zero status either through a Command Complete or a Command Status event.

For both of these events the status is collected up in the event handlers called by hci_event_packet() and then passed as the second parameter to req_complete_skb(). The req_complete_skb() callback in turn is hci_req_sync_complete() for __hci_cmd_sync_ev() which stores the status in hdev->req_result. The hdev->req_result is then further converted through bt_to_errno() back in __hci_cmd_sync_ev().

---
 drivers/bluetooth/btbcm.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/bluetooth/btbcm.c +0 -6
index 4bba866..728fce3 100644
@@ -55,12 +55,6 @@ int btbcm_check_bdaddr(struct hci_dev *hdev)
 	}
 
 	bda = (struct hci_rp_read_bd_addr *)skb->data;
-	if (bda->status) {
-		BT_ERR("%s: BCM: Device address result failed (%02x)",
-		       hdev->name, bda->status);
-		kfree_skb(skb);
-		return -bt_to_errno(bda->status);
-	}
 
 	/* The address 00:20:70:02:A0:00 indicates a BCM20702A0 controller
 	 * with no configured address.
Signature · 1 line
1.9.1
maintainer
#6 lore raw

Re: [PATCH v5 4/4] Bluetooth: btbcm: Fix calls to __hci_cmd_sync()

Hi Fred,

Quoted 14 lines

Remove test of command reply status as it is already performed by __hci_cmd_sync().

__hci_cmd_sync_ev() function already returns an error if it got a non-zero status either through a Command Complete or a Command Status event.

For both of these events the status is collected up in the event handlers called by hci_event_packet() and then passed as the second parameter to req_complete_skb(). The req_complete_skb() callback in turn is hci_req_sync_complete() for __hci_cmd_sync_ev() which stores the status in hdev->req_result. The hdev->req_result is then further converted through bt_to_errno() back in __hci_cmd_sync_ev().

Quoted 4 lines

---
drivers/bluetooth/btbcm.c | 6 ------

1 file changed, 6 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

maintainer
#7 lore raw
In reply to Frederic Danis

Hi Fred,

Quoted 14 lines

Remove test of command reply status as it is already performed by __hci_cmd_sync().

__hci_cmd_sync_ev() function already returns an error if it got a non-zero status either through a Command Complete or a Command Status event.

For both of these events the status is collected up in the event handlers called by hci_event_packet() and then passed as the second parameter to req_complete_skb(). The req_complete_skb() callback in turn is hci_req_sync_complete() for __hci_cmd_sync_ev() which stores the status in hdev->req_result. The hdev->req_result is then further converted through bt_to_errno() back in __hci_cmd_sync_ev().

Quoted 4 lines

---
net/bluetooth/hci_core.c | 5 -----

1 file changed, 5 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel