diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2013-10-19 10:09:11 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2013-10-19 11:56:52 -0400 |
commit | 06f5b7785af6beebb7b2a452687b5a102c90ca6e (patch) | |
tree | 33945c97ce1f48736cb71925bb60993e2a54f70c /net/bluetooth/hci_core.c | |
parent | 3497ac84bd35bc5b984a3a20625021bfb0ca3f37 (diff) |
Bluetooth: Add support for setting SSP debug mode
Enabling and disabling SSP debug mode is useful for development. This
adds a debugfs entry that allows to configure the SSP debug mode.
On purpose this has been implemented as debugfs entry and not a public
API since it is really only useful during testing and development.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth/hci_core.c')
-rw-r--r-- | net/bluetooth/hci_core.c | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 384b9db16f69..2a9e92503fd6 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -303,6 +303,55 @@ static int auto_accept_delay_get(void *data, u64 *val) | |||
303 | DEFINE_SIMPLE_ATTRIBUTE(auto_accept_delay_fops, auto_accept_delay_get, | 303 | DEFINE_SIMPLE_ATTRIBUTE(auto_accept_delay_fops, auto_accept_delay_get, |
304 | auto_accept_delay_set, "%llu\n"); | 304 | auto_accept_delay_set, "%llu\n"); |
305 | 305 | ||
306 | static int ssp_debug_mode_set(void *data, u64 val) | ||
307 | { | ||
308 | struct hci_dev *hdev = data; | ||
309 | struct sk_buff *skb; | ||
310 | __u8 mode; | ||
311 | int err; | ||
312 | |||
313 | if (val != 0 && val != 1) | ||
314 | return -EINVAL; | ||
315 | |||
316 | if (!test_bit(HCI_UP, &hdev->flags)) | ||
317 | return -ENETDOWN; | ||
318 | |||
319 | hci_req_lock(hdev); | ||
320 | mode = val; | ||
321 | skb = __hci_cmd_sync(hdev, HCI_OP_WRITE_SSP_DEBUG_MODE, sizeof(mode), | ||
322 | &mode, HCI_CMD_TIMEOUT); | ||
323 | hci_req_unlock(hdev); | ||
324 | |||
325 | if (IS_ERR(skb)) | ||
326 | return PTR_ERR(skb); | ||
327 | |||
328 | err = -bt_to_errno(skb->data[0]); | ||
329 | kfree_skb(skb); | ||
330 | |||
331 | if (err < 0) | ||
332 | return err; | ||
333 | |||
334 | hci_dev_lock(hdev); | ||
335 | hdev->ssp_debug_mode = val; | ||
336 | hci_dev_unlock(hdev); | ||
337 | |||
338 | return 0; | ||
339 | } | ||
340 | |||
341 | static int ssp_debug_mode_get(void *data, u64 *val) | ||
342 | { | ||
343 | struct hci_dev *hdev = data; | ||
344 | |||
345 | hci_dev_lock(hdev); | ||
346 | *val = hdev->ssp_debug_mode; | ||
347 | hci_dev_unlock(hdev); | ||
348 | |||
349 | return 0; | ||
350 | } | ||
351 | |||
352 | DEFINE_SIMPLE_ATTRIBUTE(ssp_debug_mode_fops, ssp_debug_mode_get, | ||
353 | ssp_debug_mode_set, "%llu\n"); | ||
354 | |||
306 | static int idle_timeout_set(void *data, u64 val) | 355 | static int idle_timeout_set(void *data, u64 val) |
307 | { | 356 | { |
308 | struct hci_dev *hdev = data; | 357 | struct hci_dev *hdev = data; |
@@ -1199,9 +1248,12 @@ static int __hci_init(struct hci_dev *hdev) | |||
1199 | hdev, &voice_setting_fops); | 1248 | hdev, &voice_setting_fops); |
1200 | } | 1249 | } |
1201 | 1250 | ||
1202 | if (lmp_ssp_capable(hdev)) | 1251 | if (lmp_ssp_capable(hdev)) { |
1203 | debugfs_create_file("auto_accept_delay", 0644, hdev->debugfs, | 1252 | debugfs_create_file("auto_accept_delay", 0644, hdev->debugfs, |
1204 | hdev, &auto_accept_delay_fops); | 1253 | hdev, &auto_accept_delay_fops); |
1254 | debugfs_create_file("ssp_debug_mode", 0644, hdev->debugfs, | ||
1255 | hdev, &ssp_debug_mode_fops); | ||
1256 | } | ||
1205 | 1257 | ||
1206 | if (lmp_sniff_capable(hdev)) { | 1258 | if (lmp_sniff_capable(hdev)) { |
1207 | debugfs_create_file("idle_timeout", 0644, hdev->debugfs, | 1259 | debugfs_create_file("idle_timeout", 0644, hdev->debugfs, |