Commit 111902f7 authored by Marcel Holtmann's avatar Marcel Holtmann

Bluetooth: Use separate dbg_flags to special debugfs options

All the special settings configured via debugfs are either developer
only options or temporary solutions. To not clutter the standard flags,
move them to their own dbg_flags entry.
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
parent d97c9fb0
...@@ -104,6 +104,15 @@ enum { ...@@ -104,6 +104,15 @@ enum {
HCI_RESET, HCI_RESET,
}; };
/* BR/EDR and/or LE controller flags: the flags defined here should represent
* states configured via debugfs for debugging and testing purposes only.
*/
enum {
HCI_DUT_MODE,
HCI_FORCE_SC,
HCI_FORCE_STATIC_ADDR,
};
/* /*
* BR/EDR and/or LE controller flags: the flags defined here should represent * BR/EDR and/or LE controller flags: the flags defined here should represent
* states from the controller. * states from the controller.
...@@ -116,9 +125,6 @@ enum { ...@@ -116,9 +125,6 @@ enum {
HCI_PAIRABLE, HCI_PAIRABLE,
HCI_SERVICE_CACHE, HCI_SERVICE_CACHE,
HCI_DEBUG_KEYS, HCI_DEBUG_KEYS,
HCI_DUT_MODE,
HCI_FORCE_SC,
HCI_FORCE_STATIC_ADDR,
HCI_UNREGISTER, HCI_UNREGISTER,
HCI_USER_CHANNEL, HCI_USER_CHANNEL,
......
...@@ -318,6 +318,7 @@ struct hci_dev { ...@@ -318,6 +318,7 @@ struct hci_dev {
struct rfkill *rfkill; struct rfkill *rfkill;
unsigned long dbg_flags;
unsigned long dev_flags; unsigned long dev_flags;
struct delayed_work le_scan_disable; struct delayed_work le_scan_disable;
......
...@@ -68,7 +68,7 @@ static ssize_t dut_mode_read(struct file *file, char __user *user_buf, ...@@ -68,7 +68,7 @@ static ssize_t dut_mode_read(struct file *file, char __user *user_buf,
struct hci_dev *hdev = file->private_data; struct hci_dev *hdev = file->private_data;
char buf[3]; char buf[3];
buf[0] = test_bit(HCI_DUT_MODE, &hdev->dev_flags) ? 'Y': 'N'; buf[0] = test_bit(HCI_DUT_MODE, &hdev->dbg_flags) ? 'Y': 'N';
buf[1] = '\n'; buf[1] = '\n';
buf[2] = '\0'; buf[2] = '\0';
return simple_read_from_buffer(user_buf, count, ppos, buf, 2); return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
...@@ -94,7 +94,7 @@ static ssize_t dut_mode_write(struct file *file, const char __user *user_buf, ...@@ -94,7 +94,7 @@ static ssize_t dut_mode_write(struct file *file, const char __user *user_buf,
if (strtobool(buf, &enable)) if (strtobool(buf, &enable))
return -EINVAL; return -EINVAL;
if (enable == test_bit(HCI_DUT_MODE, &hdev->dev_flags)) if (enable == test_bit(HCI_DUT_MODE, &hdev->dbg_flags))
return -EALREADY; return -EALREADY;
hci_req_lock(hdev); hci_req_lock(hdev);
...@@ -115,7 +115,7 @@ static ssize_t dut_mode_write(struct file *file, const char __user *user_buf, ...@@ -115,7 +115,7 @@ static ssize_t dut_mode_write(struct file *file, const char __user *user_buf,
if (err < 0) if (err < 0)
return err; return err;
change_bit(HCI_DUT_MODE, &hdev->dev_flags); change_bit(HCI_DUT_MODE, &hdev->dbg_flags);
return count; return count;
} }
...@@ -407,7 +407,7 @@ static ssize_t force_sc_support_read(struct file *file, char __user *user_buf, ...@@ -407,7 +407,7 @@ static ssize_t force_sc_support_read(struct file *file, char __user *user_buf,
struct hci_dev *hdev = file->private_data; struct hci_dev *hdev = file->private_data;
char buf[3]; char buf[3];
buf[0] = test_bit(HCI_FORCE_SC, &hdev->dev_flags) ? 'Y': 'N'; buf[0] = test_bit(HCI_FORCE_SC, &hdev->dbg_flags) ? 'Y': 'N';
buf[1] = '\n'; buf[1] = '\n';
buf[2] = '\0'; buf[2] = '\0';
return simple_read_from_buffer(user_buf, count, ppos, buf, 2); return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
...@@ -432,10 +432,10 @@ static ssize_t force_sc_support_write(struct file *file, ...@@ -432,10 +432,10 @@ static ssize_t force_sc_support_write(struct file *file,
if (strtobool(buf, &enable)) if (strtobool(buf, &enable))
return -EINVAL; return -EINVAL;
if (enable == test_bit(HCI_FORCE_SC, &hdev->dev_flags)) if (enable == test_bit(HCI_FORCE_SC, &hdev->dbg_flags))
return -EALREADY; return -EALREADY;
change_bit(HCI_FORCE_SC, &hdev->dev_flags); change_bit(HCI_FORCE_SC, &hdev->dbg_flags);
return count; return count;
} }
...@@ -719,7 +719,7 @@ static ssize_t force_static_address_read(struct file *file, ...@@ -719,7 +719,7 @@ static ssize_t force_static_address_read(struct file *file,
struct hci_dev *hdev = file->private_data; struct hci_dev *hdev = file->private_data;
char buf[3]; char buf[3];
buf[0] = test_bit(HCI_FORCE_STATIC_ADDR, &hdev->dev_flags) ? 'Y': 'N'; buf[0] = test_bit(HCI_FORCE_STATIC_ADDR, &hdev->dbg_flags) ? 'Y': 'N';
buf[1] = '\n'; buf[1] = '\n';
buf[2] = '\0'; buf[2] = '\0';
return simple_read_from_buffer(user_buf, count, ppos, buf, 2); return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
...@@ -744,10 +744,10 @@ static ssize_t force_static_address_write(struct file *file, ...@@ -744,10 +744,10 @@ static ssize_t force_static_address_write(struct file *file,
if (strtobool(buf, &enable)) if (strtobool(buf, &enable))
return -EINVAL; return -EINVAL;
if (enable == test_bit(HCI_FORCE_STATIC_ADDR, &hdev->dev_flags)) if (enable == test_bit(HCI_FORCE_STATIC_ADDR, &hdev->dbg_flags))
return -EALREADY; return -EALREADY;
change_bit(HCI_FORCE_STATIC_ADDR, &hdev->dev_flags); change_bit(HCI_FORCE_STATIC_ADDR, &hdev->dbg_flags);
return count; return count;
} }
...@@ -1752,7 +1752,7 @@ static void hci_init4_req(struct hci_request *req, unsigned long opt) ...@@ -1752,7 +1752,7 @@ static void hci_init4_req(struct hci_request *req, unsigned long opt)
/* Enable Secure Connections if supported and configured */ /* Enable Secure Connections if supported and configured */
if ((lmp_sc_capable(hdev) || if ((lmp_sc_capable(hdev) ||
test_bit(HCI_FORCE_SC, &hdev->dev_flags)) && test_bit(HCI_FORCE_SC, &hdev->dbg_flags)) &&
test_bit(HCI_SC_ENABLED, &hdev->dev_flags)) { test_bit(HCI_SC_ENABLED, &hdev->dev_flags)) {
u8 support = 0x01; u8 support = 0x01;
hci_req_add(req, HCI_OP_WRITE_SC_SUPPORT, hci_req_add(req, HCI_OP_WRITE_SC_SUPPORT,
...@@ -3782,7 +3782,7 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy, ...@@ -3782,7 +3782,7 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy,
* the HCI command if the current random address is already the * the HCI command if the current random address is already the
* static one. * static one.
*/ */
if (test_bit(HCI_FORCE_STATIC_ADDR, &hdev->dev_flags) || if (test_bit(HCI_FORCE_STATIC_ADDR, &hdev->dbg_flags) ||
!bacmp(&hdev->bdaddr, BDADDR_ANY)) { !bacmp(&hdev->bdaddr, BDADDR_ANY)) {
*own_addr_type = ADDR_LE_DEV_RANDOM; *own_addr_type = ADDR_LE_DEV_RANDOM;
if (bacmp(&hdev->static_addr, &hdev->random_addr)) if (bacmp(&hdev->static_addr, &hdev->random_addr))
...@@ -3811,7 +3811,7 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy, ...@@ -3811,7 +3811,7 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy,
void hci_copy_identity_address(struct hci_dev *hdev, bdaddr_t *bdaddr, void hci_copy_identity_address(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 *bdaddr_type) u8 *bdaddr_type)
{ {
if (test_bit(HCI_FORCE_STATIC_ADDR, &hdev->dev_flags) || if (test_bit(HCI_FORCE_STATIC_ADDR, &hdev->dbg_flags) ||
!bacmp(&hdev->bdaddr, BDADDR_ANY)) { !bacmp(&hdev->bdaddr, BDADDR_ANY)) {
bacpy(bdaddr, &hdev->static_addr); bacpy(bdaddr, &hdev->static_addr);
*bdaddr_type = ADDR_LE_DEV_RANDOM; *bdaddr_type = ADDR_LE_DEV_RANDOM;
......
...@@ -387,7 +387,7 @@ static u32 get_supported_settings(struct hci_dev *hdev) ...@@ -387,7 +387,7 @@ static u32 get_supported_settings(struct hci_dev *hdev)
} }
if (lmp_sc_capable(hdev) || if (lmp_sc_capable(hdev) ||
test_bit(HCI_FORCE_SC, &hdev->dev_flags)) test_bit(HCI_FORCE_SC, &hdev->dbg_flags))
settings |= MGMT_SETTING_SECURE_CONN; settings |= MGMT_SETTING_SECURE_CONN;
} }
...@@ -4261,7 +4261,7 @@ static int set_secure_conn(struct sock *sk, struct hci_dev *hdev, ...@@ -4261,7 +4261,7 @@ static int set_secure_conn(struct sock *sk, struct hci_dev *hdev,
status); status);
if (!lmp_sc_capable(hdev) && if (!lmp_sc_capable(hdev) &&
!test_bit(HCI_FORCE_SC, &hdev->dev_flags)) !test_bit(HCI_FORCE_SC, &hdev->dbg_flags))
return cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN, return cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN,
MGMT_STATUS_NOT_SUPPORTED); MGMT_STATUS_NOT_SUPPORTED);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment