diff options
author | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2015-01-08 10:00:55 -0500 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2015-01-14 16:48:13 -0500 |
commit | 7b2ed60ed43ac7348dec33e789d1481891537841 (patch) | |
tree | 93f4b2216cd607cec4a424c6e60be5a7d0fd967a /net/bluetooth/6lowpan.c | |
parent | e12af489b91d47a806f4e96e4edc20df612482e7 (diff) |
Bluetooth: 6lowpan: Remove PSM setting code
Removing PSM setting debugfs interface as the IPSP has a well
defined PSM value that should be used.
The patch introduces enable flag that can be used to toggle
6lowpan on/off.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/6lowpan.c')
-rw-r--r-- | net/bluetooth/6lowpan.c | 66 |
1 files changed, 31 insertions, 35 deletions
diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index c989253737f0..1742b849fcff 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c | |||
@@ -31,7 +31,7 @@ | |||
31 | 31 | ||
32 | #define VERSION "0.1" | 32 | #define VERSION "0.1" |
33 | 33 | ||
34 | static struct dentry *lowpan_psm_debugfs; | 34 | static struct dentry *lowpan_enable_debugfs; |
35 | static struct dentry *lowpan_control_debugfs; | 35 | static struct dentry *lowpan_control_debugfs; |
36 | 36 | ||
37 | #define IFACE_NAME_TEMPLATE "bt%d" | 37 | #define IFACE_NAME_TEMPLATE "bt%d" |
@@ -55,11 +55,7 @@ struct skb_cb { | |||
55 | static LIST_HEAD(bt_6lowpan_devices); | 55 | static LIST_HEAD(bt_6lowpan_devices); |
56 | static DEFINE_SPINLOCK(devices_lock); | 56 | static DEFINE_SPINLOCK(devices_lock); |
57 | 57 | ||
58 | /* If psm is set to 0 (default value), then 6lowpan is disabled. | 58 | static bool enable_6lowpan; |
59 | * Other values are used to indicate a Protocol Service Multiplexer | ||
60 | * value for 6lowpan. | ||
61 | */ | ||
62 | static u16 psm_6lowpan; | ||
63 | 59 | ||
64 | /* We are listening incoming connections via this channel | 60 | /* We are listening incoming connections via this channel |
65 | */ | 61 | */ |
@@ -761,7 +757,7 @@ static bool is_bt_6lowpan(struct hci_conn *hcon) | |||
761 | if (hcon->type != LE_LINK) | 757 | if (hcon->type != LE_LINK) |
762 | return false; | 758 | return false; |
763 | 759 | ||
764 | if (!psm_6lowpan) | 760 | if (!enable_6lowpan) |
765 | return false; | 761 | return false; |
766 | 762 | ||
767 | return true; | 763 | return true; |
@@ -1085,7 +1081,7 @@ static int bt_6lowpan_connect(bdaddr_t *addr, u8 dst_type) | |||
1085 | if (!pchan) | 1081 | if (!pchan) |
1086 | return -EINVAL; | 1082 | return -EINVAL; |
1087 | 1083 | ||
1088 | err = l2cap_chan_connect(pchan, cpu_to_le16(psm_6lowpan), 0, | 1084 | err = l2cap_chan_connect(pchan, cpu_to_le16(L2CAP_PSM_IPSP), 0, |
1089 | addr, dst_type); | 1085 | addr, dst_type); |
1090 | 1086 | ||
1091 | BT_DBG("chan %p err %d", pchan, err); | 1087 | BT_DBG("chan %p err %d", pchan, err); |
@@ -1118,7 +1114,7 @@ static struct l2cap_chan *bt_6lowpan_listen(void) | |||
1118 | struct l2cap_chan *pchan; | 1114 | struct l2cap_chan *pchan; |
1119 | int err; | 1115 | int err; |
1120 | 1116 | ||
1121 | if (psm_6lowpan == 0) | 1117 | if (!enable_6lowpan) |
1122 | return NULL; | 1118 | return NULL; |
1123 | 1119 | ||
1124 | pchan = chan_get(); | 1120 | pchan = chan_get(); |
@@ -1130,10 +1126,9 @@ static struct l2cap_chan *bt_6lowpan_listen(void) | |||
1130 | 1126 | ||
1131 | atomic_set(&pchan->nesting, L2CAP_NESTING_PARENT); | 1127 | atomic_set(&pchan->nesting, L2CAP_NESTING_PARENT); |
1132 | 1128 | ||
1133 | BT_DBG("psm 0x%04x chan %p src type %d", psm_6lowpan, pchan, | 1129 | BT_DBG("chan %p src type %d", pchan, pchan->src_type); |
1134 | pchan->src_type); | ||
1135 | 1130 | ||
1136 | err = l2cap_add_psm(pchan, addr, cpu_to_le16(psm_6lowpan)); | 1131 | err = l2cap_add_psm(pchan, addr, cpu_to_le16(L2CAP_PSM_IPSP)); |
1137 | if (err) { | 1132 | if (err) { |
1138 | l2cap_chan_put(pchan); | 1133 | l2cap_chan_put(pchan); |
1139 | BT_ERR("psm cannot be added err %d", err); | 1134 | BT_ERR("psm cannot be added err %d", err); |
@@ -1219,22 +1214,23 @@ static void disconnect_all_peers(void) | |||
1219 | spin_unlock(&devices_lock); | 1214 | spin_unlock(&devices_lock); |
1220 | } | 1215 | } |
1221 | 1216 | ||
1222 | struct set_psm { | 1217 | struct set_enable { |
1223 | struct work_struct work; | 1218 | struct work_struct work; |
1224 | u16 psm; | 1219 | bool flag; |
1225 | }; | 1220 | }; |
1226 | 1221 | ||
1227 | static void do_psm_set(struct work_struct *work) | 1222 | static void do_enable_set(struct work_struct *work) |
1228 | { | 1223 | { |
1229 | struct set_psm *set_psm = container_of(work, struct set_psm, work); | 1224 | struct set_enable *set_enable = container_of(work, |
1225 | struct set_enable, work); | ||
1230 | 1226 | ||
1231 | if (set_psm->psm == 0 || psm_6lowpan != set_psm->psm) | 1227 | if (!set_enable->flag || enable_6lowpan != set_enable->flag) |
1232 | /* Disconnect existing connections if 6lowpan is | 1228 | /* Disconnect existing connections if 6lowpan is |
1233 | * disabled (psm = 0), or if psm changes. | 1229 | * disabled |
1234 | */ | 1230 | */ |
1235 | disconnect_all_peers(); | 1231 | disconnect_all_peers(); |
1236 | 1232 | ||
1237 | psm_6lowpan = set_psm->psm; | 1233 | enable_6lowpan = set_enable->flag; |
1238 | 1234 | ||
1239 | if (listen_chan) { | 1235 | if (listen_chan) { |
1240 | l2cap_chan_close(listen_chan, 0); | 1236 | l2cap_chan_close(listen_chan, 0); |
@@ -1243,33 +1239,33 @@ static void do_psm_set(struct work_struct *work) | |||
1243 | 1239 | ||
1244 | listen_chan = bt_6lowpan_listen(); | 1240 | listen_chan = bt_6lowpan_listen(); |
1245 | 1241 | ||
1246 | kfree(set_psm); | 1242 | kfree(set_enable); |
1247 | } | 1243 | } |
1248 | 1244 | ||
1249 | static int lowpan_psm_set(void *data, u64 val) | 1245 | static int lowpan_enable_set(void *data, u64 val) |
1250 | { | 1246 | { |
1251 | struct set_psm *set_psm; | 1247 | struct set_enable *set_enable; |
1252 | 1248 | ||
1253 | set_psm = kzalloc(sizeof(*set_psm), GFP_KERNEL); | 1249 | set_enable = kzalloc(sizeof(*set_enable), GFP_KERNEL); |
1254 | if (!set_psm) | 1250 | if (!set_enable) |
1255 | return -ENOMEM; | 1251 | return -ENOMEM; |
1256 | 1252 | ||
1257 | set_psm->psm = val; | 1253 | set_enable->flag = !!val; |
1258 | INIT_WORK(&set_psm->work, do_psm_set); | 1254 | INIT_WORK(&set_enable->work, do_enable_set); |
1259 | 1255 | ||
1260 | schedule_work(&set_psm->work); | 1256 | schedule_work(&set_enable->work); |
1261 | 1257 | ||
1262 | return 0; | 1258 | return 0; |
1263 | } | 1259 | } |
1264 | 1260 | ||
1265 | static int lowpan_psm_get(void *data, u64 *val) | 1261 | static int lowpan_enable_get(void *data, u64 *val) |
1266 | { | 1262 | { |
1267 | *val = psm_6lowpan; | 1263 | *val = enable_6lowpan; |
1268 | return 0; | 1264 | return 0; |
1269 | } | 1265 | } |
1270 | 1266 | ||
1271 | DEFINE_SIMPLE_ATTRIBUTE(lowpan_psm_fops, lowpan_psm_get, | 1267 | DEFINE_SIMPLE_ATTRIBUTE(lowpan_enable_fops, lowpan_enable_get, |
1272 | lowpan_psm_set, "%llu\n"); | 1268 | lowpan_enable_set, "%llu\n"); |
1273 | 1269 | ||
1274 | static ssize_t lowpan_control_write(struct file *fp, | 1270 | static ssize_t lowpan_control_write(struct file *fp, |
1275 | const char __user *user_buffer, | 1271 | const char __user *user_buffer, |
@@ -1439,9 +1435,9 @@ static struct notifier_block bt_6lowpan_dev_notifier = { | |||
1439 | 1435 | ||
1440 | static int __init bt_6lowpan_init(void) | 1436 | static int __init bt_6lowpan_init(void) |
1441 | { | 1437 | { |
1442 | lowpan_psm_debugfs = debugfs_create_file("6lowpan_psm", 0644, | 1438 | lowpan_enable_debugfs = debugfs_create_file("6lowpan_enable", 0644, |
1443 | bt_debugfs, NULL, | 1439 | bt_debugfs, NULL, |
1444 | &lowpan_psm_fops); | 1440 | &lowpan_enable_fops); |
1445 | lowpan_control_debugfs = debugfs_create_file("6lowpan_control", 0644, | 1441 | lowpan_control_debugfs = debugfs_create_file("6lowpan_control", 0644, |
1446 | bt_debugfs, NULL, | 1442 | bt_debugfs, NULL, |
1447 | &lowpan_control_fops); | 1443 | &lowpan_control_fops); |
@@ -1451,7 +1447,7 @@ static int __init bt_6lowpan_init(void) | |||
1451 | 1447 | ||
1452 | static void __exit bt_6lowpan_exit(void) | 1448 | static void __exit bt_6lowpan_exit(void) |
1453 | { | 1449 | { |
1454 | debugfs_remove(lowpan_psm_debugfs); | 1450 | debugfs_remove(lowpan_enable_debugfs); |
1455 | debugfs_remove(lowpan_control_debugfs); | 1451 | debugfs_remove(lowpan_control_debugfs); |
1456 | 1452 | ||
1457 | if (listen_chan) { | 1453 | if (listen_chan) { |