diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/hci_conn.c | 7 | ||||
-rw-r--r-- | net/bluetooth/hci_core.c | 74 | ||||
-rw-r--r-- | net/bluetooth/hci_sock.c | 14 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 6 |
4 files changed, 72 insertions, 29 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 8a0c7a0ac1b6..25ee27ddc882 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
@@ -346,9 +346,6 @@ static void hci_conn_idle(struct work_struct *work) | |||
346 | 346 | ||
347 | BT_DBG("hcon %p mode %d", conn, conn->mode); | 347 | BT_DBG("hcon %p mode %d", conn, conn->mode); |
348 | 348 | ||
349 | if (test_bit(HCI_RAW, &hdev->flags)) | ||
350 | return; | ||
351 | |||
352 | if (!lmp_sniff_capable(hdev) || !lmp_sniff_capable(conn)) | 349 | if (!lmp_sniff_capable(hdev) || !lmp_sniff_capable(conn)) |
353 | return; | 350 | return; |
354 | 351 | ||
@@ -539,7 +536,6 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src) | |||
539 | 536 | ||
540 | list_for_each_entry(d, &hci_dev_list, list) { | 537 | list_for_each_entry(d, &hci_dev_list, list) { |
541 | if (!test_bit(HCI_UP, &d->flags) || | 538 | if (!test_bit(HCI_UP, &d->flags) || |
542 | test_bit(HCI_RAW, &d->flags) || | ||
543 | test_bit(HCI_USER_CHANNEL, &d->dev_flags) || | 539 | test_bit(HCI_USER_CHANNEL, &d->dev_flags) || |
544 | d->dev_type != HCI_BREDR) | 540 | d->dev_type != HCI_BREDR) |
545 | continue; | 541 | continue; |
@@ -1059,9 +1055,6 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active) | |||
1059 | 1055 | ||
1060 | BT_DBG("hcon %p mode %d", conn, conn->mode); | 1056 | BT_DBG("hcon %p mode %d", conn, conn->mode); |
1061 | 1057 | ||
1062 | if (test_bit(HCI_RAW, &hdev->flags)) | ||
1063 | return; | ||
1064 | |||
1065 | if (conn->mode != HCI_CM_SNIFF) | 1058 | if (conn->mode != HCI_CM_SNIFF) |
1066 | goto timer; | 1059 | goto timer; |
1067 | 1060 | ||
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 9852449ac104..50db0201213c 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -2117,6 +2117,11 @@ int hci_inquiry(void __user *arg) | |||
2117 | goto done; | 2117 | goto done; |
2118 | } | 2118 | } |
2119 | 2119 | ||
2120 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) { | ||
2121 | err = -EOPNOTSUPP; | ||
2122 | goto done; | ||
2123 | } | ||
2124 | |||
2120 | if (hdev->dev_type != HCI_BREDR) { | 2125 | if (hdev->dev_type != HCI_BREDR) { |
2121 | err = -EOPNOTSUPP; | 2126 | err = -EOPNOTSUPP; |
2122 | goto done; | 2127 | goto done; |
@@ -2246,10 +2251,7 @@ static int hci_dev_do_open(struct hci_dev *hdev) | |||
2246 | ret = hdev->setup(hdev); | 2251 | ret = hdev->setup(hdev); |
2247 | 2252 | ||
2248 | if (!ret) { | 2253 | if (!ret) { |
2249 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) | 2254 | if (!test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks) && |
2250 | set_bit(HCI_RAW, &hdev->flags); | ||
2251 | |||
2252 | if (!test_bit(HCI_RAW, &hdev->flags) && | ||
2253 | !test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) | 2255 | !test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) |
2254 | ret = __hci_init(hdev); | 2256 | ret = __hci_init(hdev); |
2255 | } | 2257 | } |
@@ -2286,7 +2288,7 @@ static int hci_dev_do_open(struct hci_dev *hdev) | |||
2286 | } | 2288 | } |
2287 | 2289 | ||
2288 | hdev->close(hdev); | 2290 | hdev->close(hdev); |
2289 | hdev->flags = 0; | 2291 | hdev->flags &= BIT(HCI_RAW); |
2290 | } | 2292 | } |
2291 | 2293 | ||
2292 | done: | 2294 | done: |
@@ -2305,6 +2307,21 @@ int hci_dev_open(__u16 dev) | |||
2305 | if (!hdev) | 2307 | if (!hdev) |
2306 | return -ENODEV; | 2308 | return -ENODEV; |
2307 | 2309 | ||
2310 | /* Devices that are marked for raw-only usage can only be powered | ||
2311 | * up as user channel. Trying to bring them up as normal devices | ||
2312 | * will result into a failure. Only user channel operation is | ||
2313 | * possible. | ||
2314 | * | ||
2315 | * When this function is called for a user channel, the flag | ||
2316 | * HCI_USER_CHANNEL will be set first before attempting to | ||
2317 | * open the device. | ||
2318 | */ | ||
2319 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks) && | ||
2320 | !test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) { | ||
2321 | err = -EOPNOTSUPP; | ||
2322 | goto done; | ||
2323 | } | ||
2324 | |||
2308 | /* We need to ensure that no other power on/off work is pending | 2325 | /* We need to ensure that no other power on/off work is pending |
2309 | * before proceeding to call hci_dev_do_open. This is | 2326 | * before proceeding to call hci_dev_do_open. This is |
2310 | * particularly important if the setup procedure has not yet | 2327 | * particularly important if the setup procedure has not yet |
@@ -2321,8 +2338,8 @@ int hci_dev_open(__u16 dev) | |||
2321 | 2338 | ||
2322 | err = hci_dev_do_open(hdev); | 2339 | err = hci_dev_do_open(hdev); |
2323 | 2340 | ||
2341 | done: | ||
2324 | hci_dev_put(hdev); | 2342 | hci_dev_put(hdev); |
2325 | |||
2326 | return err; | 2343 | return err; |
2327 | } | 2344 | } |
2328 | 2345 | ||
@@ -2374,7 +2391,7 @@ static int hci_dev_do_close(struct hci_dev *hdev) | |||
2374 | /* Reset device */ | 2391 | /* Reset device */ |
2375 | skb_queue_purge(&hdev->cmd_q); | 2392 | skb_queue_purge(&hdev->cmd_q); |
2376 | atomic_set(&hdev->cmd_cnt, 1); | 2393 | atomic_set(&hdev->cmd_cnt, 1); |
2377 | if (!test_bit(HCI_RAW, &hdev->flags) && | 2394 | if (!test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks) && |
2378 | !test_bit(HCI_AUTO_OFF, &hdev->dev_flags) && | 2395 | !test_bit(HCI_AUTO_OFF, &hdev->dev_flags) && |
2379 | test_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks)) { | 2396 | test_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks)) { |
2380 | set_bit(HCI_INIT, &hdev->flags); | 2397 | set_bit(HCI_INIT, &hdev->flags); |
@@ -2405,7 +2422,7 @@ static int hci_dev_do_close(struct hci_dev *hdev) | |||
2405 | hdev->close(hdev); | 2422 | hdev->close(hdev); |
2406 | 2423 | ||
2407 | /* Clear flags */ | 2424 | /* Clear flags */ |
2408 | hdev->flags = 0; | 2425 | hdev->flags &= BIT(HCI_RAW); |
2409 | hdev->dev_flags &= ~HCI_PERSISTENT_MASK; | 2426 | hdev->dev_flags &= ~HCI_PERSISTENT_MASK; |
2410 | 2427 | ||
2411 | if (!test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) { | 2428 | if (!test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) { |
@@ -2474,6 +2491,11 @@ int hci_dev_reset(__u16 dev) | |||
2474 | goto done; | 2491 | goto done; |
2475 | } | 2492 | } |
2476 | 2493 | ||
2494 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) { | ||
2495 | ret = -EOPNOTSUPP; | ||
2496 | goto done; | ||
2497 | } | ||
2498 | |||
2477 | /* Drop queues */ | 2499 | /* Drop queues */ |
2478 | skb_queue_purge(&hdev->rx_q); | 2500 | skb_queue_purge(&hdev->rx_q); |
2479 | skb_queue_purge(&hdev->cmd_q); | 2501 | skb_queue_purge(&hdev->cmd_q); |
@@ -2489,8 +2511,7 @@ int hci_dev_reset(__u16 dev) | |||
2489 | atomic_set(&hdev->cmd_cnt, 1); | 2511 | atomic_set(&hdev->cmd_cnt, 1); |
2490 | hdev->acl_cnt = 0; hdev->sco_cnt = 0; hdev->le_cnt = 0; | 2512 | hdev->acl_cnt = 0; hdev->sco_cnt = 0; hdev->le_cnt = 0; |
2491 | 2513 | ||
2492 | if (!test_bit(HCI_RAW, &hdev->flags)) | 2514 | ret = __hci_req_sync(hdev, hci_reset_req, 0, HCI_INIT_TIMEOUT); |
2493 | ret = __hci_req_sync(hdev, hci_reset_req, 0, HCI_INIT_TIMEOUT); | ||
2494 | 2515 | ||
2495 | done: | 2516 | done: |
2496 | hci_req_unlock(hdev); | 2517 | hci_req_unlock(hdev); |
@@ -2512,6 +2533,11 @@ int hci_dev_reset_stat(__u16 dev) | |||
2512 | goto done; | 2533 | goto done; |
2513 | } | 2534 | } |
2514 | 2535 | ||
2536 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) { | ||
2537 | ret = -EOPNOTSUPP; | ||
2538 | goto done; | ||
2539 | } | ||
2540 | |||
2515 | memset(&hdev->stat, 0, sizeof(struct hci_dev_stats)); | 2541 | memset(&hdev->stat, 0, sizeof(struct hci_dev_stats)); |
2516 | 2542 | ||
2517 | done: | 2543 | done: |
@@ -2537,6 +2563,11 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg) | |||
2537 | goto done; | 2563 | goto done; |
2538 | } | 2564 | } |
2539 | 2565 | ||
2566 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) { | ||
2567 | err = -EOPNOTSUPP; | ||
2568 | goto done; | ||
2569 | } | ||
2570 | |||
2540 | if (hdev->dev_type != HCI_BREDR) { | 2571 | if (hdev->dev_type != HCI_BREDR) { |
2541 | err = -EOPNOTSUPP; | 2572 | err = -EOPNOTSUPP; |
2542 | goto done; | 2573 | goto done; |
@@ -2760,8 +2791,10 @@ static void hci_power_on(struct work_struct *work) | |||
2760 | HCI_AUTO_OFF_TIMEOUT); | 2791 | HCI_AUTO_OFF_TIMEOUT); |
2761 | } | 2792 | } |
2762 | 2793 | ||
2763 | if (test_and_clear_bit(HCI_SETUP, &hdev->dev_flags)) | 2794 | if (test_and_clear_bit(HCI_SETUP, &hdev->dev_flags)) { |
2764 | mgmt_index_added(hdev); | 2795 | if (!test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) |
2796 | mgmt_index_added(hdev); | ||
2797 | } | ||
2765 | } | 2798 | } |
2766 | 2799 | ||
2767 | static void hci_power_off(struct work_struct *work) | 2800 | static void hci_power_off(struct work_struct *work) |
@@ -3887,6 +3920,13 @@ int hci_register_dev(struct hci_dev *hdev) | |||
3887 | list_add(&hdev->list, &hci_dev_list); | 3920 | list_add(&hdev->list, &hci_dev_list); |
3888 | write_unlock(&hci_dev_list_lock); | 3921 | write_unlock(&hci_dev_list_lock); |
3889 | 3922 | ||
3923 | /* Devices that are marked for raw-only usage need to set | ||
3924 | * the HCI_RAW flag to indicate that only user channel is | ||
3925 | * supported. | ||
3926 | */ | ||
3927 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) | ||
3928 | set_bit(HCI_RAW, &hdev->flags); | ||
3929 | |||
3890 | hci_notify(hdev, HCI_DEV_REG); | 3930 | hci_notify(hdev, HCI_DEV_REG); |
3891 | hci_dev_hold(hdev); | 3931 | hci_dev_hold(hdev); |
3892 | 3932 | ||
@@ -3929,7 +3969,8 @@ void hci_unregister_dev(struct hci_dev *hdev) | |||
3929 | cancel_work_sync(&hdev->power_on); | 3969 | cancel_work_sync(&hdev->power_on); |
3930 | 3970 | ||
3931 | if (!test_bit(HCI_INIT, &hdev->flags) && | 3971 | if (!test_bit(HCI_INIT, &hdev->flags) && |
3932 | !test_bit(HCI_SETUP, &hdev->dev_flags)) { | 3972 | !test_bit(HCI_SETUP, &hdev->dev_flags) && |
3973 | !test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) { | ||
3933 | hci_dev_lock(hdev); | 3974 | hci_dev_lock(hdev); |
3934 | mgmt_index_removed(hdev); | 3975 | mgmt_index_removed(hdev); |
3935 | hci_dev_unlock(hdev); | 3976 | hci_dev_unlock(hdev); |
@@ -4694,7 +4735,7 @@ static inline int __get_blocks(struct hci_dev *hdev, struct sk_buff *skb) | |||
4694 | 4735 | ||
4695 | static void __check_timeout(struct hci_dev *hdev, unsigned int cnt) | 4736 | static void __check_timeout(struct hci_dev *hdev, unsigned int cnt) |
4696 | { | 4737 | { |
4697 | if (!test_bit(HCI_RAW, &hdev->flags)) { | 4738 | if (!test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) { |
4698 | /* ACL tx timeout must be longer than maximum | 4739 | /* ACL tx timeout must be longer than maximum |
4699 | * link supervision timeout (40.9 seconds) */ | 4740 | * link supervision timeout (40.9 seconds) */ |
4700 | if (!cnt && time_after(jiffies, hdev->acl_last_tx + | 4741 | if (!cnt && time_after(jiffies, hdev->acl_last_tx + |
@@ -4877,7 +4918,7 @@ static void hci_sched_le(struct hci_dev *hdev) | |||
4877 | if (!hci_conn_num(hdev, LE_LINK)) | 4918 | if (!hci_conn_num(hdev, LE_LINK)) |
4878 | return; | 4919 | return; |
4879 | 4920 | ||
4880 | if (!test_bit(HCI_RAW, &hdev->flags)) { | 4921 | if (!test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) { |
4881 | /* LE tx timeout must be longer than maximum | 4922 | /* LE tx timeout must be longer than maximum |
4882 | * link supervision timeout (40.9 seconds) */ | 4923 | * link supervision timeout (40.9 seconds) */ |
4883 | if (!hdev->le_cnt && hdev->le_pkts && | 4924 | if (!hdev->le_cnt && hdev->le_pkts && |
@@ -5122,8 +5163,7 @@ static void hci_rx_work(struct work_struct *work) | |||
5122 | hci_send_to_sock(hdev, skb); | 5163 | hci_send_to_sock(hdev, skb); |
5123 | } | 5164 | } |
5124 | 5165 | ||
5125 | if (test_bit(HCI_RAW, &hdev->flags) || | 5166 | if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) { |
5126 | test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) { | ||
5127 | kfree_skb(skb); | 5167 | kfree_skb(skb); |
5128 | continue; | 5168 | continue; |
5129 | } | 5169 | } |
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 80d25c150a65..54e4e8fd5d97 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c | |||
@@ -453,7 +453,8 @@ static int hci_sock_release(struct socket *sock) | |||
453 | 453 | ||
454 | if (hdev) { | 454 | if (hdev) { |
455 | if (hci_pi(sk)->channel == HCI_CHANNEL_USER) { | 455 | if (hci_pi(sk)->channel == HCI_CHANNEL_USER) { |
456 | mgmt_index_added(hdev); | 456 | if (!test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) |
457 | mgmt_index_added(hdev); | ||
457 | clear_bit(HCI_USER_CHANNEL, &hdev->dev_flags); | 458 | clear_bit(HCI_USER_CHANNEL, &hdev->dev_flags); |
458 | hci_dev_close(hdev->id); | 459 | hci_dev_close(hdev->id); |
459 | } | 460 | } |
@@ -517,6 +518,9 @@ static int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd, | |||
517 | if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) | 518 | if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) |
518 | return -EBUSY; | 519 | return -EBUSY; |
519 | 520 | ||
521 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) | ||
522 | return -EOPNOTSUPP; | ||
523 | |||
520 | if (hdev->dev_type != HCI_BREDR) | 524 | if (hdev->dev_type != HCI_BREDR) |
521 | return -EOPNOTSUPP; | 525 | return -EOPNOTSUPP; |
522 | 526 | ||
@@ -702,12 +706,14 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, | |||
702 | goto done; | 706 | goto done; |
703 | } | 707 | } |
704 | 708 | ||
705 | mgmt_index_removed(hdev); | 709 | if (!test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) |
710 | mgmt_index_removed(hdev); | ||
706 | 711 | ||
707 | err = hci_dev_open(hdev->id); | 712 | err = hci_dev_open(hdev->id); |
708 | if (err) { | 713 | if (err) { |
709 | clear_bit(HCI_USER_CHANNEL, &hdev->dev_flags); | 714 | clear_bit(HCI_USER_CHANNEL, &hdev->dev_flags); |
710 | mgmt_index_added(hdev); | 715 | if (!test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) |
716 | mgmt_index_added(hdev); | ||
711 | hci_dev_put(hdev); | 717 | hci_dev_put(hdev); |
712 | goto done; | 718 | goto done; |
713 | } | 719 | } |
@@ -960,7 +966,7 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
960 | goto drop; | 966 | goto drop; |
961 | } | 967 | } |
962 | 968 | ||
963 | if (test_bit(HCI_RAW, &hdev->flags) || (ogf == 0x3f)) { | 969 | if (ogf == 0x3f) { |
964 | skb_queue_tail(&hdev->raw_q, skb); | 970 | skb_queue_tail(&hdev->raw_q, skb); |
965 | queue_work(hdev->workqueue, &hdev->tx_work); | 971 | queue_work(hdev->workqueue, &hdev->tx_work); |
966 | } else { | 972 | } else { |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 6faa4616cbfe..41b1aec0c5dc 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -347,6 +347,9 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data, | |||
347 | if (test_bit(HCI_USER_CHANNEL, &d->dev_flags)) | 347 | if (test_bit(HCI_USER_CHANNEL, &d->dev_flags)) |
348 | continue; | 348 | continue; |
349 | 349 | ||
350 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &d->quirks)) | ||
351 | continue; | ||
352 | |||
350 | if (d->dev_type == HCI_BREDR) { | 353 | if (d->dev_type == HCI_BREDR) { |
351 | rp->index[count++] = cpu_to_le16(d->id); | 354 | rp->index[count++] = cpu_to_le16(d->id); |
352 | BT_DBG("Added hci%u", d->id); | 355 | BT_DBG("Added hci%u", d->id); |
@@ -5066,7 +5069,8 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) | |||
5066 | } | 5069 | } |
5067 | 5070 | ||
5068 | if (test_bit(HCI_SETUP, &hdev->dev_flags) || | 5071 | if (test_bit(HCI_SETUP, &hdev->dev_flags) || |
5069 | test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) { | 5072 | test_bit(HCI_USER_CHANNEL, &hdev->dev_flags) || |
5073 | test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) { | ||
5070 | err = cmd_status(sk, index, opcode, | 5074 | err = cmd_status(sk, index, opcode, |
5071 | MGMT_STATUS_INVALID_INDEX); | 5075 | MGMT_STATUS_INVALID_INDEX); |
5072 | goto done; | 5076 | goto done; |