diff options
| author | Johan Hedberg <johan.hedberg@intel.com> | 2014-10-16 04:45:31 -0400 |
|---|---|---|
| committer | Marcel Holtmann <marcel@holtmann.org> | 2014-12-03 10:51:20 -0500 |
| commit | 858cdc78be8be19b7176cafe06d3db3acfb345d4 (patch) | |
| tree | 938062d0fa29a9d7b07831b50011661cdc59af3a | |
| parent | fe8bc5ac67a36b05c4ec91643736d44373096a76 (diff) | |
Bluetooth: Add debugfs switch for forcing SMP over BR/EDR
To make it possible to use LE SC functionality over BR/EDR with pre-4.1
controllers (that do not support BR/EDR SC links) it's useful to be able
to force LE SC operations even over a traditional SSP protected link.
This patch adds a debugfs switch to force a special debug flag which is
used to skip the checks for BR/EDR SC support.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
| -rw-r--r-- | include/net/bluetooth/hci.h | 1 | ||||
| -rw-r--r-- | net/bluetooth/hci_core.c | 47 |
2 files changed, 48 insertions, 0 deletions
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index e56f9099f8e3..569c077778b6 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h | |||
| @@ -163,6 +163,7 @@ enum { | |||
| 163 | enum { | 163 | enum { |
| 164 | HCI_DUT_MODE, | 164 | HCI_DUT_MODE, |
| 165 | HCI_FORCE_SC, | 165 | HCI_FORCE_SC, |
| 166 | HCI_FORCE_LESC, | ||
| 166 | HCI_FORCE_STATIC_ADDR, | 167 | HCI_FORCE_STATIC_ADDR, |
| 167 | }; | 168 | }; |
| 168 | 169 | ||
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 2fa9f2b2bee3..581e13e9dc32 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
| @@ -406,6 +406,49 @@ static const struct file_operations force_sc_support_fops = { | |||
| 406 | .llseek = default_llseek, | 406 | .llseek = default_llseek, |
| 407 | }; | 407 | }; |
| 408 | 408 | ||
| 409 | static ssize_t force_lesc_support_read(struct file *file, char __user *user_buf, | ||
| 410 | size_t count, loff_t *ppos) | ||
| 411 | { | ||
| 412 | struct hci_dev *hdev = file->private_data; | ||
| 413 | char buf[3]; | ||
| 414 | |||
| 415 | buf[0] = test_bit(HCI_FORCE_LESC, &hdev->dbg_flags) ? 'Y': 'N'; | ||
| 416 | buf[1] = '\n'; | ||
| 417 | buf[2] = '\0'; | ||
| 418 | return simple_read_from_buffer(user_buf, count, ppos, buf, 2); | ||
| 419 | } | ||
| 420 | |||
| 421 | static ssize_t force_lesc_support_write(struct file *file, | ||
| 422 | const char __user *user_buf, | ||
| 423 | size_t count, loff_t *ppos) | ||
| 424 | { | ||
| 425 | struct hci_dev *hdev = file->private_data; | ||
| 426 | char buf[32]; | ||
| 427 | size_t buf_size = min(count, (sizeof(buf)-1)); | ||
| 428 | bool enable; | ||
| 429 | |||
| 430 | if (copy_from_user(buf, user_buf, buf_size)) | ||
| 431 | return -EFAULT; | ||
| 432 | |||
| 433 | buf[buf_size] = '\0'; | ||
| 434 | if (strtobool(buf, &enable)) | ||
| 435 | return -EINVAL; | ||
| 436 | |||
| 437 | if (enable == test_bit(HCI_FORCE_LESC, &hdev->dbg_flags)) | ||
| 438 | return -EALREADY; | ||
| 439 | |||
| 440 | change_bit(HCI_FORCE_LESC, &hdev->dbg_flags); | ||
| 441 | |||
| 442 | return count; | ||
| 443 | } | ||
| 444 | |||
| 445 | static const struct file_operations force_lesc_support_fops = { | ||
| 446 | .open = simple_open, | ||
| 447 | .read = force_lesc_support_read, | ||
| 448 | .write = force_lesc_support_write, | ||
| 449 | .llseek = default_llseek, | ||
| 450 | }; | ||
| 451 | |||
| 409 | static ssize_t sc_only_mode_read(struct file *file, char __user *user_buf, | 452 | static ssize_t sc_only_mode_read(struct file *file, char __user *user_buf, |
| 410 | size_t count, loff_t *ppos) | 453 | size_t count, loff_t *ppos) |
| 411 | { | 454 | { |
| @@ -1817,6 +1860,10 @@ static int __hci_init(struct hci_dev *hdev) | |||
| 1817 | hdev, &force_sc_support_fops); | 1860 | hdev, &force_sc_support_fops); |
| 1818 | debugfs_create_file("sc_only_mode", 0444, hdev->debugfs, | 1861 | debugfs_create_file("sc_only_mode", 0444, hdev->debugfs, |
| 1819 | hdev, &sc_only_mode_fops); | 1862 | hdev, &sc_only_mode_fops); |
| 1863 | if (lmp_le_capable(hdev)) | ||
| 1864 | debugfs_create_file("force_lesc_support", 0644, | ||
| 1865 | hdev->debugfs, hdev, | ||
| 1866 | &force_lesc_support_fops); | ||
| 1820 | } | 1867 | } |
| 1821 | 1868 | ||
| 1822 | if (lmp_sniff_capable(hdev)) { | 1869 | if (lmp_sniff_capable(hdev)) { |
