diff options
author | James Morris <jmorris@namei.org> | 2010-03-30 17:39:27 -0400 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2010-03-30 17:39:27 -0400 |
commit | d25d6fa1a95f465ff1ec4458ca15e30b2c8dffec (patch) | |
tree | 7362b182dedd825fc762ef7706830837e42943af /net/bluetooth | |
parent | 225a9be24d799aa16d543c31fb09f0c9ed1d9caa (diff) | |
parent | 2eaa9cfdf33b8d7fb7aff27792192e0019ae8fc6 (diff) |
Merge branch 'master' into next
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/hci_sysfs.c | 44 | ||||
-rw-r--r-- | net/bluetooth/l2cap.c | 46 | ||||
-rw-r--r-- | net/bluetooth/rfcomm/core.c | 39 | ||||
-rw-r--r-- | net/bluetooth/rfcomm/sock.c | 36 | ||||
-rw-r--r-- | net/bluetooth/sco.c | 36 |
5 files changed, 138 insertions, 63 deletions
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index 1a79a6c7e30e..05fd125f74fe 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c | |||
@@ -3,12 +3,12 @@ | |||
3 | #include <linux/kernel.h> | 3 | #include <linux/kernel.h> |
4 | #include <linux/init.h> | 4 | #include <linux/init.h> |
5 | #include <linux/debugfs.h> | 5 | #include <linux/debugfs.h> |
6 | #include <linux/seq_file.h> | ||
6 | 7 | ||
7 | #include <net/bluetooth/bluetooth.h> | 8 | #include <net/bluetooth/bluetooth.h> |
8 | #include <net/bluetooth/hci_core.h> | 9 | #include <net/bluetooth/hci_core.h> |
9 | 10 | ||
10 | struct class *bt_class = NULL; | 11 | static struct class *bt_class; |
11 | EXPORT_SYMBOL_GPL(bt_class); | ||
12 | 12 | ||
13 | struct dentry *bt_debugfs = NULL; | 13 | struct dentry *bt_debugfs = NULL; |
14 | EXPORT_SYMBOL_GPL(bt_debugfs); | 14 | EXPORT_SYMBOL_GPL(bt_debugfs); |
@@ -405,20 +405,11 @@ static struct device_type bt_host = { | |||
405 | .release = bt_host_release, | 405 | .release = bt_host_release, |
406 | }; | 406 | }; |
407 | 407 | ||
408 | static int inquiry_cache_open(struct inode *inode, struct file *file) | 408 | static int inquiry_cache_show(struct seq_file *f, void *p) |
409 | { | ||
410 | file->private_data = inode->i_private; | ||
411 | return 0; | ||
412 | } | ||
413 | |||
414 | static ssize_t inquiry_cache_read(struct file *file, char __user *userbuf, | ||
415 | size_t count, loff_t *ppos) | ||
416 | { | 409 | { |
417 | struct hci_dev *hdev = file->private_data; | 410 | struct hci_dev *hdev = f->private; |
418 | struct inquiry_cache *cache = &hdev->inq_cache; | 411 | struct inquiry_cache *cache = &hdev->inq_cache; |
419 | struct inquiry_entry *e; | 412 | struct inquiry_entry *e; |
420 | char buf[4096]; | ||
421 | int n = 0; | ||
422 | 413 | ||
423 | hci_dev_lock_bh(hdev); | 414 | hci_dev_lock_bh(hdev); |
424 | 415 | ||
@@ -426,23 +417,30 @@ static ssize_t inquiry_cache_read(struct file *file, char __user *userbuf, | |||
426 | struct inquiry_data *data = &e->data; | 417 | struct inquiry_data *data = &e->data; |
427 | bdaddr_t bdaddr; | 418 | bdaddr_t bdaddr; |
428 | baswap(&bdaddr, &data->bdaddr); | 419 | baswap(&bdaddr, &data->bdaddr); |
429 | n += sprintf(buf + n, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n", | 420 | seq_printf(f, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n", |
430 | batostr(&bdaddr), | 421 | batostr(&bdaddr), |
431 | data->pscan_rep_mode, data->pscan_period_mode, | 422 | data->pscan_rep_mode, data->pscan_period_mode, |
432 | data->pscan_mode, data->dev_class[2], | 423 | data->pscan_mode, data->dev_class[2], |
433 | data->dev_class[1], data->dev_class[0], | 424 | data->dev_class[1], data->dev_class[0], |
434 | __le16_to_cpu(data->clock_offset), | 425 | __le16_to_cpu(data->clock_offset), |
435 | data->rssi, data->ssp_mode, e->timestamp); | 426 | data->rssi, data->ssp_mode, e->timestamp); |
436 | } | 427 | } |
437 | 428 | ||
438 | hci_dev_unlock_bh(hdev); | 429 | hci_dev_unlock_bh(hdev); |
439 | 430 | ||
440 | return simple_read_from_buffer(userbuf, count, ppos, buf, n); | 431 | return 0; |
432 | } | ||
433 | |||
434 | static int inquiry_cache_open(struct inode *inode, struct file *file) | ||
435 | { | ||
436 | return single_open(file, inquiry_cache_show, inode->i_private); | ||
441 | } | 437 | } |
442 | 438 | ||
443 | static const struct file_operations inquiry_cache_fops = { | 439 | static const struct file_operations inquiry_cache_fops = { |
444 | .open = inquiry_cache_open, | 440 | .open = inquiry_cache_open, |
445 | .read = inquiry_cache_read, | 441 | .read = seq_read, |
442 | .llseek = seq_lseek, | ||
443 | .release = single_release, | ||
446 | }; | 444 | }; |
447 | 445 | ||
448 | int hci_register_sysfs(struct hci_dev *hdev) | 446 | int hci_register_sysfs(struct hci_dev *hdev) |
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index 400efa26ddba..7794a2e2adce 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c | |||
@@ -40,6 +40,8 @@ | |||
40 | #include <linux/skbuff.h> | 40 | #include <linux/skbuff.h> |
41 | #include <linux/list.h> | 41 | #include <linux/list.h> |
42 | #include <linux/device.h> | 42 | #include <linux/device.h> |
43 | #include <linux/debugfs.h> | ||
44 | #include <linux/seq_file.h> | ||
43 | #include <linux/uaccess.h> | 45 | #include <linux/uaccess.h> |
44 | #include <linux/crc16.h> | 46 | #include <linux/crc16.h> |
45 | #include <net/sock.h> | 47 | #include <net/sock.h> |
@@ -2830,6 +2832,11 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
2830 | int len = cmd->len - sizeof(*rsp); | 2832 | int len = cmd->len - sizeof(*rsp); |
2831 | char req[64]; | 2833 | char req[64]; |
2832 | 2834 | ||
2835 | if (len > sizeof(req) - sizeof(struct l2cap_conf_req)) { | ||
2836 | l2cap_send_disconn_req(conn, sk); | ||
2837 | goto done; | ||
2838 | } | ||
2839 | |||
2833 | /* throw out any old stored conf requests */ | 2840 | /* throw out any old stored conf requests */ |
2834 | result = L2CAP_CONF_SUCCESS; | 2841 | result = L2CAP_CONF_SUCCESS; |
2835 | len = l2cap_parse_conf_rsp(sk, rsp->data, | 2842 | len = l2cap_parse_conf_rsp(sk, rsp->data, |
@@ -3937,29 +3944,42 @@ drop: | |||
3937 | return 0; | 3944 | return 0; |
3938 | } | 3945 | } |
3939 | 3946 | ||
3940 | static ssize_t l2cap_sysfs_show(struct class *dev, char *buf) | 3947 | static int l2cap_debugfs_show(struct seq_file *f, void *p) |
3941 | { | 3948 | { |
3942 | struct sock *sk; | 3949 | struct sock *sk; |
3943 | struct hlist_node *node; | 3950 | struct hlist_node *node; |
3944 | char *str = buf; | ||
3945 | 3951 | ||
3946 | read_lock_bh(&l2cap_sk_list.lock); | 3952 | read_lock_bh(&l2cap_sk_list.lock); |
3947 | 3953 | ||
3948 | sk_for_each(sk, node, &l2cap_sk_list.head) { | 3954 | sk_for_each(sk, node, &l2cap_sk_list.head) { |
3949 | struct l2cap_pinfo *pi = l2cap_pi(sk); | 3955 | struct l2cap_pinfo *pi = l2cap_pi(sk); |
3950 | 3956 | ||
3951 | str += sprintf(str, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d\n", | 3957 | seq_printf(f, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d\n", |
3952 | batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), | 3958 | batostr(&bt_sk(sk)->src), |
3953 | sk->sk_state, __le16_to_cpu(pi->psm), pi->scid, | 3959 | batostr(&bt_sk(sk)->dst), |
3954 | pi->dcid, pi->imtu, pi->omtu, pi->sec_level); | 3960 | sk->sk_state, __le16_to_cpu(pi->psm), |
3961 | pi->scid, pi->dcid, | ||
3962 | pi->imtu, pi->omtu, pi->sec_level); | ||
3955 | } | 3963 | } |
3956 | 3964 | ||
3957 | read_unlock_bh(&l2cap_sk_list.lock); | 3965 | read_unlock_bh(&l2cap_sk_list.lock); |
3958 | 3966 | ||
3959 | return str - buf; | 3967 | return 0; |
3960 | } | 3968 | } |
3961 | 3969 | ||
3962 | static CLASS_ATTR(l2cap, S_IRUGO, l2cap_sysfs_show, NULL); | 3970 | static int l2cap_debugfs_open(struct inode *inode, struct file *file) |
3971 | { | ||
3972 | return single_open(file, l2cap_debugfs_show, inode->i_private); | ||
3973 | } | ||
3974 | |||
3975 | static const struct file_operations l2cap_debugfs_fops = { | ||
3976 | .open = l2cap_debugfs_open, | ||
3977 | .read = seq_read, | ||
3978 | .llseek = seq_lseek, | ||
3979 | .release = single_release, | ||
3980 | }; | ||
3981 | |||
3982 | static struct dentry *l2cap_debugfs; | ||
3963 | 3983 | ||
3964 | static const struct proto_ops l2cap_sock_ops = { | 3984 | static const struct proto_ops l2cap_sock_ops = { |
3965 | .family = PF_BLUETOOTH, | 3985 | .family = PF_BLUETOOTH, |
@@ -4019,8 +4039,12 @@ static int __init l2cap_init(void) | |||
4019 | goto error; | 4039 | goto error; |
4020 | } | 4040 | } |
4021 | 4041 | ||
4022 | if (class_create_file(bt_class, &class_attr_l2cap) < 0) | 4042 | if (bt_debugfs) { |
4023 | BT_ERR("Failed to create L2CAP info file"); | 4043 | l2cap_debugfs = debugfs_create_file("l2cap", 0444, |
4044 | bt_debugfs, NULL, &l2cap_debugfs_fops); | ||
4045 | if (!l2cap_debugfs) | ||
4046 | BT_ERR("Failed to create L2CAP debug file"); | ||
4047 | } | ||
4024 | 4048 | ||
4025 | BT_INFO("L2CAP ver %s", VERSION); | 4049 | BT_INFO("L2CAP ver %s", VERSION); |
4026 | BT_INFO("L2CAP socket layer initialized"); | 4050 | BT_INFO("L2CAP socket layer initialized"); |
@@ -4034,7 +4058,7 @@ error: | |||
4034 | 4058 | ||
4035 | static void __exit l2cap_exit(void) | 4059 | static void __exit l2cap_exit(void) |
4036 | { | 4060 | { |
4037 | class_remove_file(bt_class, &class_attr_l2cap); | 4061 | debugfs_remove(l2cap_debugfs); |
4038 | 4062 | ||
4039 | if (bt_sock_unregister(BTPROTO_L2CAP) < 0) | 4063 | if (bt_sock_unregister(BTPROTO_L2CAP) < 0) |
4040 | BT_ERR("L2CAP socket unregistration failed"); | 4064 | BT_ERR("L2CAP socket unregistration failed"); |
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 89f4a59eb82b..13f114e8b0f9 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
@@ -33,6 +33,8 @@ | |||
33 | #include <linux/init.h> | 33 | #include <linux/init.h> |
34 | #include <linux/wait.h> | 34 | #include <linux/wait.h> |
35 | #include <linux/device.h> | 35 | #include <linux/device.h> |
36 | #include <linux/debugfs.h> | ||
37 | #include <linux/seq_file.h> | ||
36 | #include <linux/net.h> | 38 | #include <linux/net.h> |
37 | #include <linux/mutex.h> | 39 | #include <linux/mutex.h> |
38 | #include <linux/kthread.h> | 40 | #include <linux/kthread.h> |
@@ -2098,11 +2100,10 @@ static struct hci_cb rfcomm_cb = { | |||
2098 | .security_cfm = rfcomm_security_cfm | 2100 | .security_cfm = rfcomm_security_cfm |
2099 | }; | 2101 | }; |
2100 | 2102 | ||
2101 | static ssize_t rfcomm_dlc_sysfs_show(struct class *dev, char *buf) | 2103 | static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x) |
2102 | { | 2104 | { |
2103 | struct rfcomm_session *s; | 2105 | struct rfcomm_session *s; |
2104 | struct list_head *pp, *p; | 2106 | struct list_head *pp, *p; |
2105 | char *str = buf; | ||
2106 | 2107 | ||
2107 | rfcomm_lock(); | 2108 | rfcomm_lock(); |
2108 | 2109 | ||
@@ -2112,18 +2113,32 @@ static ssize_t rfcomm_dlc_sysfs_show(struct class *dev, char *buf) | |||
2112 | struct sock *sk = s->sock->sk; | 2113 | struct sock *sk = s->sock->sk; |
2113 | struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list); | 2114 | struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list); |
2114 | 2115 | ||
2115 | str += sprintf(str, "%s %s %ld %d %d %d %d\n", | 2116 | seq_printf(f, "%s %s %ld %d %d %d %d\n", |
2116 | batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), | 2117 | batostr(&bt_sk(sk)->src), |
2117 | d->state, d->dlci, d->mtu, d->rx_credits, d->tx_credits); | 2118 | batostr(&bt_sk(sk)->dst), |
2119 | d->state, d->dlci, d->mtu, | ||
2120 | d->rx_credits, d->tx_credits); | ||
2118 | } | 2121 | } |
2119 | } | 2122 | } |
2120 | 2123 | ||
2121 | rfcomm_unlock(); | 2124 | rfcomm_unlock(); |
2122 | 2125 | ||
2123 | return (str - buf); | 2126 | return 0; |
2124 | } | 2127 | } |
2125 | 2128 | ||
2126 | static CLASS_ATTR(rfcomm_dlc, S_IRUGO, rfcomm_dlc_sysfs_show, NULL); | 2129 | static int rfcomm_dlc_debugfs_open(struct inode *inode, struct file *file) |
2130 | { | ||
2131 | return single_open(file, rfcomm_dlc_debugfs_show, inode->i_private); | ||
2132 | } | ||
2133 | |||
2134 | static const struct file_operations rfcomm_dlc_debugfs_fops = { | ||
2135 | .open = rfcomm_dlc_debugfs_open, | ||
2136 | .read = seq_read, | ||
2137 | .llseek = seq_lseek, | ||
2138 | .release = single_release, | ||
2139 | }; | ||
2140 | |||
2141 | static struct dentry *rfcomm_dlc_debugfs; | ||
2127 | 2142 | ||
2128 | /* ---- Initialization ---- */ | 2143 | /* ---- Initialization ---- */ |
2129 | static int __init rfcomm_init(void) | 2144 | static int __init rfcomm_init(void) |
@@ -2140,8 +2155,12 @@ static int __init rfcomm_init(void) | |||
2140 | goto unregister; | 2155 | goto unregister; |
2141 | } | 2156 | } |
2142 | 2157 | ||
2143 | if (class_create_file(bt_class, &class_attr_rfcomm_dlc) < 0) | 2158 | if (bt_debugfs) { |
2144 | BT_ERR("Failed to create RFCOMM info file"); | 2159 | rfcomm_dlc_debugfs = debugfs_create_file("rfcomm_dlc", 0444, |
2160 | bt_debugfs, NULL, &rfcomm_dlc_debugfs_fops); | ||
2161 | if (!rfcomm_dlc_debugfs) | ||
2162 | BT_ERR("Failed to create RFCOMM debug file"); | ||
2163 | } | ||
2145 | 2164 | ||
2146 | err = rfcomm_init_ttys(); | 2165 | err = rfcomm_init_ttys(); |
2147 | if (err < 0) | 2166 | if (err < 0) |
@@ -2169,7 +2188,7 @@ unregister: | |||
2169 | 2188 | ||
2170 | static void __exit rfcomm_exit(void) | 2189 | static void __exit rfcomm_exit(void) |
2171 | { | 2190 | { |
2172 | class_remove_file(bt_class, &class_attr_rfcomm_dlc); | 2191 | debugfs_remove(rfcomm_dlc_debugfs); |
2173 | 2192 | ||
2174 | hci_unregister_cb(&rfcomm_cb); | 2193 | hci_unregister_cb(&rfcomm_cb); |
2175 | 2194 | ||
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index 4b5968dda673..7f439765403d 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c | |||
@@ -40,6 +40,8 @@ | |||
40 | #include <linux/skbuff.h> | 40 | #include <linux/skbuff.h> |
41 | #include <linux/list.h> | 41 | #include <linux/list.h> |
42 | #include <linux/device.h> | 42 | #include <linux/device.h> |
43 | #include <linux/debugfs.h> | ||
44 | #include <linux/seq_file.h> | ||
43 | #include <net/sock.h> | 45 | #include <net/sock.h> |
44 | 46 | ||
45 | #include <asm/system.h> | 47 | #include <asm/system.h> |
@@ -1061,26 +1063,38 @@ done: | |||
1061 | return result; | 1063 | return result; |
1062 | } | 1064 | } |
1063 | 1065 | ||
1064 | static ssize_t rfcomm_sock_sysfs_show(struct class *dev, char *buf) | 1066 | static int rfcomm_sock_debugfs_show(struct seq_file *f, void *p) |
1065 | { | 1067 | { |
1066 | struct sock *sk; | 1068 | struct sock *sk; |
1067 | struct hlist_node *node; | 1069 | struct hlist_node *node; |
1068 | char *str = buf; | ||
1069 | 1070 | ||
1070 | read_lock_bh(&rfcomm_sk_list.lock); | 1071 | read_lock_bh(&rfcomm_sk_list.lock); |
1071 | 1072 | ||
1072 | sk_for_each(sk, node, &rfcomm_sk_list.head) { | 1073 | sk_for_each(sk, node, &rfcomm_sk_list.head) { |
1073 | str += sprintf(str, "%s %s %d %d\n", | 1074 | seq_printf(f, "%s %s %d %d\n", |
1074 | batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), | 1075 | batostr(&bt_sk(sk)->src), |
1076 | batostr(&bt_sk(sk)->dst), | ||
1075 | sk->sk_state, rfcomm_pi(sk)->channel); | 1077 | sk->sk_state, rfcomm_pi(sk)->channel); |
1076 | } | 1078 | } |
1077 | 1079 | ||
1078 | read_unlock_bh(&rfcomm_sk_list.lock); | 1080 | read_unlock_bh(&rfcomm_sk_list.lock); |
1079 | 1081 | ||
1080 | return (str - buf); | 1082 | return 0; |
1081 | } | 1083 | } |
1082 | 1084 | ||
1083 | static CLASS_ATTR(rfcomm, S_IRUGO, rfcomm_sock_sysfs_show, NULL); | 1085 | static int rfcomm_sock_debugfs_open(struct inode *inode, struct file *file) |
1086 | { | ||
1087 | return single_open(file, rfcomm_sock_debugfs_show, inode->i_private); | ||
1088 | } | ||
1089 | |||
1090 | static const struct file_operations rfcomm_sock_debugfs_fops = { | ||
1091 | .open = rfcomm_sock_debugfs_open, | ||
1092 | .read = seq_read, | ||
1093 | .llseek = seq_lseek, | ||
1094 | .release = single_release, | ||
1095 | }; | ||
1096 | |||
1097 | static struct dentry *rfcomm_sock_debugfs; | ||
1084 | 1098 | ||
1085 | static const struct proto_ops rfcomm_sock_ops = { | 1099 | static const struct proto_ops rfcomm_sock_ops = { |
1086 | .family = PF_BLUETOOTH, | 1100 | .family = PF_BLUETOOTH, |
@@ -1120,8 +1134,12 @@ int __init rfcomm_init_sockets(void) | |||
1120 | if (err < 0) | 1134 | if (err < 0) |
1121 | goto error; | 1135 | goto error; |
1122 | 1136 | ||
1123 | if (class_create_file(bt_class, &class_attr_rfcomm) < 0) | 1137 | if (bt_debugfs) { |
1124 | BT_ERR("Failed to create RFCOMM info file"); | 1138 | rfcomm_sock_debugfs = debugfs_create_file("rfcomm", 0444, |
1139 | bt_debugfs, NULL, &rfcomm_sock_debugfs_fops); | ||
1140 | if (!rfcomm_sock_debugfs) | ||
1141 | BT_ERR("Failed to create RFCOMM debug file"); | ||
1142 | } | ||
1125 | 1143 | ||
1126 | BT_INFO("RFCOMM socket layer initialized"); | 1144 | BT_INFO("RFCOMM socket layer initialized"); |
1127 | 1145 | ||
@@ -1135,7 +1153,7 @@ error: | |||
1135 | 1153 | ||
1136 | void rfcomm_cleanup_sockets(void) | 1154 | void rfcomm_cleanup_sockets(void) |
1137 | { | 1155 | { |
1138 | class_remove_file(bt_class, &class_attr_rfcomm); | 1156 | debugfs_remove(rfcomm_sock_debugfs); |
1139 | 1157 | ||
1140 | if (bt_sock_unregister(BTPROTO_RFCOMM) < 0) | 1158 | if (bt_sock_unregister(BTPROTO_RFCOMM) < 0) |
1141 | BT_ERR("RFCOMM socket layer unregistration failed"); | 1159 | BT_ERR("RFCOMM socket layer unregistration failed"); |
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index dd8f6ec57dce..e5b16b76b22e 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c | |||
@@ -38,6 +38,8 @@ | |||
38 | #include <linux/socket.h> | 38 | #include <linux/socket.h> |
39 | #include <linux/skbuff.h> | 39 | #include <linux/skbuff.h> |
40 | #include <linux/device.h> | 40 | #include <linux/device.h> |
41 | #include <linux/debugfs.h> | ||
42 | #include <linux/seq_file.h> | ||
41 | #include <linux/list.h> | 43 | #include <linux/list.h> |
42 | #include <net/sock.h> | 44 | #include <net/sock.h> |
43 | 45 | ||
@@ -953,26 +955,36 @@ drop: | |||
953 | return 0; | 955 | return 0; |
954 | } | 956 | } |
955 | 957 | ||
956 | static ssize_t sco_sysfs_show(struct class *dev, char *buf) | 958 | static int sco_debugfs_show(struct seq_file *f, void *p) |
957 | { | 959 | { |
958 | struct sock *sk; | 960 | struct sock *sk; |
959 | struct hlist_node *node; | 961 | struct hlist_node *node; |
960 | char *str = buf; | ||
961 | 962 | ||
962 | read_lock_bh(&sco_sk_list.lock); | 963 | read_lock_bh(&sco_sk_list.lock); |
963 | 964 | ||
964 | sk_for_each(sk, node, &sco_sk_list.head) { | 965 | sk_for_each(sk, node, &sco_sk_list.head) { |
965 | str += sprintf(str, "%s %s %d\n", | 966 | seq_printf(f, "%s %s %d\n", batostr(&bt_sk(sk)->src), |
966 | batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), | 967 | batostr(&bt_sk(sk)->dst), sk->sk_state); |
967 | sk->sk_state); | ||
968 | } | 968 | } |
969 | 969 | ||
970 | read_unlock_bh(&sco_sk_list.lock); | 970 | read_unlock_bh(&sco_sk_list.lock); |
971 | 971 | ||
972 | return (str - buf); | 972 | return 0; |
973 | } | 973 | } |
974 | 974 | ||
975 | static CLASS_ATTR(sco, S_IRUGO, sco_sysfs_show, NULL); | 975 | static int sco_debugfs_open(struct inode *inode, struct file *file) |
976 | { | ||
977 | return single_open(file, sco_debugfs_show, inode->i_private); | ||
978 | } | ||
979 | |||
980 | static const struct file_operations sco_debugfs_fops = { | ||
981 | .open = sco_debugfs_open, | ||
982 | .read = seq_read, | ||
983 | .llseek = seq_lseek, | ||
984 | .release = single_release, | ||
985 | }; | ||
986 | |||
987 | static struct dentry *sco_debugfs; | ||
976 | 988 | ||
977 | static const struct proto_ops sco_sock_ops = { | 989 | static const struct proto_ops sco_sock_ops = { |
978 | .family = PF_BLUETOOTH, | 990 | .family = PF_BLUETOOTH, |
@@ -1030,8 +1042,12 @@ static int __init sco_init(void) | |||
1030 | goto error; | 1042 | goto error; |
1031 | } | 1043 | } |
1032 | 1044 | ||
1033 | if (class_create_file(bt_class, &class_attr_sco) < 0) | 1045 | if (bt_debugfs) { |
1034 | BT_ERR("Failed to create SCO info file"); | 1046 | sco_debugfs = debugfs_create_file("sco", 0444, |
1047 | bt_debugfs, NULL, &sco_debugfs_fops); | ||
1048 | if (!sco_debugfs) | ||
1049 | BT_ERR("Failed to create SCO debug file"); | ||
1050 | } | ||
1035 | 1051 | ||
1036 | BT_INFO("SCO (Voice Link) ver %s", VERSION); | 1052 | BT_INFO("SCO (Voice Link) ver %s", VERSION); |
1037 | BT_INFO("SCO socket layer initialized"); | 1053 | BT_INFO("SCO socket layer initialized"); |
@@ -1045,7 +1061,7 @@ error: | |||
1045 | 1061 | ||
1046 | static void __exit sco_exit(void) | 1062 | static void __exit sco_exit(void) |
1047 | { | 1063 | { |
1048 | class_remove_file(bt_class, &class_attr_sco); | 1064 | debugfs_remove(sco_debugfs); |
1049 | 1065 | ||
1050 | if (bt_sock_unregister(BTPROTO_SCO) < 0) | 1066 | if (bt_sock_unregister(BTPROTO_SCO) < 0) |
1051 | BT_ERR("SCO socket unregistration failed"); | 1067 | BT_ERR("SCO socket unregistration failed"); |