diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/hci_core.c | 93 |
1 files changed, 9 insertions, 84 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 97a6453bee30..8d972023196b 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -879,104 +879,29 @@ static int adv_channel_map_get(void *data, u64 *val) | |||
879 | DEFINE_SIMPLE_ATTRIBUTE(adv_channel_map_fops, adv_channel_map_get, | 879 | DEFINE_SIMPLE_ATTRIBUTE(adv_channel_map_fops, adv_channel_map_get, |
880 | adv_channel_map_set, "%llu\n"); | 880 | adv_channel_map_set, "%llu\n"); |
881 | 881 | ||
882 | static int le_auto_conn_show(struct seq_file *sf, void *ptr) | 882 | static int device_list_show(struct seq_file *f, void *ptr) |
883 | { | 883 | { |
884 | struct hci_dev *hdev = sf->private; | 884 | struct hci_dev *hdev = f->private; |
885 | struct hci_conn_params *p; | 885 | struct hci_conn_params *p; |
886 | 886 | ||
887 | hci_dev_lock(hdev); | 887 | hci_dev_lock(hdev); |
888 | |||
889 | list_for_each_entry(p, &hdev->le_conn_params, list) { | 888 | list_for_each_entry(p, &hdev->le_conn_params, list) { |
890 | seq_printf(sf, "%pMR %u %u\n", &p->addr, p->addr_type, | 889 | seq_printf(f, "%pMR %u %u\n", &p->addr, p->addr_type, |
891 | p->auto_connect); | 890 | p->auto_connect); |
892 | } | 891 | } |
893 | |||
894 | hci_dev_unlock(hdev); | 892 | hci_dev_unlock(hdev); |
895 | 893 | ||
896 | return 0; | 894 | return 0; |
897 | } | 895 | } |
898 | 896 | ||
899 | static int le_auto_conn_open(struct inode *inode, struct file *file) | 897 | static int device_list_open(struct inode *inode, struct file *file) |
900 | { | ||
901 | return single_open(file, le_auto_conn_show, inode->i_private); | ||
902 | } | ||
903 | |||
904 | static ssize_t le_auto_conn_write(struct file *file, const char __user *data, | ||
905 | size_t count, loff_t *offset) | ||
906 | { | 898 | { |
907 | struct seq_file *sf = file->private_data; | 899 | return single_open(file, device_list_show, inode->i_private); |
908 | struct hci_dev *hdev = sf->private; | ||
909 | u8 auto_connect = 0; | ||
910 | bdaddr_t addr; | ||
911 | u8 addr_type; | ||
912 | char *buf; | ||
913 | int err = 0; | ||
914 | int n; | ||
915 | |||
916 | /* Don't allow partial write */ | ||
917 | if (*offset != 0) | ||
918 | return -EINVAL; | ||
919 | |||
920 | if (count < 3) | ||
921 | return -EINVAL; | ||
922 | |||
923 | buf = memdup_user(data, count); | ||
924 | if (IS_ERR(buf)) | ||
925 | return PTR_ERR(buf); | ||
926 | |||
927 | if (memcmp(buf, "add", 3) == 0) { | ||
928 | n = sscanf(&buf[4], "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx %hhu %hhu", | ||
929 | &addr.b[5], &addr.b[4], &addr.b[3], &addr.b[2], | ||
930 | &addr.b[1], &addr.b[0], &addr_type, | ||
931 | &auto_connect); | ||
932 | |||
933 | if (n < 7) { | ||
934 | err = -EINVAL; | ||
935 | goto done; | ||
936 | } | ||
937 | |||
938 | hci_dev_lock(hdev); | ||
939 | err = hci_conn_params_add(hdev, &addr, addr_type, auto_connect, | ||
940 | hdev->le_conn_min_interval, | ||
941 | hdev->le_conn_max_interval); | ||
942 | hci_dev_unlock(hdev); | ||
943 | |||
944 | if (err) | ||
945 | goto done; | ||
946 | } else if (memcmp(buf, "del", 3) == 0) { | ||
947 | n = sscanf(&buf[4], "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx %hhu", | ||
948 | &addr.b[5], &addr.b[4], &addr.b[3], &addr.b[2], | ||
949 | &addr.b[1], &addr.b[0], &addr_type); | ||
950 | |||
951 | if (n < 7) { | ||
952 | err = -EINVAL; | ||
953 | goto done; | ||
954 | } | ||
955 | |||
956 | hci_dev_lock(hdev); | ||
957 | hci_conn_params_del(hdev, &addr, addr_type); | ||
958 | hci_dev_unlock(hdev); | ||
959 | } else if (memcmp(buf, "clr", 3) == 0) { | ||
960 | hci_dev_lock(hdev); | ||
961 | hci_conn_params_clear(hdev); | ||
962 | hci_dev_unlock(hdev); | ||
963 | } else { | ||
964 | err = -EINVAL; | ||
965 | } | ||
966 | |||
967 | done: | ||
968 | kfree(buf); | ||
969 | |||
970 | if (err) | ||
971 | return err; | ||
972 | else | ||
973 | return count; | ||
974 | } | 900 | } |
975 | 901 | ||
976 | static const struct file_operations le_auto_conn_fops = { | 902 | static const struct file_operations device_list_fops = { |
977 | .open = le_auto_conn_open, | 903 | .open = device_list_open, |
978 | .read = seq_read, | 904 | .read = seq_read, |
979 | .write = le_auto_conn_write, | ||
980 | .llseek = seq_lseek, | 905 | .llseek = seq_lseek, |
981 | .release = single_release, | 906 | .release = single_release, |
982 | }; | 907 | }; |
@@ -1785,8 +1710,8 @@ static int __hci_init(struct hci_dev *hdev) | |||
1785 | hdev, &conn_max_interval_fops); | 1710 | hdev, &conn_max_interval_fops); |
1786 | debugfs_create_file("adv_channel_map", 0644, hdev->debugfs, | 1711 | debugfs_create_file("adv_channel_map", 0644, hdev->debugfs, |
1787 | hdev, &adv_channel_map_fops); | 1712 | hdev, &adv_channel_map_fops); |
1788 | debugfs_create_file("le_auto_conn", 0644, hdev->debugfs, hdev, | 1713 | debugfs_create_file("device_list", 0444, hdev->debugfs, hdev, |
1789 | &le_auto_conn_fops); | 1714 | &device_list_fops); |
1790 | debugfs_create_u16("discov_interleaved_timeout", 0644, | 1715 | debugfs_create_u16("discov_interleaved_timeout", 0644, |
1791 | hdev->debugfs, | 1716 | hdev->debugfs, |
1792 | &hdev->discov_interleaved_timeout); | 1717 | &hdev->discov_interleaved_timeout); |