aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/bluetooth/hci_core.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 3321c65c73ac..96e0acc3fc92 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2817,14 +2817,20 @@ int hci_get_dev_list(void __user *arg)
2817 2817
2818 read_lock(&hci_dev_list_lock); 2818 read_lock(&hci_dev_list_lock);
2819 list_for_each_entry(hdev, &hci_dev_list, list) { 2819 list_for_each_entry(hdev, &hci_dev_list, list) {
2820 if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) 2820 unsigned long flags = hdev->flags;
2821 cancel_delayed_work(&hdev->power_off); 2821
2822 /* When the auto-off is configured it means the transport
2823 * is running, but in that case still indicate that the
2824 * device is actually down.
2825 */
2826 if (test_bit(HCI_AUTO_OFF, &hdev->dev_flags))
2827 flags &= ~BIT(HCI_UP);
2822 2828
2823 if (!test_bit(HCI_MGMT, &hdev->dev_flags)) 2829 if (!test_bit(HCI_MGMT, &hdev->dev_flags))
2824 set_bit(HCI_PAIRABLE, &hdev->dev_flags); 2830 set_bit(HCI_PAIRABLE, &hdev->dev_flags);
2825 2831
2826 (dr + n)->dev_id = hdev->id; 2832 (dr + n)->dev_id = hdev->id;
2827 (dr + n)->dev_opt = hdev->flags; 2833 (dr + n)->dev_opt = flags;
2828 2834
2829 if (++n >= dev_num) 2835 if (++n >= dev_num)
2830 break; 2836 break;
@@ -2844,6 +2850,7 @@ int hci_get_dev_info(void __user *arg)
2844{ 2850{
2845 struct hci_dev *hdev; 2851 struct hci_dev *hdev;
2846 struct hci_dev_info di; 2852 struct hci_dev_info di;
2853 unsigned long flags;
2847 int err = 0; 2854 int err = 0;
2848 2855
2849 if (copy_from_user(&di, arg, sizeof(di))) 2856 if (copy_from_user(&di, arg, sizeof(di)))
@@ -2853,8 +2860,14 @@ int hci_get_dev_info(void __user *arg)
2853 if (!hdev) 2860 if (!hdev)
2854 return -ENODEV; 2861 return -ENODEV;
2855 2862
2856 if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) 2863 /* When the auto-off is configured it means the transport
2857 cancel_delayed_work_sync(&hdev->power_off); 2864 * is running, but in that case still indicate that the
2865 * device is actually down.
2866 */
2867 if (test_bit(HCI_AUTO_OFF, &hdev->dev_flags))
2868 flags = hdev->flags & ~BIT(HCI_UP);
2869 else
2870 flags = hdev->flags;
2858 2871
2859 if (!test_bit(HCI_MGMT, &hdev->dev_flags)) 2872 if (!test_bit(HCI_MGMT, &hdev->dev_flags))
2860 set_bit(HCI_PAIRABLE, &hdev->dev_flags); 2873 set_bit(HCI_PAIRABLE, &hdev->dev_flags);
@@ -2862,7 +2875,7 @@ int hci_get_dev_info(void __user *arg)
2862 strcpy(di.name, hdev->name); 2875 strcpy(di.name, hdev->name);
2863 di.bdaddr = hdev->bdaddr; 2876 di.bdaddr = hdev->bdaddr;
2864 di.type = (hdev->bus & 0x0f) | ((hdev->dev_type & 0x03) << 4); 2877 di.type = (hdev->bus & 0x0f) | ((hdev->dev_type & 0x03) << 4);
2865 di.flags = hdev->flags; 2878 di.flags = flags;
2866 di.pkt_type = hdev->pkt_type; 2879 di.pkt_type = hdev->pkt_type;
2867 if (lmp_bredr_capable(hdev)) { 2880 if (lmp_bredr_capable(hdev)) {
2868 di.acl_mtu = hdev->acl_mtu; 2881 di.acl_mtu = hdev->acl_mtu;