Bluetooth: Move {min,max}_key_size debugfs into hci_debugfs_create_le
Subsystems (2)
Marcel Holtmann
maintainerPATCH 1/1 Bluetooth: Move {min,max}_key_size debugfs into hci_debugfs_create_le
The debugfs entries for {min,max}_key_size are created during SMP registration and thus it might lead to multiple attempts to create the same entries. Avoid this by moving them to the LE controller init section.
Signed-off-by Marcel Holtmann <[email protected]>
--- net/bluetooth/hci_debugfs.c | 61 ++++++++++++++++++++++++ net/bluetooth/smp.c | 93 ------------------------------------- 2 files changed, 61 insertions(+), 93 deletions(-)
net/bluetooth/hci_debugfs.c +61 -0
@@ -26,6 +26,7 @@#include <net/bluetooth/bluetooth.h> #include <net/bluetooth/hci_core.h> +#include "smp.h" #include "hci_debugfs.h" #define DEFINE_QUIRK_ATTRIBUTE (__name, __quirk) \
@@ -989,6 +990,62 @@ static int adv_max_interval_get(void *data, u64 *val)DEFINE_SIMPLE_ATTRIBUTE (adv_max_interval_fops, adv_max_interval_get, adv_max_interval_set,"%llu\n" ); +static int min_key_size_set (void *data,u64 val) +{ +struct hci_dev *hdev = data; + +if (val > hdev->le_max_key_size || val <SMP_MIN_ENC_KEY_SIZE ) +return -EINVAL ; + +hci_dev_lock (hdev); + hdev->le_min_key_size = val; +hci_dev_unlock (hdev); + +return 0 ; +} + +static int min_key_size_get (void *data,u64 *val) +{ +struct hci_dev *hdev = data; + +hci_dev_lock (hdev); + *val = hdev->le_min_key_size; +hci_dev_unlock (hdev); + +return 0 ; +} + +DEFINE_SIMPLE_ATTRIBUTE (min_key_size_fops, min_key_size_get, + min_key_size_set,"%llu\n" ); + +static int max_key_size_set (void *data,u64 val) +{ +struct hci_dev *hdev = data; + +if (val >SMP_MAX_ENC_KEY_SIZE || val < hdev->le_min_key_size) +return -EINVAL ; + +hci_dev_lock (hdev); + hdev->le_max_key_size = val; +hci_dev_unlock (hdev); + +return 0 ; +} + +static int max_key_size_get (void *data,u64 *val) +{ +struct hci_dev *hdev = data; + +hci_dev_lock (hdev); + *val = hdev->le_max_key_size; +hci_dev_unlock (hdev); + +return 0 ; +} + +DEFINE_SIMPLE_ATTRIBUTE (max_key_size_fops, max_key_size_get, + max_key_size_set,"%llu\n" ); +static int auth_payload_timeout_set (void *data,u64 val) {struct hci_dev *hdev = data;
@@ -1071,6 +1128,10 @@ void hci_debugfs_create_le(struct hci_dev *hdev) &adv_max_interval_fops);debugfs_create_u16 ("discov_interleaved_timeout" ,0644 , hdev->debugfs, &hdev->discov_interleaved_timeout); +debugfs_create_file ("min_key_size" ,0644 , hdev->debugfs, hdev, + &min_key_size_fops); +debugfs_create_file ("max_key_size" ,0644 , hdev->debugfs, hdev, + &max_key_size_fops);debugfs_create_file ("auth_payload_timeout" ,0644 , hdev->debugfs, hdev, &auth_payload_timeout_fops);
net/bluetooth/smp.c +0 -93
105 lines not on this page · raw message
Signature · 1 line
2.24.1
Johan Hedberg
AppliedHi Marcel,
Quoted 10 lines · Marcel Holtmann
The debugfs entries for {min,max}_key_size are created during SMP registration and thus it might lead to multiple attempts to create the same entries. Avoid this by moving them to the LE controller init section.
Signed-off-by Marcel Holtmann <[email protected]>--- net/bluetooth/hci_debugfs.c | 61 ++++++++++++++++++++++++ net/bluetooth/smp.c | 93 ------------------------------------- 2 files changed, 61 insertions(+), 93 deletions(-)
Applied to bluetooth-next. Thanks.
Johan