diff options
-rw-r--r-- | include/net/bluetooth/hci.h | 1 | ||||
-rw-r--r-- | net/bluetooth/hci_core.c | 43 | ||||
-rw-r--r-- | net/bluetooth/hci_sock.c | 8 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 6 |
4 files changed, 34 insertions, 24 deletions
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 66358af6b1fc..606a9b1466a3 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h | |||
@@ -127,6 +127,7 @@ enum { | |||
127 | HCI_KEEP_DEBUG_KEYS, | 127 | HCI_KEEP_DEBUG_KEYS, |
128 | HCI_USE_DEBUG_KEYS, | 128 | HCI_USE_DEBUG_KEYS, |
129 | HCI_UNREGISTER, | 129 | HCI_UNREGISTER, |
130 | HCI_UNCONFIGURED, | ||
130 | HCI_USER_CHANNEL, | 131 | HCI_USER_CHANNEL, |
131 | 132 | ||
132 | HCI_LE_SCAN, | 133 | HCI_LE_SCAN, |
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 1fff3d890f41..395b014ad0e8 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -2116,7 +2116,7 @@ int hci_inquiry(void __user *arg) | |||
2116 | goto done; | 2116 | goto done; |
2117 | } | 2117 | } |
2118 | 2118 | ||
2119 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) { | 2119 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) { |
2120 | err = -EOPNOTSUPP; | 2120 | err = -EOPNOTSUPP; |
2121 | goto done; | 2121 | goto done; |
2122 | } | 2122 | } |
@@ -2261,7 +2261,7 @@ static int hci_dev_do_open(struct hci_dev *hdev) | |||
2261 | } | 2261 | } |
2262 | 2262 | ||
2263 | if (!ret) { | 2263 | if (!ret) { |
2264 | if (!test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks) && | 2264 | if (!test_bit(HCI_UNCONFIGURED, &hdev->dev_flags) && |
2265 | !test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) | 2265 | !test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) |
2266 | ret = __hci_init(hdev); | 2266 | ret = __hci_init(hdev); |
2267 | } | 2267 | } |
@@ -2274,6 +2274,7 @@ static int hci_dev_do_open(struct hci_dev *hdev) | |||
2274 | set_bit(HCI_UP, &hdev->flags); | 2274 | set_bit(HCI_UP, &hdev->flags); |
2275 | hci_notify(hdev, HCI_DEV_UP); | 2275 | hci_notify(hdev, HCI_DEV_UP); |
2276 | if (!test_bit(HCI_SETUP, &hdev->dev_flags) && | 2276 | if (!test_bit(HCI_SETUP, &hdev->dev_flags) && |
2277 | !test_bit(HCI_UNCONFIGURED, &hdev->dev_flags) && | ||
2277 | !test_bit(HCI_USER_CHANNEL, &hdev->dev_flags) && | 2278 | !test_bit(HCI_USER_CHANNEL, &hdev->dev_flags) && |
2278 | hdev->dev_type == HCI_BREDR) { | 2279 | hdev->dev_type == HCI_BREDR) { |
2279 | hci_dev_lock(hdev); | 2280 | hci_dev_lock(hdev); |
@@ -2317,7 +2318,7 @@ int hci_dev_open(__u16 dev) | |||
2317 | if (!hdev) | 2318 | if (!hdev) |
2318 | return -ENODEV; | 2319 | return -ENODEV; |
2319 | 2320 | ||
2320 | /* Devices that are marked for raw-only usage can only be powered | 2321 | /* Devices that are marked as unconfigured can only be powered |
2321 | * up as user channel. Trying to bring them up as normal devices | 2322 | * up as user channel. Trying to bring them up as normal devices |
2322 | * will result into a failure. Only user channel operation is | 2323 | * will result into a failure. Only user channel operation is |
2323 | * possible. | 2324 | * possible. |
@@ -2326,7 +2327,7 @@ int hci_dev_open(__u16 dev) | |||
2326 | * HCI_USER_CHANNEL will be set first before attempting to | 2327 | * HCI_USER_CHANNEL will be set first before attempting to |
2327 | * open the device. | 2328 | * open the device. |
2328 | */ | 2329 | */ |
2329 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks) && | 2330 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags) && |
2330 | !test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) { | 2331 | !test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) { |
2331 | err = -EOPNOTSUPP; | 2332 | err = -EOPNOTSUPP; |
2332 | goto done; | 2333 | goto done; |
@@ -2401,8 +2402,8 @@ static int hci_dev_do_close(struct hci_dev *hdev) | |||
2401 | /* Reset device */ | 2402 | /* Reset device */ |
2402 | skb_queue_purge(&hdev->cmd_q); | 2403 | skb_queue_purge(&hdev->cmd_q); |
2403 | atomic_set(&hdev->cmd_cnt, 1); | 2404 | atomic_set(&hdev->cmd_cnt, 1); |
2404 | if (!test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks) && | 2405 | if (!test_bit(HCI_AUTO_OFF, &hdev->dev_flags) && |
2405 | !test_bit(HCI_AUTO_OFF, &hdev->dev_flags) && | 2406 | !test_bit(HCI_UNCONFIGURED, &hdev->dev_flags) && |
2406 | test_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks)) { | 2407 | test_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks)) { |
2407 | set_bit(HCI_INIT, &hdev->flags); | 2408 | set_bit(HCI_INIT, &hdev->flags); |
2408 | __hci_req_sync(hdev, hci_reset_req, 0, HCI_CMD_TIMEOUT); | 2409 | __hci_req_sync(hdev, hci_reset_req, 0, HCI_CMD_TIMEOUT); |
@@ -2501,7 +2502,7 @@ int hci_dev_reset(__u16 dev) | |||
2501 | goto done; | 2502 | goto done; |
2502 | } | 2503 | } |
2503 | 2504 | ||
2504 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) { | 2505 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) { |
2505 | ret = -EOPNOTSUPP; | 2506 | ret = -EOPNOTSUPP; |
2506 | goto done; | 2507 | goto done; |
2507 | } | 2508 | } |
@@ -2543,7 +2544,7 @@ int hci_dev_reset_stat(__u16 dev) | |||
2543 | goto done; | 2544 | goto done; |
2544 | } | 2545 | } |
2545 | 2546 | ||
2546 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) { | 2547 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) { |
2547 | ret = -EOPNOTSUPP; | 2548 | ret = -EOPNOTSUPP; |
2548 | goto done; | 2549 | goto done; |
2549 | } | 2550 | } |
@@ -2573,7 +2574,7 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg) | |||
2573 | goto done; | 2574 | goto done; |
2574 | } | 2575 | } |
2575 | 2576 | ||
2576 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) { | 2577 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) { |
2577 | err = -EOPNOTSUPP; | 2578 | err = -EOPNOTSUPP; |
2578 | goto done; | 2579 | goto done; |
2579 | } | 2580 | } |
@@ -2791,6 +2792,7 @@ static void hci_power_on(struct work_struct *work) | |||
2791 | * valid, it is important to turn the device back off. | 2792 | * valid, it is important to turn the device back off. |
2792 | */ | 2793 | */ |
2793 | if (test_bit(HCI_RFKILLED, &hdev->dev_flags) || | 2794 | if (test_bit(HCI_RFKILLED, &hdev->dev_flags) || |
2795 | test_bit(HCI_UNCONFIGURED, &hdev->dev_flags) || | ||
2794 | (hdev->dev_type == HCI_BREDR && | 2796 | (hdev->dev_type == HCI_BREDR && |
2795 | !bacmp(&hdev->bdaddr, BDADDR_ANY) && | 2797 | !bacmp(&hdev->bdaddr, BDADDR_ANY) && |
2796 | !bacmp(&hdev->static_addr, BDADDR_ANY))) { | 2798 | !bacmp(&hdev->static_addr, BDADDR_ANY))) { |
@@ -2802,7 +2804,15 @@ static void hci_power_on(struct work_struct *work) | |||
2802 | } | 2804 | } |
2803 | 2805 | ||
2804 | if (test_and_clear_bit(HCI_SETUP, &hdev->dev_flags)) { | 2806 | if (test_and_clear_bit(HCI_SETUP, &hdev->dev_flags)) { |
2805 | if (!test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) | 2807 | /* For unconfigured devices, set the HCI_RAW flag |
2808 | * so that userspace can easily identify them. | ||
2809 | * | ||
2810 | * If the device is fully configured and ready for | ||
2811 | * operation, announce it via management interface. | ||
2812 | */ | ||
2813 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) | ||
2814 | set_bit(HCI_RAW, &hdev->flags); | ||
2815 | else | ||
2806 | mgmt_index_added(hdev); | 2816 | mgmt_index_added(hdev); |
2807 | } | 2817 | } |
2808 | } | 2818 | } |
@@ -3974,12 +3984,11 @@ int hci_register_dev(struct hci_dev *hdev) | |||
3974 | list_add(&hdev->list, &hci_dev_list); | 3984 | list_add(&hdev->list, &hci_dev_list); |
3975 | write_unlock(&hci_dev_list_lock); | 3985 | write_unlock(&hci_dev_list_lock); |
3976 | 3986 | ||
3977 | /* Devices that are marked for raw-only usage need to set | 3987 | /* Devices that are marked for raw-only usage are unconfigured |
3978 | * the HCI_RAW flag to indicate that only user channel is | 3988 | * and should not be included in normal operation. |
3979 | * supported. | ||
3980 | */ | 3989 | */ |
3981 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) | 3990 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) |
3982 | set_bit(HCI_RAW, &hdev->flags); | 3991 | set_bit(HCI_UNCONFIGURED, &hdev->dev_flags); |
3983 | 3992 | ||
3984 | hci_notify(hdev, HCI_DEV_REG); | 3993 | hci_notify(hdev, HCI_DEV_REG); |
3985 | hci_dev_hold(hdev); | 3994 | hci_dev_hold(hdev); |
@@ -4024,7 +4033,7 @@ void hci_unregister_dev(struct hci_dev *hdev) | |||
4024 | 4033 | ||
4025 | if (!test_bit(HCI_INIT, &hdev->flags) && | 4034 | if (!test_bit(HCI_INIT, &hdev->flags) && |
4026 | !test_bit(HCI_SETUP, &hdev->dev_flags) && | 4035 | !test_bit(HCI_SETUP, &hdev->dev_flags) && |
4027 | !test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) { | 4036 | !test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) { |
4028 | hci_dev_lock(hdev); | 4037 | hci_dev_lock(hdev); |
4029 | mgmt_index_removed(hdev); | 4038 | mgmt_index_removed(hdev); |
4030 | hci_dev_unlock(hdev); | 4039 | hci_dev_unlock(hdev); |
@@ -4788,7 +4797,7 @@ static inline int __get_blocks(struct hci_dev *hdev, struct sk_buff *skb) | |||
4788 | 4797 | ||
4789 | static void __check_timeout(struct hci_dev *hdev, unsigned int cnt) | 4798 | static void __check_timeout(struct hci_dev *hdev, unsigned int cnt) |
4790 | { | 4799 | { |
4791 | if (!test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) { | 4800 | if (!test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) { |
4792 | /* ACL tx timeout must be longer than maximum | 4801 | /* ACL tx timeout must be longer than maximum |
4793 | * link supervision timeout (40.9 seconds) */ | 4802 | * link supervision timeout (40.9 seconds) */ |
4794 | if (!cnt && time_after(jiffies, hdev->acl_last_tx + | 4803 | if (!cnt && time_after(jiffies, hdev->acl_last_tx + |
@@ -4971,7 +4980,7 @@ static void hci_sched_le(struct hci_dev *hdev) | |||
4971 | if (!hci_conn_num(hdev, LE_LINK)) | 4980 | if (!hci_conn_num(hdev, LE_LINK)) |
4972 | return; | 4981 | return; |
4973 | 4982 | ||
4974 | if (!test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) { | 4983 | if (!test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) { |
4975 | /* LE tx timeout must be longer than maximum | 4984 | /* LE tx timeout must be longer than maximum |
4976 | * link supervision timeout (40.9 seconds) */ | 4985 | * link supervision timeout (40.9 seconds) */ |
4977 | if (!hdev->le_cnt && hdev->le_pkts && | 4986 | if (!hdev->le_cnt && hdev->le_pkts && |
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 54e4e8fd5d97..db9610323d4d 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c | |||
@@ -453,7 +453,7 @@ 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 | if (!test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) | 456 | if (!test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) |
457 | mgmt_index_added(hdev); | 457 | mgmt_index_added(hdev); |
458 | clear_bit(HCI_USER_CHANNEL, &hdev->dev_flags); | 458 | clear_bit(HCI_USER_CHANNEL, &hdev->dev_flags); |
459 | hci_dev_close(hdev->id); | 459 | hci_dev_close(hdev->id); |
@@ -518,7 +518,7 @@ static int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd, | |||
518 | if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) | 518 | if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) |
519 | return -EBUSY; | 519 | return -EBUSY; |
520 | 520 | ||
521 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) | 521 | if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) |
522 | return -EOPNOTSUPP; | 522 | return -EOPNOTSUPP; |
523 | 523 | ||
524 | if (hdev->dev_type != HCI_BREDR) | 524 | if (hdev->dev_type != HCI_BREDR) |
@@ -706,13 +706,13 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, | |||
706 | goto done; | 706 | goto done; |
707 | } | 707 | } |
708 | 708 | ||
709 | if (!test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) | 709 | if (!test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) |
710 | mgmt_index_removed(hdev); | 710 | mgmt_index_removed(hdev); |
711 | 711 | ||
712 | err = hci_dev_open(hdev->id); | 712 | err = hci_dev_open(hdev->id); |
713 | if (err) { | 713 | if (err) { |
714 | clear_bit(HCI_USER_CHANNEL, &hdev->dev_flags); | 714 | clear_bit(HCI_USER_CHANNEL, &hdev->dev_flags); |
715 | if (!test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) | 715 | if (!test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) |
716 | mgmt_index_added(hdev); | 716 | mgmt_index_added(hdev); |
717 | hci_dev_put(hdev); | 717 | hci_dev_put(hdev); |
718 | goto done; | 718 | goto done; |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 50a0a3ec50b0..1ab98980054c 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -353,7 +353,7 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data, | |||
353 | if (test_bit(HCI_USER_CHANNEL, &d->dev_flags)) | 353 | if (test_bit(HCI_USER_CHANNEL, &d->dev_flags)) |
354 | continue; | 354 | continue; |
355 | 355 | ||
356 | if (test_bit(HCI_QUIRK_RAW_DEVICE, &d->quirks)) | 356 | if (test_bit(HCI_UNCONFIGURED, &d->dev_flags)) |
357 | continue; | 357 | continue; |
358 | 358 | ||
359 | if (d->dev_type == HCI_BREDR) { | 359 | if (d->dev_type == HCI_BREDR) { |
@@ -5317,8 +5317,8 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) | |||
5317 | } | 5317 | } |
5318 | 5318 | ||
5319 | if (test_bit(HCI_SETUP, &hdev->dev_flags) || | 5319 | if (test_bit(HCI_SETUP, &hdev->dev_flags) || |
5320 | test_bit(HCI_USER_CHANNEL, &hdev->dev_flags) || | 5320 | test_bit(HCI_UNCONFIGURED, &hdev->dev_flags) || |
5321 | test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) { | 5321 | test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) { |
5322 | err = cmd_status(sk, index, opcode, | 5322 | err = cmd_status(sk, index, opcode, |
5323 | MGMT_STATUS_INVALID_INDEX); | 5323 | MGMT_STATUS_INVALID_INDEX); |
5324 | goto done; | 5324 | goto done; |