From 3d9526b171e0f2b94e478204d232e3ea94296200 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Mon, 5 Oct 2026 21:13:55 +0300 Subject: [PATCH] Bluetooth: make hdev->adv_instance_timeout a boolean Mesh uses millisecond time units for advertisements instead of seconds as normally. These values go to hdev->adv_instance_timeout, which then has mixed units. hdev->adv_instance_timeout is however only used as a true/false flag. Make hdev->adv_instance_timeout boolean flag, to avoid possible future problems with its mixed-units values. Signed-off-by: Pauli Virtanen Signed-off-by: Luiz Augusto von Dentz --- include/net/bluetooth/hci_core.h | 2 +- net/bluetooth/hci_core.c | 6 +++--- net/bluetooth/hci_sync.c | 8 ++++---- net/bluetooth/mgmt.c | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index f631d9484a0b..aa04dec45153 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -601,7 +601,7 @@ struct hci_dev { struct list_head adv_instances; unsigned int adv_instance_cnt; __u8 cur_adv_instance; - __u16 adv_instance_timeout; + bool adv_instance_timeout; struct delayed_work adv_instance_expire; struct idr adv_monitors_idr; diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 5c6884b65976..c8b57848228b 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1617,7 +1617,7 @@ int hci_remove_adv_instance(struct hci_dev *hdev, u8 instance) if (hdev->cur_adv_instance == instance) { if (hdev->adv_instance_timeout) { cancel_delayed_work(&hdev->adv_instance_expire); - hdev->adv_instance_timeout = 0; + hdev->adv_instance_timeout = false; } hdev->cur_adv_instance = 0x00; } @@ -1647,7 +1647,7 @@ void hci_adv_instances_clear(struct hci_dev *hdev) if (hdev->adv_instance_timeout) { disable_delayed_work(&hdev->adv_instance_expire); - hdev->adv_instance_timeout = 0; + hdev->adv_instance_timeout = false; } list_for_each_entry_safe(adv_instance, n, &hdev->adv_instances, list) { @@ -2437,7 +2437,7 @@ struct hci_dev *hci_alloc_dev_priv(int sizeof_priv) hdev->adv_tx_power = HCI_TX_POWER_INVALID; hdev->adv_instance_cnt = 0; hdev->cur_adv_instance = 0x00; - hdev->adv_instance_timeout = 0; + hdev->adv_instance_timeout = false; hdev->advmon_allowlist_duration = 300; hdev->advmon_no_filter_duration = 500; diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 69ebdff2047d..a1cba1a7d6d5 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -470,7 +470,7 @@ static void reenable_adv(struct work_struct *work) static void cancel_adv_timeout(struct hci_dev *hdev) { if (hdev->adv_instance_timeout) { - hdev->adv_instance_timeout = 0; + hdev->adv_instance_timeout = false; cancel_delayed_work(&hdev->adv_instance_expire); } } @@ -570,7 +570,7 @@ static void adv_timeout_expire(struct work_struct *work) hci_dev_lock(hdev); - hdev->adv_instance_timeout = 0; + hdev->adv_instance_timeout = false; if (hdev->cur_adv_instance == 0x00) goto unlock; @@ -2101,7 +2101,7 @@ int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance, /* Only use work for scheduling instances with legacy advertising */ if (!ext_adv_capable(hdev)) { - hdev->adv_instance_timeout = timeout; + hdev->adv_instance_timeout = true; queue_delayed_work(hdev->req_workqueue, &hdev->adv_instance_expire, adv->mesh ? msecs_to_jiffies(timeout) : @@ -5580,7 +5580,7 @@ int hci_dev_close_sync(struct hci_dev *hdev) if (hdev->adv_instance_timeout) { cancel_delayed_work_sync(&hdev->adv_instance_expire); - hdev->adv_instance_timeout = 0; + hdev->adv_instance_timeout = false; } err = hci_dev_shutdown(hdev); diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index aea3482e3893..2e35b09579d3 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1299,7 +1299,7 @@ void mgmt_advertising_removed(struct sock *sk, struct hci_dev *hdev, static void cancel_adv_timeout(struct hci_dev *hdev) { if (hdev->adv_instance_timeout) { - hdev->adv_instance_timeout = 0; + hdev->adv_instance_timeout = false; cancel_delayed_work(&hdev->adv_instance_expire); } }