aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2012-02-27 18:07:22 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2012-02-27 18:54:19 -0500
commit8f984dfaf0bfa1355548cfba00473c8fa8e22d6e (patch)
tree7c22e24bf6e2ff7ab28bfaadf1f9da983a962827 /net
parent0b60eba1b29740a606e6b7694d2dc98b6085a1bf (diff)
Bluetooth: Remove redundant read_host_features commands
Previously the write_le_enable would trigger a read_host_features command but since we have access to the value LE support was set to we can simply just clear or set the bit in hdev->host_features. This also removes a second unnecessary read_host_features command from the device initialization procedure since LE is only enabled after the first read_host_features command completes. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/hci_event.c59
1 files changed, 34 insertions, 25 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index e920cd520a82..488fdbcfe762 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -542,20 +542,6 @@ static void hci_setup_event_mask(struct hci_dev *hdev)
542 hci_send_cmd(hdev, HCI_OP_SET_EVENT_MASK, sizeof(events), events); 542 hci_send_cmd(hdev, HCI_OP_SET_EVENT_MASK, sizeof(events), events);
543} 543}
544 544
545static void hci_set_le_support(struct hci_dev *hdev)
546{
547 struct hci_cp_write_le_host_supported cp;
548
549 memset(&cp, 0, sizeof(cp));
550
551 if (enable_le && test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) {
552 cp.le = 1;
553 cp.simul = !!(hdev->features[6] & LMP_SIMUL_LE_BR);
554 }
555
556 hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, sizeof(cp), &cp);
557}
558
559static void hci_setup(struct hci_dev *hdev) 545static void hci_setup(struct hci_dev *hdev)
560{ 546{
561 if (hdev->dev_type != HCI_BREDR) 547 if (hdev->dev_type != HCI_BREDR)
@@ -608,9 +594,6 @@ static void hci_setup(struct hci_dev *hdev)
608 hci_send_cmd(hdev, HCI_OP_WRITE_AUTH_ENABLE, 594 hci_send_cmd(hdev, HCI_OP_WRITE_AUTH_ENABLE,
609 sizeof(enable), &enable); 595 sizeof(enable), &enable);
610 } 596 }
611
612 if (hdev->features[4] & LMP_LE)
613 hci_set_le_support(hdev);
614} 597}
615 598
616static void hci_cc_read_local_version(struct hci_dev *hdev, struct sk_buff *skb) 599static void hci_cc_read_local_version(struct hci_dev *hdev, struct sk_buff *skb)
@@ -730,6 +713,22 @@ static void hci_cc_read_local_features(struct hci_dev *hdev, struct sk_buff *skb
730 hdev->features[6], hdev->features[7]); 713 hdev->features[6], hdev->features[7]);
731} 714}
732 715
716static void hci_set_le_support(struct hci_dev *hdev)
717{
718 struct hci_cp_write_le_host_supported cp;
719
720 memset(&cp, 0, sizeof(cp));
721
722 if (enable_le && test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) {
723 cp.le = 1;
724 cp.simul = !!(hdev->features[6] & LMP_SIMUL_LE_BR);
725 }
726
727 if (cp.le != !!(hdev->host_features[0] & LMP_HOST_LE))
728 hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED,
729 sizeof(cp), &cp);
730}
731
733static void hci_cc_read_local_ext_features(struct hci_dev *hdev, 732static void hci_cc_read_local_ext_features(struct hci_dev *hdev,
734 struct sk_buff *skb) 733 struct sk_buff *skb)
735{ 734{
@@ -738,7 +737,7 @@ static void hci_cc_read_local_ext_features(struct hci_dev *hdev,
738 BT_DBG("%s status 0x%x", hdev->name, rp->status); 737 BT_DBG("%s status 0x%x", hdev->name, rp->status);
739 738
740 if (rp->status) 739 if (rp->status)
741 return; 740 goto done;
742 741
743 switch (rp->page) { 742 switch (rp->page) {
744 case 0: 743 case 0:
@@ -749,6 +748,10 @@ static void hci_cc_read_local_ext_features(struct hci_dev *hdev,
749 break; 748 break;
750 } 749 }
751 750
751 if (test_bit(HCI_INIT, &hdev->flags) && hdev->features[4] & LMP_LE)
752 hci_set_le_support(hdev);
753
754done:
752 hci_req_complete(hdev, HCI_OP_READ_LOCAL_EXT_FEATURES, rp->status); 755 hci_req_complete(hdev, HCI_OP_READ_LOCAL_EXT_FEATURES, rp->status);
753} 756}
754 757
@@ -1149,21 +1152,27 @@ static void hci_cc_le_ltk_neg_reply(struct hci_dev *hdev, struct sk_buff *skb)
1149static inline void hci_cc_write_le_host_supported(struct hci_dev *hdev, 1152static inline void hci_cc_write_le_host_supported(struct hci_dev *hdev,
1150 struct sk_buff *skb) 1153 struct sk_buff *skb)
1151{ 1154{
1152 struct hci_cp_read_local_ext_features cp;
1153 struct hci_cp_write_le_host_supported *sent; 1155 struct hci_cp_write_le_host_supported *sent;
1154 __u8 status = *((__u8 *) skb->data); 1156 __u8 status = *((__u8 *) skb->data);
1155 1157
1156 BT_DBG("%s status 0x%x", hdev->name, status); 1158 BT_DBG("%s status 0x%x", hdev->name, status);
1157 1159
1158 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED); 1160 sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED);
1159 if (sent && test_bit(HCI_MGMT, &hdev->dev_flags)) 1161 if (!sent)
1160 mgmt_le_enable_complete(hdev, sent->le, status);
1161
1162 if (status)
1163 return; 1162 return;
1164 1163
1165 cp.page = 0x01; 1164 if (!status) {
1166 hci_send_cmd(hdev, HCI_OP_READ_LOCAL_EXT_FEATURES, sizeof(cp), &cp); 1165 if (sent->le)
1166 hdev->host_features[0] |= LMP_HOST_LE;
1167 else
1168 hdev->host_features[0] &= ~LMP_HOST_LE;
1169 }
1170
1171 if (test_bit(HCI_MGMT, &hdev->dev_flags) &&
1172 !test_bit(HCI_INIT, &hdev->flags))
1173 mgmt_le_enable_complete(hdev, sent->le, status);
1174
1175 hci_req_complete(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, status);
1167} 1176}
1168 1177
1169static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) 1178static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)