aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2013-10-01 15:44:49 -0400
committerMarcel Holtmann <marcel@holtmann.org>2013-10-02 02:27:08 -0400
commitcbed0ca137ef442c545602a09030bbb35d8db013 (patch)
tree6cbbac4e5508362607a92e35b24dbf4ef316e29a
parent922ca1dfc2127a5dc363e8c1e6c8a33c5a0a14c6 (diff)
Bluetooth: Refactor hci_dev_open to a separate hci_dev_do_open function
The requirements of an external call to hci_dev_open from hci_sock.c are different to that from within hci_core.c. In the former case we want to flush any pending work in hdev->req_workqueue whereas in the latter we don't (since there we are already calling from within the workqueue itself). This patch does the necessary refactoring to a separate hci_dev_do_open function (analogous to hci_dev_do_close) but does not yet introduce the synchronizations relating to the workqueue usage. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--net/bluetooth/hci_core.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 750c360f96db..1bc43249d5a3 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1176,17 +1176,10 @@ void hci_update_ad(struct hci_request *req)
1176 hci_req_add(req, HCI_OP_LE_SET_ADV_DATA, sizeof(cp), &cp); 1176 hci_req_add(req, HCI_OP_LE_SET_ADV_DATA, sizeof(cp), &cp);
1177} 1177}
1178 1178
1179/* ---- HCI ioctl helpers ---- */ 1179static int hci_dev_do_open(struct hci_dev *hdev)
1180
1181int hci_dev_open(__u16 dev)
1182{ 1180{
1183 struct hci_dev *hdev;
1184 int ret = 0; 1181 int ret = 0;
1185 1182
1186 hdev = hci_dev_get(dev);
1187 if (!hdev)
1188 return -ENODEV;
1189
1190 BT_DBG("%s %p", hdev->name, hdev); 1183 BT_DBG("%s %p", hdev->name, hdev);
1191 1184
1192 hci_req_lock(hdev); 1185 hci_req_lock(hdev);
@@ -1266,10 +1259,27 @@ int hci_dev_open(__u16 dev)
1266 1259
1267done: 1260done:
1268 hci_req_unlock(hdev); 1261 hci_req_unlock(hdev);
1269 hci_dev_put(hdev);
1270 return ret; 1262 return ret;
1271} 1263}
1272 1264
1265/* ---- HCI ioctl helpers ---- */
1266
1267int hci_dev_open(__u16 dev)
1268{
1269 struct hci_dev *hdev;
1270 int err;
1271
1272 hdev = hci_dev_get(dev);
1273 if (!hdev)
1274 return -ENODEV;
1275
1276 err = hci_dev_do_open(hdev);
1277
1278 hci_dev_put(hdev);
1279
1280 return err;
1281}
1282
1273static int hci_dev_do_close(struct hci_dev *hdev) 1283static int hci_dev_do_close(struct hci_dev *hdev)
1274{ 1284{
1275 BT_DBG("%s %p", hdev->name, hdev); 1285 BT_DBG("%s %p", hdev->name, hdev);
@@ -1665,7 +1675,7 @@ static void hci_power_on(struct work_struct *work)
1665 1675
1666 BT_DBG("%s", hdev->name); 1676 BT_DBG("%s", hdev->name);
1667 1677
1668 err = hci_dev_open(hdev->id); 1678 err = hci_dev_do_open(hdev);
1669 if (err < 0) { 1679 if (err < 0) {
1670 mgmt_set_powered_failed(hdev, err); 1680 mgmt_set_powered_failed(hdev, err);
1671 return; 1681 return;