aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth
diff options
context:
space:
mode:
authorDaniel Drake <drake@endlessm.com>2015-02-23 19:16:47 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2015-03-13 06:47:48 -0400
commit6576fe4afc1203d27a5f4c8f5511f44203f4e333 (patch)
tree1da3af518e8833fb96ddb079a311628890c363e7 /drivers/bluetooth
parent238be788fcb75870661ec165dc90f2a2674e7fcb (diff)
Bluetooth: btusb: Add helper for READ_LOCAL_VERSION command
Multiple codepaths duplicate some simple code to read and sanity-check local version information. Before I add a couple more such codepaths, add a helper to reduce duplication. Signed-off-by: Daniel Drake <drake@endlessm.com> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r--drivers/bluetooth/btusb.c60
1 files changed, 28 insertions, 32 deletions
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index c34a875aaf60..bb5fd693414f 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -1269,6 +1269,28 @@ static void btusb_waker(struct work_struct *work)
1269 usb_autopm_put_interface(data->intf); 1269 usb_autopm_put_interface(data->intf);
1270} 1270}
1271 1271
1272static struct sk_buff *btusb_read_local_version(struct hci_dev *hdev)
1273{
1274 struct sk_buff *skb;
1275
1276 skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL,
1277 HCI_INIT_TIMEOUT);
1278 if (IS_ERR(skb)) {
1279 BT_ERR("%s: HCI_OP_READ_LOCAL_VERSION failed (%ld)",
1280 hdev->name, PTR_ERR(skb));
1281 return skb;
1282 }
1283
1284 if (skb->len != sizeof(struct hci_rp_read_local_version)) {
1285 BT_ERR("%s: HCI_OP_READ_LOCAL_VERSION event length mismatch",
1286 hdev->name);
1287 kfree_skb(skb);
1288 return ERR_PTR(-EIO);
1289 }
1290
1291 return skb;
1292}
1293
1272static int btusb_setup_bcm92035(struct hci_dev *hdev) 1294static int btusb_setup_bcm92035(struct hci_dev *hdev)
1273{ 1295{
1274 struct sk_buff *skb; 1296 struct sk_buff *skb;
@@ -1293,12 +1315,9 @@ static int btusb_setup_csr(struct hci_dev *hdev)
1293 1315
1294 BT_DBG("%s", hdev->name); 1316 BT_DBG("%s", hdev->name);
1295 1317
1296 skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL, 1318 skb = btusb_read_local_version(hdev);
1297 HCI_INIT_TIMEOUT); 1319 if (IS_ERR(skb))
1298 if (IS_ERR(skb)) {
1299 BT_ERR("Reading local version failed (%ld)", -PTR_ERR(skb));
1300 return -PTR_ERR(skb); 1320 return -PTR_ERR(skb);
1301 }
1302 1321
1303 rp = (struct hci_rp_read_local_version *)skb->data; 1322 rp = (struct hci_rp_read_local_version *)skb->data;
1304 1323
@@ -2429,21 +2448,9 @@ static int btusb_setup_bcm_patchram(struct hci_dev *hdev)
2429 kfree_skb(skb); 2448 kfree_skb(skb);
2430 2449
2431 /* Read Local Version Info */ 2450 /* Read Local Version Info */
2432 skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL, 2451 skb = btusb_read_local_version(hdev);
2433 HCI_INIT_TIMEOUT); 2452 if (IS_ERR(skb))
2434 if (IS_ERR(skb)) { 2453 return PTR_ERR(skb);
2435 ret = PTR_ERR(skb);
2436 BT_ERR("%s: HCI_OP_READ_LOCAL_VERSION failed (%ld)",
2437 hdev->name, ret);
2438 return ret;
2439 }
2440
2441 if (skb->len != sizeof(*ver)) {
2442 BT_ERR("%s: HCI_OP_READ_LOCAL_VERSION event length mismatch",
2443 hdev->name);
2444 kfree_skb(skb);
2445 return -EIO;
2446 }
2447 2454
2448 ver = (struct hci_rp_read_local_version *)skb->data; 2455 ver = (struct hci_rp_read_local_version *)skb->data;
2449 rev = le16_to_cpu(ver->hci_rev); 2456 rev = le16_to_cpu(ver->hci_rev);
@@ -2531,20 +2538,9 @@ reset_fw:
2531 kfree_skb(skb); 2538 kfree_skb(skb);
2532 2539
2533 /* Read Local Version Info */ 2540 /* Read Local Version Info */
2534 skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL, 2541 skb = btusb_read_local_version(hdev);
2535 HCI_INIT_TIMEOUT);
2536 if (IS_ERR(skb)) { 2542 if (IS_ERR(skb)) {
2537 ret = PTR_ERR(skb); 2543 ret = PTR_ERR(skb);
2538 BT_ERR("%s: HCI_OP_READ_LOCAL_VERSION failed (%ld)",
2539 hdev->name, ret);
2540 goto done;
2541 }
2542
2543 if (skb->len != sizeof(*ver)) {
2544 BT_ERR("%s: HCI_OP_READ_LOCAL_VERSION event length mismatch",
2545 hdev->name);
2546 kfree_skb(skb);
2547 ret = -EIO;
2548 goto done; 2544 goto done;
2549 } 2545 }
2550 2546