Browse Source

Bluetooth: mgmt: Fix update_eir/class with HCI_AUTO_OFF flag set

If we're powered but still have the HCI_AUTO_OFF flag set the
update_eir and update_class functions should not do anything.
Additionally these functions need to be called when the flag is finally
cleared through set_powered or when powering on for real.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Johan Hedberg 13 years ago
parent
commit
504c8dcd6b
1 changed files with 5 additions and 2 deletions
  1. 5 2
      net/bluetooth/mgmt.c

+ 5 - 2
net/bluetooth/mgmt.c

@@ -532,7 +532,7 @@ static int update_eir(struct hci_dev *hdev)
 {
 {
 	struct hci_cp_write_eir cp;
 	struct hci_cp_write_eir cp;
 
 
-	if (!test_bit(HCI_UP, &hdev->flags))
+	if (!hdev_is_powered(hdev))
 		return 0;
 		return 0;
 
 
 	if (!(hdev->features[6] & LMP_EXT_INQ))
 	if (!(hdev->features[6] & LMP_EXT_INQ))
@@ -573,7 +573,7 @@ static int update_class(struct hci_dev *hdev)
 
 
 	BT_DBG("%s", hdev->name);
 	BT_DBG("%s", hdev->name);
 
 
-	if (!test_bit(HCI_UP, &hdev->flags))
+	if (!hdev_is_powered(hdev))
 		return 0;
 		return 0;
 
 
 	if (test_bit(HCI_SERVICE_CACHE, &hdev->dev_flags))
 	if (test_bit(HCI_SERVICE_CACHE, &hdev->dev_flags))
@@ -3121,6 +3121,9 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered)
 
 
 		if (scan)
 		if (scan)
 			hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
 			hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
+
+		update_class(hdev);
+		update_eir(hdev);
 	} else {
 	} else {
 		u8 status = ENETDOWN;
 		u8 status = ENETDOWN;
 		mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status);
 		mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status);