aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2013-01-09 08:29:38 -0500
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2013-01-10 03:09:59 -0500
commit13ecd8b6628c14c9a27832ce7c48315385272208 (patch)
tree6bf0201d29c30f3c79650e4dc87ee1df6512bb63 /net
parentee98f4738050bb93823ce9ba849f5d78f5b8c1a1 (diff)
Bluetooth: Move non-critical sections outside of the dev lock
This patch fixes sections of code that do not need hci_lock_dev to be outside of the lock. Such sections include code that do not touch the hdev at all as well as sections which just read a single byte from the supported_features value (i.e. all lmp_*_capable() macros). Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/mgmt.c46
1 files changed, 18 insertions, 28 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index d78ce81d2cf4..28e01f992231 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1133,13 +1133,11 @@ static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
1133 1133
1134 BT_DBG("request for %s", hdev->name); 1134 BT_DBG("request for %s", hdev->name);
1135 1135
1136 hci_dev_lock(hdev); 1136 if (!lmp_ssp_capable(hdev))
1137 return cmd_status(sk, hdev->id, MGMT_OP_SET_SSP,
1138 MGMT_STATUS_NOT_SUPPORTED);
1137 1139
1138 if (!lmp_ssp_capable(hdev)) { 1140 hci_dev_lock(hdev);
1139 err = cmd_status(sk, hdev->id, MGMT_OP_SET_SSP,
1140 MGMT_STATUS_NOT_SUPPORTED);
1141 goto failed;
1142 }
1143 1141
1144 val = !!cp->val; 1142 val = !!cp->val;
1145 1143
@@ -1217,13 +1215,11 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
1217 1215
1218 BT_DBG("request for %s", hdev->name); 1216 BT_DBG("request for %s", hdev->name);
1219 1217
1220 hci_dev_lock(hdev); 1218 if (!lmp_le_capable(hdev))
1219 return cmd_status(sk, hdev->id, MGMT_OP_SET_LE,
1220 MGMT_STATUS_NOT_SUPPORTED);
1221 1221
1222 if (!lmp_le_capable(hdev)) { 1222 hci_dev_lock(hdev);
1223 err = cmd_status(sk, hdev->id, MGMT_OP_SET_LE,
1224 MGMT_STATUS_NOT_SUPPORTED);
1225 goto unlock;
1226 }
1227 1223
1228 val = !!cp->val; 1224 val = !!cp->val;
1229 enabled = lmp_host_le_capable(hdev); 1225 enabled = lmp_host_le_capable(hdev);
@@ -1422,25 +1418,19 @@ static int set_dev_class(struct sock *sk, struct hci_dev *hdev, void *data,
1422 1418
1423 BT_DBG("request for %s", hdev->name); 1419 BT_DBG("request for %s", hdev->name);
1424 1420
1425 hci_dev_lock(hdev); 1421 if (!lmp_bredr_capable(hdev))
1422 return cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS,
1423 MGMT_STATUS_NOT_SUPPORTED);
1426 1424
1427 if (!lmp_bredr_capable(hdev)) { 1425 if (test_bit(HCI_PENDING_CLASS, &hdev->dev_flags))
1428 err = cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS, 1426 return cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS,
1429 MGMT_STATUS_NOT_SUPPORTED); 1427 MGMT_STATUS_BUSY);
1430 goto unlock;
1431 }
1432 1428
1433 if (test_bit(HCI_PENDING_CLASS, &hdev->dev_flags)) { 1429 if ((cp->minor & 0x03) != 0 || (cp->major & 0xe0) != 0)
1434 err = cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS, 1430 return cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS,
1435 MGMT_STATUS_BUSY); 1431 MGMT_STATUS_INVALID_PARAMS);
1436 goto unlock;
1437 }
1438 1432
1439 if ((cp->minor & 0x03) != 0 || (cp->major & 0xe0) != 0) { 1433 hci_dev_lock(hdev);
1440 err = cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS,
1441 MGMT_STATUS_INVALID_PARAMS);
1442 goto unlock;
1443 }
1444 1434
1445 hdev->major_class = cp->major; 1435 hdev->major_class = cp->major;
1446 hdev->minor_class = cp->minor; 1436 hdev->minor_class = cp->minor;