* [PATCH 1/4] Bluetooth: hci_vhci: convert timeouts to secs_to_jiffies()
2025-02-19 22:51 [PATCH 0/4] Bluetooth: Converge on using secs_to_jiffies() Easwar Hariharan
@ 2025-02-19 22:51 ` Easwar Hariharan
2025-02-19 22:51 ` [PATCH 2/4] Bluetooth: MGMT: " Easwar Hariharan
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Easwar Hariharan @ 2025-02-19 22:51 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz, Johan Hedberg,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman
Cc: linux-bluetooth, linux-kernel, netdev, Easwar Hariharan
Commit b35108a51cf7 ("jiffies: Define secs_to_jiffies()") introduced
secs_to_jiffies(). As the value here is a multiple of 1000, use
secs_to_jiffies() instead of msecs_to_jiffies to avoid the multiplication.
This is converted using scripts/coccinelle/misc/secs_to_jiffies.cocci with
the following Coccinelle rules:
@depends on patch@
expression E;
@@
-msecs_to_jiffies(E * 1000)
+secs_to_jiffies(E)
-msecs_to_jiffies(E * MSEC_PER_SEC)
+secs_to_jiffies(E)
Signed-off-by: Easwar Hariharan <eahariha@linux.microsoft.com>
---
drivers/bluetooth/hci_vhci.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index 7651321d351ccd5a96503bb555b5d9eb2c35b4ff..963741490106ae686b88babff560dc0ad03ec37d 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -316,7 +316,7 @@ static inline void force_devcd_timeout(struct hci_dev *hdev,
unsigned int timeout)
{
#ifdef CONFIG_DEV_COREDUMP
- hdev->dump.timeout = msecs_to_jiffies(timeout * 1000);
+ hdev->dump.timeout = secs_to_jiffies(timeout);
#endif
}
@@ -645,7 +645,7 @@ static int vhci_open(struct inode *inode, struct file *file)
file->private_data = data;
nonseekable_open(inode, file);
- schedule_delayed_work(&data->open_timeout, msecs_to_jiffies(1000));
+ schedule_delayed_work(&data->open_timeout, secs_to_jiffies(1));
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/4] Bluetooth: MGMT: convert timeouts to secs_to_jiffies()
2025-02-19 22:51 [PATCH 0/4] Bluetooth: Converge on using secs_to_jiffies() Easwar Hariharan
2025-02-19 22:51 ` [PATCH 1/4] Bluetooth: hci_vhci: convert timeouts to secs_to_jiffies() Easwar Hariharan
@ 2025-02-19 22:51 ` Easwar Hariharan
2025-02-19 22:51 ` [PATCH 3/4] Bluetooth: SMP: " Easwar Hariharan
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Easwar Hariharan @ 2025-02-19 22:51 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz, Johan Hedberg,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman
Cc: linux-bluetooth, linux-kernel, netdev, Easwar Hariharan
Commit b35108a51cf7 ("jiffies: Define secs_to_jiffies()") introduced
secs_to_jiffies(). As the value here is a multiple of 1000, use
secs_to_jiffies() instead of msecs_to_jiffies to avoid the multiplication.
This is converted using scripts/coccinelle/misc/secs_to_jiffies.cocci with
the following Coccinelle rules:
@depends on patch@
expression E;
@@
-msecs_to_jiffies(E * 1000)
+secs_to_jiffies(E)
-msecs_to_jiffies(E * MSEC_PER_SEC)
+secs_to_jiffies(E)
Signed-off-by: Easwar Hariharan <eahariha@linux.microsoft.com>
---
net/bluetooth/hci_sync.c | 2 +-
net/bluetooth/mgmt.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index dd770ef5ec36840add2fa0549aa1689135a21e4c..a43749aebf76e83f3541deb346015c5e5a620eda 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -1910,7 +1910,7 @@ int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance,
hdev->adv_instance_timeout = timeout;
queue_delayed_work(hdev->req_workqueue,
&hdev->adv_instance_expire,
- msecs_to_jiffies(timeout * 1000));
+ secs_to_jiffies(timeout));
}
/* If we're just re-scheduling the same instance again then do not
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index e8533167aa88377e6ecd8702277730db0fd21b36..a31b46db50dd546c665e18786c2e1efc1391ee61 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1533,7 +1533,7 @@ static void mgmt_set_discoverable_complete(struct hci_dev *hdev, void *data,
if (hci_dev_test_flag(hdev, HCI_DISCOVERABLE) &&
hdev->discov_timeout > 0) {
- int to = msecs_to_jiffies(hdev->discov_timeout * 1000);
+ int to = secs_to_jiffies(hdev->discov_timeout);
queue_delayed_work(hdev->req_workqueue, &hdev->discov_off, to);
}
@@ -1641,7 +1641,7 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
hdev->discov_timeout = timeout;
if (cp->val && hdev->discov_timeout > 0) {
- int to = msecs_to_jiffies(hdev->discov_timeout * 1000);
+ int to = secs_to_jiffies(hdev->discov_timeout);
queue_delayed_work(hdev->req_workqueue,
&hdev->discov_off, to);
}
@@ -2534,7 +2534,7 @@ static int send_hci_cmd_sync(struct hci_dev *hdev, void *data)
skb = __hci_cmd_sync_ev(hdev, le16_to_cpu(cp->opcode),
le16_to_cpu(cp->params_len), cp->params,
cp->event, cp->timeout ?
- msecs_to_jiffies(cp->timeout * 1000) :
+ secs_to_jiffies(cp->timeout) :
HCI_CMD_TIMEOUT);
if (IS_ERR(skb)) {
mgmt_cmd_status(cmd->sk, hdev->id, MGMT_OP_HCI_CMD_SYNC,
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 3/4] Bluetooth: SMP: convert timeouts to secs_to_jiffies()
2025-02-19 22:51 [PATCH 0/4] Bluetooth: Converge on using secs_to_jiffies() Easwar Hariharan
2025-02-19 22:51 ` [PATCH 1/4] Bluetooth: hci_vhci: convert timeouts to secs_to_jiffies() Easwar Hariharan
2025-02-19 22:51 ` [PATCH 2/4] Bluetooth: MGMT: " Easwar Hariharan
@ 2025-02-19 22:51 ` Easwar Hariharan
2025-02-19 22:51 ` [PATCH 4/4] Bluetooth: L2CAP: " Easwar Hariharan
2025-02-20 18:10 ` [PATCH 0/4] Bluetooth: Converge on using secs_to_jiffies() patchwork-bot+bluetooth
4 siblings, 0 replies; 6+ messages in thread
From: Easwar Hariharan @ 2025-02-19 22:51 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz, Johan Hedberg,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman
Cc: linux-bluetooth, linux-kernel, netdev, Easwar Hariharan
Commit b35108a51cf7 ("jiffies: Define secs_to_jiffies()") introduced
secs_to_jiffies(). As the value here is a multiple of 1000, use
secs_to_jiffies() instead of msecs_to_jiffies() for readability.
Signed-off-by: Easwar Hariharan <eahariha@linux.microsoft.com>
---
net/bluetooth/smp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 8b9724fd752a1a713d55630fb19fc7ffc2ac0079..a31c6acf1df2bbdc512d1406663ad06069c1f184 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -55,7 +55,7 @@
/* Keys which are not distributed with Secure Connections */
#define SMP_SC_NO_DIST (SMP_DIST_ENC_KEY | SMP_DIST_LINK_KEY)
-#define SMP_TIMEOUT msecs_to_jiffies(30000)
+#define SMP_TIMEOUT secs_to_jiffies(30)
#define ID_ADDR_TIMEOUT msecs_to_jiffies(200)
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 4/4] Bluetooth: L2CAP: convert timeouts to secs_to_jiffies()
2025-02-19 22:51 [PATCH 0/4] Bluetooth: Converge on using secs_to_jiffies() Easwar Hariharan
` (2 preceding siblings ...)
2025-02-19 22:51 ` [PATCH 3/4] Bluetooth: SMP: " Easwar Hariharan
@ 2025-02-19 22:51 ` Easwar Hariharan
2025-02-20 18:10 ` [PATCH 0/4] Bluetooth: Converge on using secs_to_jiffies() patchwork-bot+bluetooth
4 siblings, 0 replies; 6+ messages in thread
From: Easwar Hariharan @ 2025-02-19 22:51 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz, Johan Hedberg,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman
Cc: linux-bluetooth, linux-kernel, netdev, Easwar Hariharan
Commit b35108a51cf7 ("jiffies: Define secs_to_jiffies()") introduced
secs_to_jiffies(). As the value here is a multiple of 1000, use
secs_to_jiffies() instead of msecs_to_jiffies() for readability.
Signed-off-by: Easwar Hariharan <eahariha@linux.microsoft.com>
---
include/net/bluetooth/l2cap.h | 4 ++--
net/bluetooth/l2cap_core.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 9189354c568f442ccd55efa37d639a613be470ce..0bf8cb17a6e864793f84a4bc8620414a7a396b2f 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -38,8 +38,8 @@
#define L2CAP_DEFAULT_TX_WINDOW 63
#define L2CAP_DEFAULT_EXT_WINDOW 0x3FFF
#define L2CAP_DEFAULT_MAX_TX 3
-#define L2CAP_DEFAULT_RETRANS_TO 2000 /* 2 seconds */
-#define L2CAP_DEFAULT_MONITOR_TO 12000 /* 12 seconds */
+#define L2CAP_DEFAULT_RETRANS_TO 2 /* seconds */
+#define L2CAP_DEFAULT_MONITOR_TO 12 /* seconds */
#define L2CAP_DEFAULT_MAX_PDU_SIZE 1492 /* Sized for AMP packet */
#define L2CAP_DEFAULT_ACK_TO 200
#define L2CAP_DEFAULT_MAX_SDU_SIZE 0xFFFF
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index fec11e576f310cda115c924245458368a663528a..bc820958cb9230545d99a942a73ba53eaccba14b 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -282,7 +282,7 @@ static void __set_retrans_timer(struct l2cap_chan *chan)
if (!delayed_work_pending(&chan->monitor_timer) &&
chan->retrans_timeout) {
l2cap_set_timer(chan, &chan->retrans_timer,
- msecs_to_jiffies(chan->retrans_timeout));
+ secs_to_jiffies(chan->retrans_timeout));
}
}
@@ -291,7 +291,7 @@ static void __set_monitor_timer(struct l2cap_chan *chan)
__clear_retrans_timer(chan);
if (chan->monitor_timeout) {
l2cap_set_timer(chan, &chan->monitor_timer,
- msecs_to_jiffies(chan->monitor_timeout));
+ secs_to_jiffies(chan->monitor_timeout));
}
}
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 0/4] Bluetooth: Converge on using secs_to_jiffies()
2025-02-19 22:51 [PATCH 0/4] Bluetooth: Converge on using secs_to_jiffies() Easwar Hariharan
` (3 preceding siblings ...)
2025-02-19 22:51 ` [PATCH 4/4] Bluetooth: L2CAP: " Easwar Hariharan
@ 2025-02-20 18:10 ` patchwork-bot+bluetooth
4 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+bluetooth @ 2025-02-20 18:10 UTC (permalink / raw)
To: Easwar Hariharan
Cc: marcel, luiz.dentz, johan.hedberg, davem, edumazet, kuba, pabeni,
horms, linux-bluetooth, linux-kernel, netdev
Hello:
This series was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Wed, 19 Feb 2025 22:51:28 +0000 you wrote:
> This series converts users of msecs_to_jiffies() that either use the
> multiply pattern of either of:
> - msecs_to_jiffies(N*1000) or
> - msecs_to_jiffies(N*MSEC_PER_SEC)
>
> where N is a constant or an expression, to avoid the multiplication.
>
> [...]
Here is the summary with links:
- [1/4] Bluetooth: hci_vhci: convert timeouts to secs_to_jiffies()
https://git.kernel.org/bluetooth/bluetooth-next/c/44174b3bb552
- [2/4] Bluetooth: MGMT: convert timeouts to secs_to_jiffies()
https://git.kernel.org/bluetooth/bluetooth-next/c/b0ade3137c2a
- [3/4] Bluetooth: SMP: convert timeouts to secs_to_jiffies()
https://git.kernel.org/bluetooth/bluetooth-next/c/a6228ba15de0
- [4/4] Bluetooth: L2CAP: convert timeouts to secs_to_jiffies()
https://git.kernel.org/bluetooth/bluetooth-next/c/12159413e3fa
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread