aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2010-11-10 10:11:51 -0500
committerGustavo F. Padovan <padovan@profusion.mobi>2010-12-01 18:04:35 -0500
commitccd556fe334914bf2e465eb5bc480d49cd4406d7 (patch)
treeafff0c055f4e3b412d9234ed3c6dd971a77e479d /net/bluetooth
parent17f490bcedd7b6677140b2d49efe9e9e6b84de60 (diff)
Bluetooth: Simplify remote features callback function logic
The current remote and remote extended features event callbacks logic can be made simpler by using a label and goto statements instead of the current multiple levels of nested if statements. Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/hci_event.c91
1 files changed, 47 insertions, 44 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 84093b0000b9..84302768939a 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1162,33 +1162,33 @@ static inline void hci_remote_features_evt(struct hci_dev *hdev, struct sk_buff
1162 hci_dev_lock(hdev); 1162 hci_dev_lock(hdev);
1163 1163
1164 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); 1164 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
1165 if (conn) { 1165 if (!conn)
1166 if (!ev->status) 1166 goto unlock;
1167 memcpy(conn->features, ev->features, 8);
1168 1167
1169 if (conn->state == BT_CONFIG) { 1168 if (!ev->status)
1170 if (!ev->status && lmp_ssp_capable(hdev) && 1169 memcpy(conn->features, ev->features, 8);
1171 lmp_ssp_capable(conn)) { 1170
1172 struct hci_cp_read_remote_ext_features cp; 1171 if (conn->state != BT_CONFIG)
1173 cp.handle = ev->handle; 1172 goto unlock;
1174 cp.page = 0x01; 1173
1175 hci_send_cmd(hdev, 1174 if (!ev->status && lmp_ssp_capable(hdev) && lmp_ssp_capable(conn)) {
1176 HCI_OP_READ_REMOTE_EXT_FEATURES, 1175 struct hci_cp_read_remote_ext_features cp;
1177 sizeof(cp), &cp); 1176 cp.handle = ev->handle;
1178 } else if (!ev->status && conn->out && 1177 cp.page = 0x01;
1179 conn->sec_level == BT_SECURITY_HIGH) { 1178 hci_send_cmd(hdev, HCI_OP_READ_REMOTE_EXT_FEATURES,
1180 struct hci_cp_auth_requested cp;
1181 cp.handle = ev->handle;
1182 hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED,
1183 sizeof(cp), &cp); 1179 sizeof(cp), &cp);
1184 } else { 1180 } else if (!ev->status && conn->out &&
1185 conn->state = BT_CONNECTED; 1181 conn->sec_level == BT_SECURITY_HIGH) {
1186 hci_proto_connect_cfm(conn, ev->status); 1182 struct hci_cp_auth_requested cp;
1187 hci_conn_put(conn); 1183 cp.handle = ev->handle;
1188 } 1184 hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp);
1189 } 1185 } else {
1186 conn->state = BT_CONNECTED;
1187 hci_proto_connect_cfm(conn, ev->status);
1188 hci_conn_put(conn);
1190 } 1189 }
1191 1190
1191unlock:
1192 hci_dev_unlock(hdev); 1192 hci_dev_unlock(hdev);
1193} 1193}
1194 1194
@@ -1646,32 +1646,35 @@ static inline void hci_remote_ext_features_evt(struct hci_dev *hdev, struct sk_b
1646 hci_dev_lock(hdev); 1646 hci_dev_lock(hdev);
1647 1647
1648 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); 1648 conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle));
1649 if (conn) { 1649 if (!conn)
1650 if (!ev->status && ev->page == 0x01) { 1650 goto unlock;
1651 struct inquiry_entry *ie;
1652 1651
1653 if ((ie = hci_inquiry_cache_lookup(hdev, &conn->dst))) 1652 if (!ev->status && ev->page == 0x01) {
1654 ie->data.ssp_mode = (ev->features[0] & 0x01); 1653 struct inquiry_entry *ie;
1655 1654
1656 conn->ssp_mode = (ev->features[0] & 0x01); 1655 if ((ie = hci_inquiry_cache_lookup(hdev, &conn->dst)))
1657 } 1656 ie->data.ssp_mode = (ev->features[0] & 0x01);
1658 1657
1659 if (conn->state == BT_CONFIG) { 1658 conn->ssp_mode = (ev->features[0] & 0x01);
1660 if (!ev->status && hdev->ssp_mode > 0 && 1659 }
1661 conn->ssp_mode > 0 && conn->out && 1660
1662 conn->sec_level != BT_SECURITY_SDP) { 1661 if (conn->state != BT_CONFIG)
1663 struct hci_cp_auth_requested cp; 1662 goto unlock;
1664 cp.handle = ev->handle; 1663
1665 hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, 1664 if (!ev->status && hdev->ssp_mode > 0 &&
1666 sizeof(cp), &cp); 1665 conn->ssp_mode > 0 && conn->out &&
1667 } else { 1666 conn->sec_level != BT_SECURITY_SDP) {
1668 conn->state = BT_CONNECTED; 1667 struct hci_cp_auth_requested cp;
1669 hci_proto_connect_cfm(conn, ev->status); 1668 cp.handle = ev->handle;
1670 hci_conn_put(conn); 1669 hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED,
1671 } 1670 sizeof(cp), &cp);
1672 } 1671 } else {
1672 conn->state = BT_CONNECTED;
1673 hci_proto_connect_cfm(conn, ev->status);
1674 hci_conn_put(conn);
1673 } 1675 }
1674 1676
1677unlock:
1675 hci_dev_unlock(hdev); 1678 hci_dev_unlock(hdev);
1676} 1679}
1677 1680